Tropo is part of CiscoLearn More

Phone Number Intelligence through Tropo and Whitepages Pro

Posted on July 26, 2016 by Adam Kalsey

Customers often ask us how they can tell if a number can receive a text message. Or how to filter out robodialers from calling their numbers. Today’s tutorial shows how to use the Whitepages Pro API to control your Tropo phone number.

The Whitepages Pro Phone Intelligence API can be used to gather a large amount of information about a US phone number. Who owns it, which carrier it’s on, what type of line it is, and in many cases, even how long the phone has been active. By combining the Whitepages API with Tropo, you can change how your application routes calls based on who is behind that phone number.

Using their API is simple. You get an API key, include that key and the phone number in a query string, and get back a large JSON document containing tons of information about the phone number. Parse the JSON document and the data in your application.

Caller Quality

One of the datapoints returned by Whitepages is a reputation score of a phone number. This score is dervied by the volume of calls made by that number and nuisance reports by people. A score of 1-4 is returned, with 4 being the most suspicious and 1 indicating it’s a high-quality call. The raw data is returned as well, showing how many calls this number places, what sort of nuisances (telemarketer, survey, phishing, etc) have been reported on it, and how confident they are in the scoring.

Using this with Tropo to determine whether to answer a call or even to execute the rest of the app can be done by combining the score with Tropo’s reject() method. In your Tropo application, take the caller ID of the incoming call, look it up using the Whitepages API, and if the score is 3 or 4, reject the call, giving the caller a busy signal.

The following Ruby sample code shows how it would work. Lines 3-9 make the API call to Whitepages, in line 7 using the caller ID of the incoming call as the phone number to look up. Line 11 logs the reputation score. On line 12-14, if the score is 3 or more, it’s spam and the call is logged as spam and then rejected.

require 'rest-client'

wp_key = 'your-api-key'

response = RestClient.get '', {:params => {
  'api_key' => wp_key,
  'phone_number' => $currentCall.callerID
result = JSON.parse(

log "Phone reputation for #{$currentCall.callerID} is #{result['results'][0]['reputation']['level']}"
if result['results'][0]['reputation']['level'] >= 3 then
	log "Caller from #{$currentCall.callerID} is spam"

Place this code at the top of any Ruby application that gets incoming calls, and they’ll automatically be filtered for call quality.

Sending text messages to Landlines

Applications that send text messages to a list of users often have a problem with people who add landline or VOIP numbers to the list. Sending an message to these numbers can fail to get the message out, as carriers will attempt to deliver the text, even though the number can’t receive it. Instead, an application can check to see if the line is a mobile, and if not, call the number and play the message as text to speech. As an added bonus, this sample uses Tropo’s answering machine detection to leave a message if a voicemail or machine answers. And as an added added bonus, the sample checks the Whitepages API to see if the number is a valid, active number, capable of receiving calls or text messages.

The application is kicked off with a Tropo Session API call, passing in two variables: ‘to’ contains the number to dial, and ‘msg’ contains the message to text or speak. Lines 3-8 request the phone number info from the Whitepages API, using the ‘to’ variable as the lookup number in line 6. Line 10 logs the phone line type. Line 12 checks to see if the phone number ‘is_connected’ and if it’s not, will just skip calling or sending the message.

Lines 13-14 send the contents of ‘msg’ by text message if the number is a mobile phone. If it’s not a mobile, line 16 calls the number instead. Line 18 sets up answering machine detection, playing an introduction message, and then once Tropo’s determined that the call is answered by a human or that a machine is recording, lines 19 and 20 play the message.

require 'rest-client'

wp_key = 'your-api-key-here'
response = RestClient.get '', {:params => {
  'api_key' => wp_key,
  'phone_number' => to
result = JSON.parse(

log "%% Phone number #{$to} is #{result['results'][0]['line_type']}. Connected: #{result['results'][0]['is_connected']}" 

if result['results'][0]['is_connected'] || result['results'][0]['is_connected'].nil? then
	if result['results'][0]['line_type'] == 'Mobile' then
		message($msg, {:to => $to, :network => 'SMS'})
		call $to, {
		   :callerID => $from,
		   :timeout => 30,
		   :machineDetection => {"introduction" => "Hello, this is an important message from your dentist. Please stay on the line."},
		   :onAnswer => lambda {
		       say $msg

Get Started

The Whitepages Pro API is priced per query, starting at 1¢ per query and has a free trial available. Visit the Whitepages Pro API documentation to get an API key and get started.

DevOps with Cisco Spark: Follow your Tropo calls and SMS activity in real-time

Posted on June 13, 2016 by Steve Sfartz

Integrating phone calls and SMS into your applications can be done in a snap with Tropo’s unique Scripting platform. A few lines of Javascript, PHP, Python, Groovy or Ruby, and you’re ready to run your phone call or SMS with a custom integration. Check this javascript snippet which implements a SMS subscription service. Try it yourself: text your email address to +1 414-882-4773

Try it by yourself at +1 438–448–3585 (text or call)

Now comes the time to support and grow your application: you want to track user activity in real-time and regularly check that your script executes properly on Tropo servers. To do this you’ ll have to create a custom dashboard, or dig into Tropo script logs (which can be detailed).

This is where Cisco Spark can help. We’ll show you how to push your Tropo script activity into a Cisco Spark room in (near) real-time. At the end of the article, you’ll have your INFO and DEBUG log levels pushed to Spark.


Tropo DevOps with Cisco Spark

If you care about DevOps, you’ve already connected most of your critical backend applications and strategic delivery processes to your favorite real-time messaging platform to raise alerts or to simply share information instantly with colleagues. Let’s extend your DevOps practices to Tropo in 3 steps:

“We’ll leverage the Cisco Spark API from Tropo’s Javascript Runtime. Note that the same principles apply to the all languages supported by the Tropo Cloud Platform (Javascript, Ruby, Python, PHP, and Groovy). As of now, example code is only provided in Javascript, and your contributions are welcome.”

1. Create a Spark incoming webhook

From the Spark Web client, create a room to be used exclusively for Tropo Logs or pick an existing room.

In the right hand panel of the Spark Room, click “add Integrations” and choose “incoming integration”.

“If you do not see the “incoming integration panel”, there’s good chance you are not in the Spark WEB client, but a Desktop or Mobile Spark client.”

Name your integration. Tis name will be used to publish messages to the Spark Room as new log entries are created by your Tropo script.

Finally, copy your webhook URI suffix.

1. Create a Spark incoming webhook

2. Add the Spark4Tropo Javascript library to your script

Copy/paste the Spark4Tropo.js code snippet at the top of your Tropo script.

Insert your Spark integrations suffix into the “YOUR_INTEGRATION_SUFFIX” placeholder. You may also want to identify your logs as they are pushed to the Spark room by changing the APPNAME.

2. Copy and customize the Spark4Tropo.js snippet

3. Enhance your Script Business Logic

Replace your script’s logs by the debug() and info() functions provided by the Spark4Tropo.js code snippet.

3. turn your logs to the provided log & debug functions

Now run your code again, and watch Tropo logs showing up in Spark as your script gets executed.

Future thoughts

You may create 2 Spark Rooms : one to follow Business activity (info logs in the example above), and the other one for Debugging Purposes (fine grained logs).

Spark4Logs configuration to send logs to several Spark Rooms

Spark Haus by Cisco - Dublin, Ireland

Posted on June 8, 2016 by Phil Bellanti

We just got back from an amazing popup event held in Ireland on June 1st & 2nd. For this one, we brought ‘Spark Haus by Cisco’ to one of Dublin’s most unique venues for two-days of tech talks, demos and a hackathon, featuring the Spark and Tropo APIs. The venue was inside Dogpatch Labs, a co-working facility located in the heart of the historic Dublin Docklands. What’s really unique about this particular event space is it’s located inside a 200-year old redeveloped wine and whiskey vault, downstairs from Dogpatch’s main offices. It was an extraordinary setting to say the least. Our distinguished Technical Marketing Manager for Collaboration APIs, Adam Kalsey, was the MC for the event.

After breakfast on the first day, we started off with some tech talks on the Spark and Tropo APIs, presented by Cisco’s Jonathan Field and yours truly. The sessions were mainly geared towards the developers participating in the hackathon and coding challenges, so they can get familiarized with the technologies. Next, one of our amazing partners,, provided an awesome live demo of how they’ve integrated Spark and Tropo into a solution for insurance agents to provide quotes to visitors online. You can view a short video of Altocloud’s demo here:

Two other great Cisco partners who sponsored the event and, also held sessions on their respective offerings.

After the tech talks concluded in the afternoon, the actual hackathon kicked into high gear. We ended up with four teams in the hackathon, all developing applications using the Spark and/or Tropo APIs. The developers were definitely eager to get coding since the list of prizes to be awarded were very enticing:

  • 1st Place Team – 4 x Galaxy Visitor 7 Quadcopters
  • 2nd Place Team – 4 x Bose ® SoundLink Bluetooth Speaker III – Silver
  • 3rd Place Team – 4 x Plantronics Premium Headsets

As a side contest, those who completed some Tropo and Spark coding challenges were awarded a tech gadget (courtesy of Exertis) from a prize grab bag.

On day two, the hackathon teams submitted and presented a demo of their applications. All of the submissions were very creative and quite frankly, some of the most advanced applications we’ve seen at a Spark/Tropo hackathon. The winning submissions are as follows:

Third place went to the “Purple Pi”  team, who presented a mobile expense management application. In their app, credit card transactions appear in a Spark conversation, allowing you to categorize expenses, post receipts, and mark each expense as personal or reimbursable.

Second place went to the “Meeting Insights” team.  Their application aimed to improve the efficiency of meetings by reminding every attendee and speaker right before their time to talk comes up and provide a text backchannel (using Tropo) for every meeting. The app also automatically judged the mood and the contents of the conversation and posted to the backchannel for archiving.

The grand prize winning team was “Soteria” who put together a very neat real-time collaboration solution for a paperless healthcare application using Spark. The app allows medical providers to discuss a patient’s medical chart and have that discussion automatically update the chart by identifying health-related keywords from the chat.

After the event concluded, we had a hearty celebration aboard the Boat Restaurant & Bar – MV Cill Airne, where a good time was had by all.  We received a lot of positive feedback from the attendees and definitely hope to return to Dublin again soon. Many thanks to the Cisco team in the Dublin and Galway offices, who truly helped make this Spark Haus event a successful one!