Say you want to buy a virtual phone number, and you’d like to redirect calls to your mobile number. There could
be different reasons why you’d want to have another phone number, without having to carry a physical phone.
A typical case is when you submit your CV to websites. Instead of giving away your mobile number, you
could buy a number from Twilio, create a micro application hosted for free on
heroku, and let Twilio redirect those calls to your mobile number.
You talkin’ to ME ?!?
Twilio uses TWIML, a markup language that describes operations like DIAL or REJECT.
When somebody calls our virtual phone number, Twilio will make a POST request to our server. We return some TWIML
instructing Twilio to forward that call to our personal (mobile or landline) phone:
Note, this POST request is made by Twilio to our server. We need to configure our Twilio Account and
associate an URL with our virtual phone number.
The following action is executed when the phone hangs up, we just instruct Twilio to close the call:
We can use a database to log calls too, and it’s quite easy to setup with Datamapper and Sinatra.
Here’s a simple database model:
Twilio provides the details of who’s calling, from where and other useful infos. We can grab this informations
for each request, with a before filter in Sinatra:
It’s easy, really easy to setup a simple call forwarding service with Twilio. When we get tired of receiving calls
we can always disable the virtual phone number, hassle free.