Archive for November, 2010

JavaScript Goes First Class With Tropo

Tuesday, November 30th, 2010

In the last couple of years, there have been some significant changes in the development landscape that have elevated the status of JavaScript.

Lots of hard-core developers and engineers used to look down their noses at JavaScript as something only front-end “designers” used to make web sites look pretty.

And while the advent of AJAX-driven web development and powerful frameworks like jQuery have eroded this sentiment somewhat, a few key tools have developed in the last couple of years that have really vaulted JavaScript into first class status in the development world:

  • CouchDB – the document-oriented database that uses JSON for document structure and JavaScript for map/reduce functions.
  • Node.js – a framework for the V8 JavaScript engine from Google that lets you write sophisticated, event-driven applications in JavaScript.

In addition, the Tropo platform lets you write powerful, multichannel communication applications in pure JavaScript. Here is an example of a very simple Tropo application in JavaScript:

say("Channels are like hugs, more are better.");

One line – that’s it!

This script can be hosted and run in the Tropo cloud (much like how Google AppEngine works) and provisioned across multiple communication channels – phone, SMS, IM and even Twitter.

You can serve this humble message up to inbound callers, or send it out over all of the channels mentioned previously by kicking off an outbound session. Your choice.

Tropo blows the old notions that you can’t build powerful applications with JavaScript and that building communication apps is hard right out of the water. But what’s even cooler are the synergies that are possible when you mix up all this JavaScript goodness.

For example you can also build Tropo apps with Node.js using our WebAPI platform. Just download our Node.js library from GitHub and use the examples included with it to get started.

In addition, Tropo plays very nicely with CouchDB and you can build some really sophisticated apps that combine Tropo, Node.js and everyone’s favorite document-oriented database. (Look for a future post to cover Node.js + CouchDB + Tropo apps in detail.)

So if you’re a JavaScript ninja, or just someone who has used it on past projects, the time has never been better to sink your teeth into some exciting new applications.

Sign up for your Tropo account today and celebrate JavaScript’s promotion to first class status!

Use Bespin to edit your Tropo applications!

Tuesday, November 30th, 2010

So part of our job here in Labs it to evaluate new tech, and while looking at some HTML5 editors we ran across Bespin, which is really pretty darn cool!   We quickly realized that you could then use this tool to edit your own hosted Tropo files, simply by adding the Mozilla bookmarklet to your browser!  It’s really a super simple to setup, all you need to do is drag this bookmarklet ( Bespin ) to your browser ( Only Chrome / Safari / Firefox need apply, sorry IE :P).

After doing so you can simply click Bookmarket, while on any page with a textfield, such as the application editor in your hosted account.  It may take a few seconds to redor, but you will get an icon, which once clicked will then turn this:

Into something like this... Aww, isn’t it pretty, look at the cute syntax highlighting :)

We are working to implement some HTML5 ‘Goodness’ into our new Application Manager, which is coming soon to a browser new you, so stay tuned. In case you want to see the whole process, start to finish, via a screencast, I have one below for your viewing pleasure!

Enjoy!

Regards,
John Dyer
Labs Engineer
Voxeo Labs

Using One Line of Python with Tropo to Send SMS Notifications

Tuesday, November 23rd, 2010
Burmese python 2

Flickr credit: tambako

All day yesterday, when people were calling my Toddler Amusement Line app to try it out, I was getting a SMS text message on my iPhone each time someone called the app – complete with their Caller ID…

AND ALL IT TOOK WAS *ONE* LINE OF CODE!

Building off my colleague Chris Matthieu’s great post, “Get Notified When Someone Mentions You On Twitter, I simply added this one line to the end of my Tropo app (broken onto two lines here for display purposes):

message("TAL call from:" + currentCall.callerID, 
   {"to":"tel:+14075551212", "network":"SMS"})

Obviously, that’s not my real cell phone number… but you get the idea. I’m using the “currentCall.callerID” session variable and just appending that after a little bit of text. (“TAL” was my acronym for “Toddler Amusement Line”.) Here’s what the full app looked like:

import time

for i in range(0,10):
    for text in ("hi", "hello", "how are you"):
        say (text)
        time.sleep(2)

say("Thank you. Goodbye.")

message("TAL call from:" + currentCall.callerID, 
   {"to":"tel:+14075551212", "network":"SMS"})

If you want to try it out yourself… just head on over to Tropo and set yourself up with a free developer account.

Something Fun and Quick To Make – the Toddler Amusement Line!

Monday, November 22nd, 2010
Toddler on a phone

Flickr credit: danyork

Noticing this weekend: a) how much our 18-month-old loves to play with the phone; and b) how limited her actual “conversation” is with anyone on the phone… I decided to have a wee bit of fun and make an app that would “talk back to her”. And thus was born the Toddler Amusement Line!

You call the number and it simply loops through saying a canned set of phrases (currently “hi”, “hello”, “how are you”) 10 times with a pause between each. You can try it yourself at:

+1-617-870-3360
Skype: +990009369991480349
SIP: sip:9991480349@sip.tropo.com

Here’s all it took in python on Tropo:

import time

for i in range(0,10):
    for text in ("hi", "hello", "how are you"):
        say (text)
        time.sleep(2)

say("Thank you. Goodbye.")

I start out setting up a loop to go through the inner for loop 10 times. Main reason to do this is so that I don’t create an infinite loop running on Tropo. If the caller hangs up before the app is done, the loop will just keep going and then end. If they stay on, they’ll just get the “Thank you. Goodbye.” message.[1]

The inner loop just cycles through a series of phrases, saying each one, waiting 2 seconds and then saying the next.

If you’d like to experiment with creating an app like this yourself, here’s all you have to do:

  1. Go over and login to Tropo (you can create a free developer account if you don’t already have one).
  2. Create a new application.
  3. Choose “Tropo Scripting” as the type.
  4. Give it a name.
  5. Click on “Hosted File” and choose “Create a new hosted file for this application”
  6. Give it a file name ending in “.py” (I used “tal.py”)
  7. Copy/paste the python code above into the “File Text” area. (Tip: when you move your mouse over the code, some icons will appear in the upper right corner of the block of code – the second icon will copy the code to your clipboard.)
  8. Click “Create File”.
  9. Click “Create Application”.
  10. Start calling!

That’s it… your app is now ready to be called via either Skype or SIP. If you want to add a regular old phone number to it, just click the “Add a new phone number” link and choose from one of the available area codes. (There is no cost for a US phone number – they are free to developers.)

Now, as an added bonus, you could use one of the various international voices available for the “say” command and change the sound of the outgoing text-to-speech. For example, here the app has been changed to be a British female voice:

import time

for i in range(0,10):
    for text in ("hi", "hello", "how are you"):
        say (text, {"voice":"kate"})
        time.sleep(2)

say("Thank you. Goodbye.")

You can see the full list of available male and female voices in the “say” command reference or read our two previous blog posts with more examples about the female and the male voices.

Have fun! And may it amuse your toddler… or anyone else who calls ;-)


[1] And if you do the math, the inner loop is probably 3 seconds for each text (1 second to say and 2 to wait). 3 pieces of text at 3 seconds each equals 9 seconds for the inner loop. Do that 10 times for a total of 90 seconds. I don’t know about your toddler, but mine has probably put (or thrown) the phone down well before 90 seconds and has moved on to something else :-)

Hacking Awesomeness in Baltimore

Sunday, November 21st, 2010

Tropo was in Charm City this weekend for the first Baltimore Hackathon, which took place at Beehive Baltimore – a co-working space in Baltimore’s Canton neighborhood.

This thoroughly awesome location was the appropriate setting for a get together of hardware and software hackers from around the Baltimore area to come together and bang out great ideas over the weekend.

As hackathons go, it was a really special event.

Not only was it the first hackathon in Baltimore, but it was somewhat unique in that it focused on both software development and hardware hacking as well. All of the developers in attendance were smart, passionate technologists; the location along Baltimore’s harbor was outstanding; the event was organized exceptionally well and ran smoothly; the food was great; even the beer was good.

Tropo was on hand as a sponsor of the event and also to lend a hand to developers that wanted to add phone, voice or SMS awesomeness to their apps. Tropo’s APIs were used in some really impressive projects during the event.

For example Brent Frederick of Baltimore built what he refers to as VoiceBump – an app that lets people call a phone number and create a blog post with Tropo’s recording and transcription services.

Another app – Call the Door by Mike Brenner – uses Tropo’s SMS service to unlock the door at the building where the event was held (locked doors can turn into something of a hindrance when your coding all night).

Tropo also provided a special award at the event – giving a prize to the devleoper of the app with the best use of our services. An update with the name of the winner (or winners) and a description of the project will be posted in the next day or two.

In the interim, here are some pictures from the event.

Update: all of the winners from the Baltimore Hackathon are now listed on the Startup Baltimore site. Congratulations to all the winners!

Baltimore Hackathon

Baltimore Hackathon

Baltimore Hackathon

Baltimore Hackathon

Simple POST and GET interface to Tropo SMS

Friday, November 19th, 2010

Tropo’s coding model is designed around conversations. Ask a question, get an answer, ask something else, get another answer. Through grammars and our ask() functions, we make it easy to rapidly build a powerful automated phone or text conversation.

But what if you don’t want a conversation? What if you just want to send a text message out, without writing any code. One simple GET request and you’re on your way. And if someone texts your app, you just want that text posted somewhere like a form field would be.

One common case that’s come up a few times is people wanting to build SMS applications that run on SalesForce’s Force.com cloud. The Force.com programming language has a limitation that it can accept form posts, but sending other sorts of complex data into it doesn’t work. For example, there’s no way to receive and parse the JSON data that our WebAPI can send.

I’ve written a small application that anyone can use to do just this. Just drop it into your Tropo application and you can easily send text messages out. by passing the variables “to” and “msg” in the query string. Add in your secret API token from your Tropo account, and sending out messages is easy.

http://api.tropo.com/1.0/sessions?action=create&token=TOKEN&to=NUMBER&msg=MESSAGE

If you prefer to use POST to send your messages, Tropo can do that, too. Just post an XML document to us using the same fields above. The details of the document format can be found toward the end of our session API documentation.

To post incoming messages to a server, all you need to do is change one line in the code to add the URL you want to post to. You can also add a username and password if the server requires authentication.

Incoming messages are posted as form fields to your url. The fields “to”, “from” and “msg” contain the number (or IM address!) the message was sent to, the number or address the message was from, and the contents of the message.

Because Tropo works across multiple services with the same API, you can send and receive instant messages, too. Just remember, in order to send a message on a network, you need to have that an account for that network set up on your Tropo account. In other words, to send or receive SMS, you need an SMS phone number. To send or receive over Jabber, you need to add a Jabber account to your Tropo app.

The code is up on our GitHub account, so go read the short usage guide and grab it and try it out. You can even run it straight from GitHub without copying it up to Tropo if you want. Just fork it, edit to add your URL, then grab the “raw” url for the file off GitHub and use that as your Tropo app URL.

Here’s a short screencast showing you how to fork the code into your own github account, change the URL, and then use GitHub to serve the code to Tropo.

Tropo DTMF to XMPP IM Relay

Friday, November 19th, 2010

Are you building real-time gaming applications that use the phone (Voice or DTMF touch-tone) and require immediate response to your application?  Ever wondered how to get input from a caller at the speed of light – rather than traditional AJAX API calls?

Tropo’s Scripting API allows you to do all sorts of interesting hacks to make this possible!  Earlier, Jason Geocke demonstrated how to do this using real-time TCP sockets in the following blog post: Using Persistent Sockets in Tropo Applications.  I recently had a customer asking about a similar request but using XMPP Instant Messaging to relay the DTMF touch-tones to any IM client.

I’m always up for a new challenge but was disappointed to find that this request wasn’t challenging at all.  Tropo is ideal for building multi-modal communications apps like this going from Voice to IM in the same application.

Here is a video that demonstrates how this works.

Here is the Tropo Scripting that I used to make this demo possible.

answer
sleep 2

keeprunning = true
while keeprunning

  ask "press a key or zero to end", {
    :choices => "[1 DIGITS]",
    :onChoice => lambda { |event|
    message event.value, {
      :to => "christoffe@jabber.org",
      :network => "JABBER"}
      if event.value == "0"
        keeprunning = false
      end
    }
  }

end

The only thing left to do is connect your IM bot to your Tropo application by simply creating one dynamically like cmtest@tropo.im.  See below:

That’s all she wrote :)

What is a SMS “short code”? How do you get one for your Tropo app?

Friday, November 19th, 2010
TheNewVote = pre-election polling based on parsing the area code / local exchanges from incoming text messages = clever.  Done by some ITP'ers - take it for a test drive!

Flickr credit: dpstyles

You know all those “contest” shows on TV where viewers can text in their vote for one of the contestants? Or have you seen signs or websites for services where you can text in some word or phrase to a number (like the image to the right)? Or have you used Twitter and posted a message via SMS?

In all those cases you are using what is called in the industry a “short code”. It’s a unique number typically 4-6 digits long that is tied directly to your application – and you can get one for any Tropo application you create.

When would you want to use a short code?

  • RECEIVING A LARGE VOLUME OF SMS MESSAGES – Short codes let you receive massive amounts of text messages in a short period of time… so if you are planning to use Tropo to power the next show to succeed “American Idol”, well, a short code is the best way to go.
  • SENDING A LARGE VOLUME OF SMS MESSAGES – Similarly, if you want to send a large number of text messages… say for an outbound notification service… a short code lets you send basically an unlimited number of messages, whereas regular SMS-enabled phone numbers do have rate restrictions placed on them by carriers.
  • YOU WANT AN EASY-TO-REMEMBER NUMBER – If you are mounting a campaign where you want to promote a text-based service to people, a short code will be a whole lot easier for people to remember than a regular 10-digit phone number.

Given Voxeo’s longstanding connections into the telecommunications infrastructure, we provision short codes today for Tropo applications. Given that there is a very limited supply of short codes, the SMS carriers make it rather complicated to get one, but we take away that pain and help make the application process simple for you.

Tropogethelp.jpgIf you think a short code makes sense for your application, contact us via email or raise an “Account Ticket” under the “Get Help” section of Tropo and we can start working with you on getting the process started. If you’re not sure, drop us a line and we can discuss what options might work best for you.

P.S. For those of you who want more details on SMS short codes, Wikipedia has a write-up with info about short codes in different countries.

Text2Play Makes ProgrammableWeb’s Mashup of the Day!

Thursday, November 18th, 2010

Congratulations to Aniss Bouraba for his Text2Play application making Programmable Web’s Mashup of the Day!  Text2Play is an example in how to use Comet to build a real time web application. With Text2Play you can control the YouTube player by Searching, Playing, or Pausing a video via SMS.

This application is simply amazing!  You can send a text message (SMS) to +1-347-318-0167 with one of the following paramaters and control the YouTube video playing in your browser!

  • Play: Plays the currently video.
  • Pause: Pauses the currently playing video.
  • Query: Specifies a full-text query string.

If you want to load another video please send your query as message and it will be shown in real time. Here is an example of what it looks like using SMS.

Aniss, You Rock!

Random Hacks of Kindness and International Open Data Hackathon

Wednesday, November 17th, 2010

Tropo is joining Google, Microsoft, Yahoo!, The World Bank and NASA at the Random Hacks of Kindness Hackathon (RHoK #2) on December 4-5 in San Francisco and Seattle!

Google, Microsoft, Yahoo, NASA, The World Bank

What is RHoK #2?

RHok #2 is global gathering of hackers in many locations around the world, coming together in real time for a marathon weekend of coding around problems relating to natural disaster risk and response.  The RHok #2 event will be happening worldwide on December 4th and 5th, 2010.

What is Random Hacks of Kindness?

Random Hacks of Kindness is the brainchild of a dedicated team from Google, Microsoft, Yahoo!, NASA and The World Bank.  The very first Crisis Camp bar camp was held in Washington, D.C. in June 2009. During one of the opening sessions of the camp an industry panel spoke, and clearly stated that some issues of global importance take precedence over competitive business concerns. That panel included representatives from Google, Yahoo! and Microsoft who agreed to work together to mobilize their developer communities to hack for humanity: to develop code that responds to global challenges and has a real impact in the field. NASA and The World Bank joined forces with Google, Yahoo! and Microsoft to make it happen.

What is the International Open Data Hackathon?

The International Open Data Hackathon is a gathering of citizens in cities around the world to write applications using open public data to show support for and encourage the adoption open data policies by the world’s local, regional and national governments.  The very first one is happening on December 4th so Saturday we’ll be pulling double hackathon duty!

Get Involved

Tropo has joined Geeks without Bounds to organize RHoK #2 and the International Open Data Hackathons in Seattle and San Francisco on December 4-5.  Registration is already open for these and other locations around the world.  Click here to sign up for RHoK #2. There will be free food, WiFi, ideas, prizes and fun.  It’s a great opportunity to use your coding skills to help solve some of the world’s most challenging problems so sign up and join us!