Using Twilio with CodeIgniter– a model for rapid development

I’ve developed a CodeIgniter model (attached below) for rapid development of a Twilio-powered app. If you’re not familiar, Twilio lets you develop web apps that interface with telephony via an XML-based API.

This model only deals with incoming calls at the moment, but if I get some feedback (or need it for my own purposes), I’ll update it to initiate outgoing calls, voice->text, as well.

Here’s an example of usage:

$body = $this->twilio->say('Thanks for calling!', 'woman');
$gath = $this->twilio->say('Please enter your ID number then press pound');
$body .= $this->twilio->gather($gath, '/voice/process/idcheck/', 6);
$body .= $this->twilio->redirect('/voice/answer/noid/');
echo $this->twilio->build($body);

These 4 lines, generate the appropriate XML code to have a computerized woman’s voice say “Thanks for calling!”, then the script starts listening for touch-tone entry of a 6 digit number and says, in a male voice, “Please enter your ID number then press pound”. If a 6 digit number is entered, it POSTs it to /voice/process/idcheck/, if not, it redirects to /voice/answer/noid/

The model is available for download here.

Questions? Problems? I’m happy to help.

Want Hotchkiss Consulting to help develop your phone-based app?  We’d love to.

Leave a Reply

Powered by Olark