In case you didn’t know, Tropo is a set simple and powerful APIs that allow you to build rich voice, IM and text applications in the cloud. It supports many programming languages, Python being among them, of course. Development will also be free, so go and get an account to start playing with it!
With Tropo you can develop applications in 2 ways: hosted scripting or web API. In case you are using the web API, the code runs on your server, so there should be no problem there. When using hosted scripting applications, however, we face limitations imposed by the runtime. The Python interpreter is actually Jython 2.5 and we need to be aware of that. One of the things I really miss is some module to encode / decode JSON.
But hey, didn’t we say we could import modules directly from the web in the previous post? Lets just leverage that and build a test application.
My test application will just reply with a random Chuch Norris quote by using the JSON API provided by The Internet Chuck Norris Database. The good thing about Tropo is that you only need to write your application once, but it’s multi-channel: you may connect to it using Jabber and you’ll get a text back, or you may call it using SIP or Skype, and you’ll listen to the quote using text to speech. Cool uh?!
Lets see the code:
Code should be simple and self-explanatory, leaving out the importing magic. The application is running, you may test it:
Skype Voice: +990009369996104671 SIP Voice: sip:email@example.com Jabber: firstname.lastname@example.org