Tropo Teams with Apigee on API Explorer

January 27th, 2012 by cmatthieu

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.

Tropo Drinkup San Francisco

January 25th, 2012 by cmoe

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

Tropo joins Startup World in 36 cities

January 23rd, 2012 by Diggz

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”.

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!

Meet Phono – Tropo’s Web Phone

January 23rd, 2012 by cmatthieu

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.

<html>
  <head>
    <script src="http://code.jquery.com/jquery-1.4.2.min.js"></script>
    <script src="http://s.phono.com/releases/0.3/jquery.phono.js"></script>
  </head>
  <body>
	<input id="phonenumber" type="text">
    <input id="call" type="button" disabled="true" value="Loading..." />
    <span id="status"></span>
    <script>
    $(document).ready(function(){
      var phono = $.phono({
        apiKey: "your secret key",
        onReady: function() {
          $("#call").attr("disabled", false).val("Call");
        }
      });

      $("#call").click(function() {
        $("#call").attr("disabled", true).val("Busy");
        phono.phone.dial("app:9996182316", {
		  	headers: [
			             {
			               name:"x-numbertodial",
			               value:$('#phonenumber').val()
			             }
			           ],
          onRing: function() {
            $("#status").html("Ringing");
          },
          onAnswer: function() {
            $("#status").html("Answered");
          },
          onHangup: function() {
            $("#call").attr("disabled", false).val("Call");
            $("#status").html("Hungup");
          }
        });
      });
    })
    </script>
  </body>
</html>

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 :)

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!

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.

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:

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 = 'http://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 = 'http://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.

Node.JS Magic 8 Ball Voice App

December 23rd, 2011 by cmatthieu

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');

// http://en.wikipedia.org/wiki/Magic_8-ball
var answers = [
"It is certain",
"It is decidedly so",
"Without a doubt",
"Yes – definitely",
"You may rely on it",
"As I see it, yes",
"Most likely",
"Outlook good",
"Signs point to yes",
"Yes",
"Reply hazy, try again",
"Ask again later",
"Better not tell you now",
"Cannot predict now",
"Concentrate and ask again",
"Don't count on it",
"My reply is no",
"My sources say no",
"Outlook not so good",
"Very doubtful"
];

http.createServer(function (req, res) {

	// Create a new instance of the TropoWebAPI object.
	var tropo = new tropowebapi.TropoWebAPI(); 	
	var answer = answers[Math.floor(Math.random()*answers.length)];

	tropo.say("Welcome to the tropo node J S magic 8 ball.");

	var say = new Say("Ask your question now after the beep.");
    var choices = new Choices(null, null, "#");

    // Action classes can be passed as parameters to TropoWebAPI class methods.
    // use the record method https://www.tropo.com/docs/webapi/record.htm
    tropo.record(3, false, null, choices, "audio/wav", 5, 60, null, null, "recording", null, say, 5, null, "http://example.com/tropo", null, null);

    tropo.say(answer);

	tropo.say("Please call back to play again!");

    res.writeHead(200, {'Content-Type': 'application/json'}); 
    res.end(tropowebapi.TropoJSON(tropo));

}).listen(13188);

Be careful what you ask for…

Dial and SMS your APIs with Tropo

December 22nd, 2011 by cmatthieu

The number of APIs available are increasing by the day and so is the popularity of Node.JS, the server-side event-driven javascript framework. This got me thinking… How cool would it be to be able to call or sms an API with your phone using Node.JS?

This is a pretty simple thing to do with Tropo and Nodester. Tropo has an NPM module available for adding Voice, SMS, and Instant Messaging to Node.JS applications and Nodester has REST APIs available to report on the status of the platform. 25 lines of Node.JS code later, we now have an Node.JS application using the Tropo API to dial and sms the API to retrieve the status of the platform.

Here’s the phone number: (480) 428-8723 to call or SMS.

Install the Tropo WebAPI and Mikeal Rogers’ Request NPM modules:

npm install tropo-webapi -g
npm install request -g

Run this code on localhost or deploy it to a Node.JS hosting service like Nodester.

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

http.createServer(function (req, res) {

	// Create a new instance of the TropoWebAPI object.
	var tropo = new tropowebapi.TropoWebAPI(); 	

	// Fetch Nodester status -> http://api.nodester.com/status
	// returns {"status":"up","appshosted":2878,"appsrunning":1759}
	request('http://api.nodester.com/status', function (error, response, body) {
	     if (!error && response.statusCode == 200) {

	       // console.log(body) // Print status
	       var statusreq = JSON.parse(body);

	       tropo.say('nodester is ' + statusreq["status"] + ' and hosting ' + statusreq["appshosted"] + ' applications with '+ statusreq["appsrunning"] + ' running at the moment ');

	       res.writeHead(200, {'Content-Type': 'application/json'}); 
           res.end(tropowebapi.TropoJSON(tropo));
	     }
	   })

}).listen(13151);

One of the really cool things about the Tropo API is that you can write your app one time and it automatically runs on multiple communications channels such as: Voice, SMS, and Instant Message.

Voice Texting With Tropo Speech & SMS Technology

December 21st, 2011 by cmatthieu

We all agree that texting while driving is very dangerous, right? Fred Wilson, VC and principal of Union Square Ventures thinks so too. He recently wrote a blog post that starts like this:

“As a parent of two young adult drivers and a third soon to hit the road, nothing scares me more than texting while driving.”

Fred continued his blog post envisioning a Voice Texting application as follows:

“Being an engineer at heart and by training, I’ve been looking for a solution to the problem. I know that the buzz of the phone and the unread/unresponded message is like a drug to many and that the best solution would be a “hands free” way to read and respond. And the bluetooth/hands free voice solution works so well on most cars and most phones now, so why can’t we do the same with texting?”

Having two kids of my own (1 already driving and 1 studying for a drivers permit) and having access to the Tropo API and platform, I felt compelled to build a quick Voice Texting application to share with Fred Wilson! Here is what Fred had to say upon me sharing it with him…

Here is how it works:

To send a text, call (415) 349-3120 and using Tropo speech recognition say the phone number that you would like to text and then speak your message. Tropo then transcribes the message and sends your text message to phone number you spoke without taking your eyes or hands off the road.

Disclaimer: We are not promoting texting while driving even with the proper tools that would keep your eyes on the road such as a bluetooth earpiece and autodial features.

The source code for this project is written in Ruby and open sourced on GitHub in case anyone would like to extend it or perhaps even create a new business around this idea and have a head start! Here’s a video of me demonstrating the technology in action:

Drive safely!

Tropo Customer Spotlight: Babelverse

December 20th, 2011 by cmoe

Babelverse founders Mayel de Borniol and Josef Dunne were working out of the Tropo HQ office in San Francisco when they received the call that they had been accepted to compete among 15 other startups in the Le Web 2011 Startup Competition.

With over 600 applicants and only two weeks to prepare for the competition in Paris, France, we were able to sit down with them over a few beers and discuss their game plan to win, their experience in the San Francisco and Silicon Valley for the first time, being a part of the  Start-Up Chile Program and how they used Tropo for Crisis Response to help victims of the Japan Earthquake in March 2011.

Our Babelverse boys won 3rd place in the Le Web 2011 Startup Competition and we couldn’t be more proud.  Clearly their motto of including alcoholic beverages to help their inspiration and creativity along with their faith in always somehow being in the right place at the right time helped them win in Paris.  Congratulations!