Sep 3, 2010

Allegro Non Troppo - Using Tropo API in App Engine

I was looking for an SMS - Voice gateway for an application of mine and after thoughtfully looking into Clicatell - twilio etc. I opted for Voxeo's tropo.
Do not ask much for the reasons I am not ready for a war over which one is better or cheaper to use.
I just felt like that tropo's "develop free - pay as you go once in production" business model fits well with App Engine's model that is on the same line, same applies to application scaling which is analogous to App Engine's.

So I decided to give it a try and here are my preliminary assessment of the service:
Registration was a 30 seconds job, after which you can proceed and create an application.
Tropo is providing two different APIS a scripting API where you host your scripts in their servers and a WEB api.
Although I knew scripting would be much more easy I have chosen the WEB API for the flexibility it provides.
Setting up an application is also very easy you just provide URLS that will handle Json requests from tropo, then you get 2 keys (outbound tokens) one for voice and one for Messaging applications as well as as some telephone, sip, Inum and other numbers that you can use.
You can test those tokens right from that page if you click on those and select "launch" on the pop up, your server if set up properly will receive an HTTP GET on the URL you specified.
One note about the URLS initially i specified a URL of the form "http://www.myapp.appspot.com/trop/SMS/" it seems this form was not working then I tried something in the form "http://www.myapp.appspot.com/trop/SMS/foo.json" and it worked - but can't be sure if it is really so or I have missed something.
Now the part that puzzled me for half a day "how you initiate an action request from tropo ?" . i was very unlucky since I could not find a proper example or framework in python since this was only published just a few days ago and was not indexed by google yet, and I did not bother to ask on the tropo's forum because I was thinking I will sort it out my self in a matter of minutes. Well I did but it was a matter of many hours.
What was the problem i did'nt quite get the handshaking process and I thought I would initiate an action (i.e. sending an SMS) by sending to tropo the requesting json object, I did not even bother to check the online debugging utility as I thought this would work only for the scripting API. By the way, after i discovered it works for the web API as well, I find this a very good tool - you can find in a link at the bottom of any (?) tropo's page. Well to make a long story short you initiate a request by issuing a GET to tropo's API url then API replies with a Json post which initiates a session that is posted to your application's URL and you issue your action command by responding to this Post with a Json object.
By the time I was close enough to the solution I received and EMail from Adam Kalsey from Tropo (nice fellow who tries to be helpful all the time) who was checking how was I doing with the API, I mention something like "not much documentation for Python" and he replied right away pointing me to the framework ( http://github.com/tropo/tropo-webapi-python ). Well believe me it is a nice small MIT licenced framework by Dan York with tests and examples that will set you up and running in app engine in zero time. Pity I discovered it a little too late, but I can only blame me for that.

Lessons learned: after we deal with a problem for some time (how much ?) and before we start scratching our heads better reach out to the community, more probably than not somebody has been there before and is willing to give a hand. I know, I know I mention this same lesson some posts ago when I was dealing with panoramio API, lets hope this time I will really get my lesson.

So far so good with tropo's Web Api but, i have not done much development and testing yet. So stay tuned for more about tropo and app engine - python when i will have more to say about the service.

2 comments:

  1. Nice info. Looking forward to a follow review of how satisfied you are.

    ReplyDelete
  2. thanks for your post..nice info

    ReplyDelete