In my day-to-day work, I mostly deal with IaaS cloud, but recently thought of creating a very simple application in bluemix. The idea of the app came to my mind when visiting a local shopping store in my home town who was taking home-delivery orders on phone and wished if he had a way to receive, validate and acknowledge orders automatically using SMS.
When I came back home, I thought how difficult will be to create an app to meet the shop-keeper’s requirement, without over-engineering :-).
I have known about PaaS due to my work in the Infrastructure layer and thought of trying it out to create a basic framework of creating such an application. I’m sure there might be ready made apps available for the purpose, but I wanted to try creating one on my own just to get the experience.
All I want to do is to create an application that will receive an SMS, parse it and respond back to the sender.
This is what I did
1. Created a login in IBM Bluemix (www.bluemix.net)
2. After doing a bit of research, zeroed down to use Twilio (https://www.twilio.com) as the backend to handle SMS.
3. Signed up for a ‘free’ Twilio account – https://www.twilio.com/try-twilio
4. Created a very simple application using Twilio APIs to handle and respond to SMS. Very comprehensive and easy to use documentation by Twilio folks. Details on Twilio APIs can be found here – https://www.twilio.com/docs/api
“””Respond to incoming calls with a simple text message.”””
resp = twilio.twiml.Response()
resp.message(“Hello, This is Pradipta’s Twilio Acc”)
Complete code is available here -https://github.com/bpradipt/hello-python
5. Pushed the application code to bluemix
$ cf push twilio-sample -m 128M -b https://github.com/joshuamckenty/heroku-buildpack-python.git
requested state: started
usage: 128M x 1 instances
state since cpu memory disk
#0 running 2014-10-27 08:29:18 PM 0.0% 34.9M of 128M 95.3M of 1G
6. Configured the appropriate application url in the Twilio account configuration
And that’s all. For testing, I just sent an SMS to the Twilio number and it responded back to me with the message – “Hello, This is Pradipta’s Twilio Acc”
Very simple and straight forward. Adding logic to handle orders and acknowledging the same should be straight forward. Bluemix and Twilio makes the job a lot lot easier.
Btw, Twilio account dashboard provides logs for all the communication and is very good for debugging purposes