makes it easy for developers to add voice, SMS, and VoIP functionality
into web and native mobile apps.
Your app probably has one of these:
twilio gives it one of these:
With twilio you can:
- Build a group chat app - GroupMe
- End no-shows for doctor's appointments - Appointment Reminder
- Make voice calls to a customer from your browser - Zendesk
- Put everyone into a a group conference call
Talk is cheap!
(let's make some phones ring...)
(told you it was easy)
Doing is for DOers
- At twilio, we celebrate the DOers
- This workshop is for DOers
- Code > Slides
- Results > Theory
Sending text messages (SMS)
- Pair up
- Create Twilio account
- Choose your programming language
- Send SMS to each other's phones
- Send SMS to (202) 552-0409
Stuff you'll need to know:
- Twilio REST API
- Twilio Helper Libraries
The twilio REST API
- Make phone calls
- Send text messages
- Get usage records
- Buy phone numbers
- Everything twilio can do (just about)
- Full Docs
A cURL Request
$ curl -XPOST https://api.twilio.com/2010-04-01/Accounts/AC308ac9a994b1bd8b73ca0166442236c7/Calls.json \
-d "Url=http://demo.twilio.com/docs/voice.xml" \
-d "To=+14155551212" \
-d "From=+14158675309" \
Available Helper Libraries
If we have time, or after workshop
- Where to look when things break
Webhooks are user-defined callbacks that
allow event-driven interaction between two applications over HTTP.
- Assume a Service and a Consumer of that Service.
- The Consumer wants to be notified when Some Event happens inside the Service.
- The Consumer defines a URL to be requested by the Service over HTTP when Some Event happens.
twilio provides webhooks for voice calls and text messages
- You purchase a phone number from twilio
- For each phone number, you specify webhooks for incoming voice calls and text messages
- When twilio receives a phone call or SMS to your number, the URLs you specified are requested over HTTP
What does twilio tell you about incoming calls?
Your URL is sent POST or GET parameters that contain information like:
- The number calling/texting
- a unique ID for the call/text
- the body of a text message
- location information for the caller (if available)
How do you tell twilio how to handle incoming calls and texts?
Your webhook URL should return an XML document that contains instructions for how you want
to handle the call or text. The set of XML tags twilio
understands is called TwiML.
<?xml version="1.0" encoding="ISO-8859-1"?>
<Say voice="woman">Hello, world!</Say>
What can TwiML tell twilio to do?
A small sample...
||Say a string of text, using our built in text-to-speech engine
Gather input from the user via DTMF tones (generated by pressing buttons on a standard
Dial a specific number or VoIP client, connecting the caller with that number/client.
Send an SMS text message to the incoming caller/text-er or another number.
Things don't always work out like you planned
If there is an error in your TwiML or somewhere in telecom land,
check the logs.
There's usually detailed information there.
Kicking @$$ and Taking Orders
- Use Case: Pizza Orders via SMS
- Take (and acknowledge) order via SMS
- Display list of orders on a web page
- Send an SMS notification when a pizza order is on the way
Plan of Attack
- Buy a Twilio number (or use one you already have)
- Write a server which will handle an HTTP callback from Twilio
- Display a web page with all orders received
- Click an order to indicate it has been finished
- Use the Twilio REST API (via a helper library) to send an SMS to the orderer
- twilio wants to help you change communications forever
- Every application has an opportunity to communicate with users better
- Phone, voice, and SMS interactions can be every bit as valuable as interactions on a screen