SMS Voting App in 10 Minutes with Tropo and CouchDB

February 8th, 2012 by Mark Headd

Lat fall, I attended CouchConf NYC and gave a presentation on using Tropo with CouchDB.

It only recently occurred to me that I never did a proper screencast and blog post about my presentation, which struck me as a bit odd – I constantly get asked how to set up an SMS voting app with Tropo.

The good news is that setting up this type of app is incredibly easy with Tropo and CouchDB. The even better news is that I’ve finally gotten around to recording a screencast on how to do it – watch below.

spacer

A vote for the Rolling Stones.

All of the code used in this demo can be obtained from GitHub.

To install the CouchApp utility, go to the CouchApp project page.

If you’re looking for an easy way to set up a CouchDB instance, have a look at IrisCouch.

By pairing Tropo with CouchDB and a CouchApp running in IrisiCouch, you can have an SMS and phone voting app running entirely in the cloud in about 10 minutes. It should actually take you longer to write up the categories for your voting app than it should to deploy this solution.

Tropo + CouchDB, FTW!

Tags: couchdb, SMS, voting
Posted in JavaScript, PHP, SourceCode, Tropo | No Comments »

Customer Spotlight: PalmLing

January 30th, 2012 by cmatthieu

spacer We are excited to feature PalmLing on this week’s Tropo Customer Spotlight! Today I sat down with Ryan Frankel, one of the co-founders of PalmLing, to discuss their new business and learn more about how they are using Tropo and Phono for their human translation services.

What is PalmLing?

PalmLing is human translation in the palm of your hand. PalmLing is a phone-based platform that enables travelers to use their cell phones to speak with exceptional translators. Translators are available 24/7 and can speak directly to the person with whom you are communicating, or they can provide the information you need to communicate in a foreign language.

PalmLing uses Tropo’s Voice APIs and platform to answer international calls and initiate conferences between callers and translators to provide their service. PalmLing also uses Phono, Tropo’s web phone, to demo their translation service directly from their website. Phono basically initiates a call from the web browser into their Tropo voice application just as if someone dialed their phone number.

To learn more about PalmLing, visit their website at palmling.com!

Tags: conferencing, international, palmling, service, spotlight, translation
Posted in Tropo, Video, Web API | No Comments »

Tropo Teams with Apigee on API Explorer

January 27th, 2012 by cmatthieu

spacer

Tropo is excited to partner with Apigee on the Tropo API Explorer! The API Explorer allows more developers to explore, learn, and test Tropo’s cloud communications APIs faster than ever before.

Tropo provides an API and cloud communications platform for building powerful Voice applications with speech recognition and text-to-speech in 24 languages, call recording, conferencing, SIP/VoIP, and phone numbers in 41 countries. Tropo also provides international SMS services.

The API Explorer makes this integration easier, helping developers authenticate and test our API in seconds, view the full surface area of an API, view request/response pairs in only a few clicks and share what they are seeing with others.

Now you can use the Apigee API explorer to experiment with our REST API without writing a single line of code! It is built with Apigee To-Go, a free product to let users build, skin and embed their own API Console. The Tropo API Explorer is embedded below or you can jump to this full screen version.

Tags: API, api explorer, apigee, rest, rest api
Posted in Samples, SMS, Tropo, Web API | No Comments »

Tropo Drinkup San Francisco

January 25th, 2012 by cmoe

spacer Join us Friday January 27th for our Tropo Drinkup in San Francisco at our SOMA headquarters office and enjoy some complimentary drinks while entertained by future rockstars letting loose on our piano and guitars.

We like to get our happy hours on early so be ready to break some New Year’s resolutions with us at 3:58pm.  Yep, 3:58pm.  Because two minutes can make the world of a difference for your weekend.

End your work week early and shimmy by the Tropo office for some beers, bites and a lil’ rock jam session if you are so inclined.

Tropo Drinkup San Francisco

When: Friday January 27th

Where: 28 2nd Street 3rd Floor San Francisco, CA 94123

Time: 3:58pm- 6:00pm

Tags: developers, drinkup, happy hour, San francisco, Tropo
Posted in Tropo | No Comments »

Tropo joins Startup World in 36 cities

January 23rd, 2012 by Diggz

spacer Tropo loves startups. Why? Because entrepreneurs always think of new and innovative ways to use Tropo that we’ve never even dreamed. Since we launched Tropo in 2009, we’ve helped thousands of developers and entrepreneurs build apps, demo them, pitch them, get investment and launch into full businesses. In fact, pretty much everyone behind Tropo from the engineers to evangelists…even our newest community manager…have come from startups of our own. It’s part of our DNA.

That’s why we’re extremely pleased to announce that Tropo is partnering with Newspepper, TheNextWeb, i/o Ventures, Startup Bus, Startup America (and a whole lot more!) to launch Startup World!

Startup World is a global competition to find the next big thing. The competition will be held in 36 cities world-wide, with the regional winners flying to Silicon Valley for a grand showdown to battle it out in front of a panel of expert judges to be crowned the “world’s best startup”.

spacer

We’ll be kicking off Startup World at a Launch Party at i/o Ventures in San Francisco on Tuesday Jan 24th 2012.   Come join us for the fun and some awesome speakers including Sarah Lacy!

Tags: Startup World
Posted in Events, Tropo | No Comments »

Meet Phono – Tropo’s Web Phone

January 23rd, 2012 by cmatthieu

spacer Have you heard about Phono, our open source Javascript Phone API project?

Phono is a free HTML5 jQuery-based web phone that you can add to any web page to place or receive open SIP-based VoIP calls to/from any web browser (or iOS/Android mobile device using Phono Mobile)!

Phono can be connected to Tropo to place or receive phone calls to/from real telephone numbers! Phono can also interact with Tropo voice applications directly from a web page using Tropo’s speech recognition and text-to-speech in 24 languages as well as record and play media such as WAV or MP3 files or conduct conference calls, call transfers, call recording, etc.

To make things even better, Phono and Tropo both support SIP headers which are basically key/value pairs of data that you can sent along with calls. SIP headers are very common in call center applications and enterprise screen-pop implementations. Using SIP headers allows Phono to place a call into a Tropo application and pass along data instructing Tropo to transfer the call to another telephone number. This is how all of the click-to-call demo applications work on phono.com. These demo applications are also limited to 10 minutes in length so that you can experience the quality of a Phono call and write your own Tropo application for longer calls.

Because we have had a few questions lately on this topic, I wanted to provide some sample code for both Phono and Tropo to make this easier for you to apply to your application. This demo application allows you to enter a phone number on a web page and call it using Phono and Tropo. The web page has a simple form that asks for a phone number and has a call button that initiates a SIP VoIP call to Tropo app:9996182316. Reviewing the Phono code below, you will find that it uses jQuery to pass the phone number value in the textbox to Tropo as a SIP header.

spacer

<html>
  <head>
    <script src="/img/spacer.gif"> 

You could write a Tropo transfer application using the Scripting API in one line of Ruby code that transfers the call to the phone number in the SIP header like this:

transfer $currentCall.getHeader("x-numbertodial")

What if you wanted to add a timer that ends the call after 10 minutes like we do on phono.com for demo purposes? This feature is also simple but it requires multithreading your Ruby application and using our REST API for sending a signal to interrupt the transfer method once your timer reaches its alarm.

require "net/http"

# Create second thread for timer and announcements
Thread.new do
  sleep 600 # Note: Sleep is in seconds so 600 = 10 minutes

  http = Net::HTTP.new "api.tropo.com"

  request = Net::HTTP::Get.new "/1.0/sessions/#{$currentCall.sessionId}/signals?action=signal&value=limitreached"
  response = http.request request
end

say "hold please while we transfer your call."
transfer $currentCall.getHeader("x-numbertodial"), :allowsignals => "limitreached"
say "your limit has been reached."

That’s cool but what if you wanted to block certain phone numbers or limit the demo calls to North America? You could add area codes or phone numbers to a regex array and check the desired phone number against the list of regexes to see if you should allow the call to transfer or not like this example:

phone = $currentCall.getHeader "x-numbertodial"

# Blocked North American area codes
blocked = [
  /^\+?1?8[024]9/,
  /^\+?1?26[48]/,
  /^\+?1?24[26]/,
  /^\+?1?34[05]/,
  /^\+?1?[62]84/,
  /^\+?1?67[10]/,
  /^\+?1?78[47]/,
  /^\+?1?8[024]9/,
  /^\+?1?86[89]/,
  /^\+?1?441/,
  /^\+?1?473/,
  /^\+?1?664/,
  /^\+?1?649/,
  /^\+?1?721/,
  /^\+?1?758/,
  /^\+?1?767/,
  /^\+?1?876/,
  /^\+?1?939/
]

block_call = blocked.any? { |x| phone =~ x }

You could add this code immediately above your transfer and add a conditional statement that says something like this example:

if block_call
  say "calls to this area code are blocked."
else
  say "hold please while we transfer your call."
  transfer phone, :allowsignals => "limitreached"
  say "your limit has been reached."
end

You could also add billing functionality to the Tropo script by applying a rate based on country code and multiply it times the number of seconds that the call was in progress. To accomplish this goal, you would add a timestamp at the beginning of the script and a timestamp directly following the transfer method. When either party hangs up, the Tropo script will continue running with the line immediately following the blocked method such as transfer in this case.

If necessary, you could also check to see if the Phono caller is still on the call by interrogating the $currentCall.isActive property or by wrapping your entire application in a while loop like this example:

while $currentCall.isActive
  # Do Stuff
end

I think that should get you started! You can now build your next-generation click-to-call application using Phono and Tropo! Please let us know how you are using Phono with your Tropo applications :)

Tags: click to call, phono, Ruby, scripting api, sip, sip headers, Tropo, voip, web phone
Posted in Awesome, mashups, Open Source, Ruby, SourceCode, Tropo | No Comments »

Changes to Tropo Channel Support

January 11th, 2012 by Adam Kalsey

As Tropo evolves, we continue to evaluate our product features and make changes to improve the overall experience of using Tropo. Often, this means we add a feature or improve an existing one. Sometimes, this means removing a feature.

Tropo will be deprecating two features at the end of this month.

  • Instant Messaging and Twitter – Sending instant messages to your application was a fun idea and we used this a lot internally to test text applications, but shifting network protocols and uncooperative IM services meant we spent a lot of effort on the feature for very little positive result. We will be disabling the ability to add new IM networks shortly, and turning off the IM servers on January 28. Read more about this change here.
  • Skype numbers – Providing each application a Skype number allowed developers to test incoming calls to their applications. Unlike all of our other phone numbers and VoIP access, this was one-way: you could not call out with Skype. The Microsoft acquisition of Skype has left even this limited support with an uncertain future. You can continue to test your applications with SIP, phone numbers, or Phono. We’ve even embedded Phono so you can dial your applications with one click. Read more about this change here.

Changing and shaping the future of communications takes a lot of focus, and sometimes requires us to reassess the past. We’ve learned a lot from our Skype and IM support, and will put that knowledge to work in creating more great things in the future.

Deprecating these features is the first step in allowing us to focus on things that our users truly want. Look for a lot of great things coming from Tropo in the coming weeks and months.

Stay tuned!

Tags: end of life, features, product management
Posted in Tropo | No Comments »

Sending SMS to your Constant Contact list

December 27th, 2011 by Adam Nutt

One of the nice things about Tropo is that it does a lot of the heavy lifting for you, letting you add amazing features to existing products. One very popular contact manager is Constant Contact. Since your contacts must opt-in to this service, combining this with Tropo provides you a nice way to keep in touch with them beyond simple email.

spacer

In this post I’ll describe how I created a Python script that retrieves your contact list from CC and sends them a text message using Tropo. I’m using a hosted file located on the cloud at Tropo.com for this.

What you’ll need:

  • Python
  • Your Constant Contact API key (from developer.constantcontact.com/)
  • Your Constant Contact username and password
  • A Tropo account

Let’s start with the easy part, making a hosted Tropo application to send our users a message.

  1. Log in to tropo.com
  2. From “Your Applications”, click “Create New Application”
  3. Click “Tropo Scripting”
  4. Give your application a name
  5. For the URL, click “Hosted File” and then “Create a new hosted file for this application”
  6. Fill in the filename (in this example I’m going to use JavaScript on the Tropo side, so I chose test.js)
  7. Then just add the following 2 lines of code
call('+' + numberToDial, {
    network:"SMS"});
say(msg);

Then just click “Create File” and then “Create Application”. Once our magic monkey finishes creating your application, you will see the settings page for your application.

Next step is to add a phone number to this application. Click “Add a new phone number” and then choose your area code (Tropo only supports SMS from US and Canadian numbers at this time), then click the plus symbol to add this phone number to the application. Once your have completed these steps you’ll be taken back to the application settings page.

That’s almost all we need from Tropo. Let’s take a look at the Python code:

import urllib
import urllib2
from xml.dom import minidom
cc_url = 'https://api.constantcontact.com/ws/customers/{user_name}/contacts' cc_api_key = '{paste_your_api_key_inbetween_the_quotes}'
cc_username = '{user_name}'
cc_password = '{password}'

TROPO_URL = 'api.tropo.com/1.0/sessions?action=create&token={The Outbound Messaging Token goes here}'
SMS_MSG = 'Wishing you a happy holidays! - From the Tropo Team'

This first part, shown above, sets up our URLs – one for Constant Contact and one for Tropo. SMS_MSG will contain the content used as the body of your message.

#CC uses Basic Authentication for their API. This code sets up a password manager to take care of that for us
passman = urllib2.HTTPPasswordMgrWithDefaultRealm()
passman.add_password(None, cc_url, cc_api_key + '%' + cc_username, cc_password)
authhandler = urllib2.HTTPBasicAuthHandler(passman)
opener = urllib2.build_opener(authhandler) urllib2.install_opener(opener)

There's some heavy lifting going on here! Constant Contact is configured to require Basic Authentication for their API. Python provides us with a really nice password manager so we don't have to worry about encoding this into our HTTP request.

pagehandle = urllib2.urlopen(cc_url)
data = pagehandle.read()
dom = minidom.parseString(data)
entry_node = dom.getElementsByTagName("entry")

This code above sends a request to Constant Contact and parses the XML result. Each of your contacts is stored as an Entry in the XML data. What we want to do is loop over each one of these entries to get the unique ID:

for entry in entry_node:
	id = entry.getElementsByTagName("id")
	id = id[0].firstChild.nodeValue
	pagehandle = urllib2.urlopen(cc_url + '/' + id.rsplit('/', 1)[1])
	data = pagehandle.read()
	dom = minidom.parseString(data)
	contact_node = dom.getElementsByTagName("Contact")

Now we've iterated over all of our entries, and requested for the Constant Contact API to return the detailed record for each Contact. The field that we'll use to send our contacts an SMS is defined as "HomePhone" in the code below:

	for contact in contact_node:
		phone_num = contact.getElementsByTagName("HomePhone")
		phone_num = phone_num[0].firstChild.nodeValue
		url = TROPO_URL + '&numberToDial=' + phone_num + '&msg=' + urllib.quote(SMS_MSG)
		page = urllib2.urlopen(url)
		data = page.read()

Now we've parsed out the phone number for our users and requested that Tropo send them our season's greetings!

Note: If your phone numbers are not in a 10 digit format, this request will fail.
Note 2: The outbound messaging token can be found under the settings for your application.

This is something that could clearly be extended to a wide range of things: running specials, thanking customers, really the possibilities are only limited by your imagination. Also, if you wanted to have Tropo talk to the person instead of send a text message, just make the first line of your hosted application look like this:

call('+' + numberToDial);

To run this, take the script, edit it with your information and run it from a terminal window: python my_script_name.py

And here's the code in full:

import urllib
import urllib2
from xml.dom import minidom

cc_url = 'https://api.constantcontact.com/ws/customers/{user_name}/contacts' cc_api_key = '{paste_your_api_key_inbetween_the_quotes}'
cc_username = '{user_name}'
cc_password = '{password}'

TROPO_URL = 'api.tropo.com/1.0/sessions?action=create&token={The Outbound Messaging Token goes here}'
SMS_MSG = 'Wishing you a happy holidays! - From the Tropo Team'

#CC uses Basic Authentication for their API. This code sets up a password manager to take care of that for us
passman = urllib2.HTTPPasswordMgrWithDefaultRealm()
passman.add_password(None, cc_url, cc_api_key + '%' + cc_username, cc_password)
authhandler = urllib2.HTTPBasicAuthHandler(passman)
opener = urllib2.build_opener(authhandler) urllib2.install_opener(opener)

pagehandle = urllib2.urlopen(cc_url)
data = pagehandle.read()
dom = minidom.parseString(data)
entry_node = dom.getElementsByTagName("entry")
for entry in entry_node:
	id = entry.getElementsByTagName("id")
	id = id[0].firstChild.nodeValue
	pagehandle = urllib2.urlopen(cc_url + '/' + id.rsplit('/', 1)[1])
	data = pagehandle.read()
	dom = minidom.parseString(data)
	contact_node = dom.getElementsByTagName("Contact")
	for contact in contact_node:
		phone_num = contact.getElementsByTagName("HomePhone")
		phone_num = phone_num[0].firstChild.nodeValue
		url = TROPO_URL + '&numberToDial=' + phone_num + '&msg=' + urllib.quote(SMS_MSG)
		page = urllib2.urlopen(url)
		data = page.read()

Questions or comments? Post to our forums or send us an email to support@tropo.com.

Tags: constant contact, Python, SMS, third-party tools
Posted in Tropo | 2 Comments »

Node.JS Magic 8 Ball Voice App

December 23rd, 2011 by cmatthieu

spacer Remember the Magic 8 Ball game from yesteryear?

How would you like to have the game with you in your pocket when difficult answers are required.

I built this Magic 8 Ball game using Node.JS and the Tropo WebAPI. If you roll the array up to a single line of code, you’re only looking at a 25-line Node.JS application!

You can call this application at 415-889-8684!

Here is the Node.JS source code that runs the application.

var http = require('http');
var tropowebapi = require('tropo-webapi');

// en.wikipedia.org/wiki/Magic_8-ball
var answers = [
"It is certain&quo