From Wildsong
Jump to navigation Jump to search

Fun with Twilio

Implementing a Dispatch system for first responders using Twilio. Start of an idea.

Caller ID processing

Stuff I want to try.

Twilio Client

Voice transcription

Watson Conversation service


Using Twilio services

Programmable Voice

Geo-CEG - TwimlBin directs Geo-CEG calls to a SIP URI that goes into my Asterisk PBX via Elastic Trunk. Asterisk rings the phones.

Wildsong - Call forwarding via TwiML bin is covered here: Setting up call forwarding They also cover another service called Twilio Functions.

Currently that's all I do, forward calls from Twilio to my mobile.

Programmable SMS

This is a very simple way to allow you to receive SMS messages on any Twilio number. You just set it up to forward them to a mobile phone.

Put this in a TwiML bin and connect messaging to it to forward SMS.

<?xml version="1.0" encoding="UTF-8"?>
 <Message to="+1707yournumberhere">Template:From: Template:Body</Message>

Elastic Trunk + Asterisk

I ran this set up for about 5 years. See Asterisk for more info. Every few months something changed, and I had to debug and fix it. Stuff like firewall issues and changing ip addresses. Twilio was fine, it was all stuff on my end.

The price for a single Twilio phone number is $1/month and another $1/month if you want 911 support. The rate for calls (inbound or outbound) is less than a penny a minute.

Twilio for Geo-CEG

Geo-CEG is a small non-profit. The board members live all over the place.

I got a Twilio account through their program to support non-profits.

Currently I have a little IVR that just offers to send your call to either me or Christian (press '1' or '2')

I want the number to be able to forward calls to whoever is "on call", and to store voice mails when no one is available.

Programmable SMS

You can use the same number to send and receive SMS calls. I tested it using the sample code by putting the PHP on my own server and then pointing the SMS URL at my server. It works. That's how I can receive SMS messages. I have not tried sending an SMS yet, except that the PHP code sends a reply back.

I set up a script in my dev SSL server, sms.php.

I have written a Python Flask app to play with SMS more, see It uses both Programmable SMS and Programmable Voice.

Programmable Voice

See the same app mentioned above,

Take aways from Signal Conference 2015

Move stuff into Asterisk

Lots of stuff in Twilio space could be implemented in Asterisk space. But here at the end of 2016 I am now working on going the other direction. I have Asterisk working just fine but am thinking of dumping it in favor of OpenVBX.

My thought back then was that TWIML could be used to design IVR / autoattendant systems in Asterisk. Doing this could make it easy to implement a failover, primary would be Asterisk but if * is down then the same code would fire up and run in Twilio.

What Twilio is doing

What Twilio is doing is building a big company by (1) doing only the back end, no applications. They provide only APIs and you write your own applications. (2) Using cloud. Everything they do lives in Amazon. Based on that there must be some backend to connect to carriers that does not require anything but IP. :-) That is, they don't have big server rooms full of HT503's

They have that big giant corporation mentality. But they do make their services available to little fleas like us. I can buy one phone line for $1 a month.


Online resources

Twilio docs is of course the ultimate resource.

Twilio on Github


Twilio Best Practices, Tim Rogers, Packt Pubs 2014 Good book, but it's more than 10 minutes old. ;-) Twilio is changing fast. Everything I looked at still applies, but Twilio adds new features all the time.