Twilio is powering the future of business communications, enabling developers to embed voice, VoIP, and messaging into applications. They virtualize all infrastructure needed in a cloud-based, global environment, exposing it through the Twilio communications API platform. Applications are simple to build and scalable. Enjoy flexibility with pay-as-you go pricing, and benefit from cloud reliability.
Twilio Voice enables your application to make and receive phone calls. Twilio SMS enables your application to send and receive text messages. Twilio Client allows you to make VoIP calls from any phone, tablet, or browser and supports WebRTC.
Google App Engine customers receive complimentary credit for SMS messages or inbound minutes when you upgrade.
Twilio is a pay-as-you-go service. There are no set-up fees and you can close your account at any time. You can find more details at Twilio Pricing.
The Twilio platform consists of the Twilio Markup Language (TwiML), a RESTful API and VoIP SDKs for web browsers, Android and iOS. Helper libraries are available in multiple languages. You can find the full list at Twilio Helper Libraries.
TwiML is a set of instructions that you can use to tell Twilio what to do when you receive an incoming call or SMS. When someone makes a call or sends an SMS to one of your Twilio numbers, Twilio will look up the URL associated with that phone number and make a request to that URL. Twilio will read TwiML instructions at that URL to determine what to do:
<Say>- text to speech
<Record>- record the call
<Play>- play a message for the caller
<Gather>- prompt the caller to press digits on their keypad
<Message>- send a message
Learn about the other verbs and capabilities from the Twilio Markup Language documentation.
The Twilio REST API allows you to query metadata about your account, phone numbers, calls, text messages, and recordings. You can also do some fancy things like initiate outbound calls and send text messages.
Because the API is based on REST principles, it's very easy to write and test applications. You can use your browser to access URLs, and you can use pretty much any HTTP client in any programming language to interact with the API. For more information, see the Twilio REST API.
Copying the sample code
A complete code sample showing integration with Twilio is available at GitHub. If you want to use this sample code, copy it to your local machine:
Receiving an incoming call
After you complete Setting up, create your first application:
Deploy your project to App Engine. After you deploy your project, you can send an HTTP
http://your-app-id.appspot.com/call/receive, which returns the following text:
<?xml version="1.0" encoding="UTF-8"?> <Response> <Say>Hello from Twilio!</Say> </Response>
Copy and paste the
http://your-app-id.appspot.com/call/receiveURL into the Voice URL box on the Numbers page of your Twilio Account.
Now call your Twilio number! You should hear a voice say "Hello from Twilio!" in response. When you call, Twilio will fetch your URL, and execute the XML instructions listed above. Then Twilio will hang up, because there are no more instructions.
Sending an SMS
toparameter to use a real phone number. The
tonumber can be any outgoing number, such as your mobile phone number.
Deploy the updated code, and then send the SMS by putting this URL into a web browser:
Receiving an SMS
Deploy your updated code to App Engine, and then send an SMS to your Twilio number. You should receive a greeting in response.
Learning More about Twilio
Now that you've used some basic features, learn about more features and some best practices for building secure and scalable applications: