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.

No comments:

Post a Comment