Thursday, 15 January 2015

Simple Conferencing with Twilio, BlockSpring and AWS

Recently an entrepreneur friend of mine complained that plain teleconferencing services are expensive and in certain business situations, it is not possible to use social applications like Skype or Google Hangouts. To quantify it, he said an hour call between 4 people in the US and UK cost around ~ GBP 15 or around $23 at professional providers like GotoMeeting or Powwownow. Having known about Twilio and the power of Cloud, I felt this was not right and set about to write a simple conferencing facility POC for him which turned to be a huge cost saver. Interestingly a TollFree number costs about $2 per month and a local number about 1$, that comes to around 4$ per month recurring or admin cost as he decided to have a TollFree and Local number in the US and just a local number in the UK. A similar conference for 4 people now only costed $2.5 per hour and it was super efficient, also when we added a web based calling to it, the cost flattened around a dollar or less.

One of the salient features of the POC was that I decided not to build any backend application and use BlockSpring one of the recent discoveries for me to build a function that can allow to integrate Twilio. And use only Amazon AWS S3 to host a static web page which is a client-side Javascript application as the end point. This post simply details the steps and the code that was used to build the POC and make it open to anyone who would like to try on their own.

1. Create a static website using Amazon S3

You can refer to the official guide or follow this simple tutorial to create a static website on Amazon S3. Also you can setup a custom domain name like if that is something you'd prefer.

2. Register two applications with Twilio

Sign-up for a new account at Twilio if you already did not have one and do spend sometime looking at the self-explanatory guides and documentation which are very useful. For the conferencing app, we will create two application end-points, one to act as an administrator account which would begin and end the conference and the second one adds users as participants to the call.

NOTE: Please remember that we are using Amazon S3 to host our TwiML end-points, so the request URL must have the "HTTP GET" method, otherwise you'd have exceptions.

3. Add the following code end-points to S3 website

4. Create an account at BlockSpring

BlockSpring allows developers to create, run and share functions across multiple server side languages including PHP, Python, NodeJs, Ruby, R etc. Though the following function is open-source and can be called from your application, you will still need to register an account and get an API Key of your own to connect to the function. 

5. Use the Twilio Token Generator Function from BlockSpring

You can use my public open-source function hosted at "".

Since at the time of this writing, there is no integration between Github GIST and BlockSpring or way to embed a BlockSpring function, I have elaborated the source code of the Twilio.

6. Create the Javascript App and add it your S3 website

Please note that the account ID / Application ID in the following code are hard-coded to test accounts and will not work. You will need to use your own Twilio Account ID and Begin/Join App_ID when you upload this code.

7. Optionally associate calling numbers to the Twilio Function

If you also need to connect to the application from regular phone number, buy as many numbers as you want and point them to the "Simple Conference Join" TwiML function. The only caveat is that since we don't have any backend service of our own, you can create administrator functions on the phone and will have to use web site to begin the conference.

That's it; You now have a fully functioning conference at a very low cost.

Friday, 30 November 2012

Hard reverting a Maven release with Git

When trying to release a maven project, Git automatically tags your repository and then updates the project to a new version. However if there are any failures in between, the release cannot be fully undone and needs manual intervention to clean up the state.

The following code snippet shows how you can fully revert your project by removing both the tags and resetting the previous commit.

Thursday, 29 November 2012

New Age Architecture principles learnt from AWS re: Invent keynote

Was listening to the Keynote from Werner Vogels at AWS re: Invent and wanted to record all the concepts that he discussed. These are so valuable and applicable for large applications in today's environment and worth blogging about.



  • Decompose into small, loosely coupled, stateless building blocks 
  • Automate processes and services
  • Let business levers control the system
  • Architect with cost in mind

  • Protecting your customer is the first priority
  • In production, deploy to at least two availability zones
  • Integrate security into your application from the group up
  • Build, test, integrate and deploy continuously
  • Don't think in single failures
  • Don't treat failure as an exception
  • Entla non sunt multiplicanda praeter necessitiatem - dont make things more complicated than it should be 
  • Assume Nothing
  • Use late binding
Data Driven
  • Instrument everything, all the time
  • Inspect the whole distribution
  • Put everthing in logs

Some of the quotable quotes from the session include

"you are allowed to make mistakes"
"if you cannot collect data, you cannot act"
"whole distribution not average or median - inspect 99.9 percentile"
"Thou shalt turn off the lights"