...
Anyone can create an account and provision phone numbers using the Twilio service. When someone calls or sends a text message to one of these numbers, Twilio uses a Web hook to call a RESTful Web service that the account owner has set up. The response from the service should be an XML file that tells Twilio what to do. The Twilio docs can be found here.
Events From Voice
Once you've signed up for a Twilio account, you can provision phone numbers and associate them with callback URLs, or Web hooks. When one of your phone numbers is called, the Twillio service will POST to the Web hook associated with that number. You can create and ESL to serve as the Webhook for the pico that is running responding to Twilio.
The Twilio Module
A Twilio Module has been built. This module makes working with Twilio simple.
The Twilio Library
One of the built-in libraries in Kynetx supports Twilio directly. This makes sending Twilio directives easier. As mentioned, you can control Twilio by sending back XML files the instruct the Twilio engine on what to do next. The Twilio XML format is called TwilML.
...
Any response from a gather action will have an event attribute called Digits that contains user input. The rule simply says it back to the caller, but you could store it in an entity variable for later use and, for example display it on a Web page for the monkey to see.
Call Event Parameters
Parameter | Description | Example Value |
---|---|---|
CallStatus | Status of the call. | ringing |
Called | The number called. | 8019917544 |
CalledCity | The city called. | MIDVALE |
CalledCountry | The country called. | UT |
CalledState | The state called. | US |
CalledZip | The zip code called. | 84058 |
Caller | The number of the caller. | 18019919911 |
CallerCity | The caller's city. | OGDEN |
CallerState | The caller's state. | UT |
CallerCountry | The caller's country. | US |
CallerZip | The caller's zip. | 84058 |
Direction | The call's direction. | inbound |
From | The caller's number | 18019919911 |
FromCity | The caller's city. | OGDEN |
FromCountry | The caller's country. | US |
FromState | The caller's state. | UT |
FromZip | The caller's zip. | 84754 |
To | The number called. | 8019917544 |
ToCity | The city called. | OGDEN |
ToCountry | The country called. | US |
ToState | The state called. | UT |
ToZip | The zip code called. | 84754 |
appid | The app id to which the event was raised | a1299x21 |
Anchor | ||||
---|---|---|---|---|
|
You can use the send_sms()
action to send an SMS message using Twilio. The action takes three parameters:
...
The ruleset loads the Twilio module using the keys you create in your Twilio account.
Receiving SMS Events
Using Twilio to add SMS message capabilities to your rule set is simple. Every Twilio number has an associated Web hook for voice calls and one for SMS messages. If you've configured Twilio with an SMS webhook that is an ESL, rulesets installed in that pico will receive events from Twilio when your account receives an SMS.
...