Skip to main content
Kinetic Community

Twilio Source

Handles webhook calls to run Task Trees when an SMS to a phone number is received.

Creating a Source

First download the consumer file and place it into the WEB-INF/consumers directory of your Task application and then restart the web server.

To use the consumer, navigate to the Sources page (underneath the Admin tab) and click Add New Source. When creating a source, the type field essentially tells Kinetic Task which consumer file to use for that source.

twilio_source.png

Now that we have created a Twilio source we will be able to develop trees that refer to Twilio-specifc information like phone number and message data.

Configuring a Webhook

To have Twilio run our Task Trees we need to use webhooks. Webhooks can call the Task API whenever an SMS message is received.

Navigate to the Manage Numbers interface by clicking the Twilio Numbers link at the top of the page.

twilio_numbers.png

Then click the phone number link for the number you would like to configure (highlighted above).

number_url.png

The only thing we need to configure is the Request URL underneath the Messaging header. We need to set this field to the API route of the Task Tree we wish to run. The API routes use the following format.

https://mytaskserver.mycompany.com/kinetic-task/app/api/v1/run-tree/SOURCE/GROUP/TREE

Given the source "Twilio", the source group "Test", and the tree name "Message" we would use the following API route. 

https://mytaskServer.mycompany.com/kinetic-task/app/api/v1/run-tree/Twilio/Test/Message

Finally, complete configuration by clicking the Save button.

Source Data

predefined_values.png

When the Twilio webhook calls the Task API it passes along form parameters that are converted into a string of JSON data. In Task this is referred to as Source Data. The consumer then parses the source data and provides the menu of pre-defined values available within the Tree Builder. An example of the pre-defined values menu is shown on the right.

In the Pre-defined Values section below we describe each of the pre-defined values made available by the Twilio source.

The Example Source Data section gives an example of real source data that was posted to Kinetic Task from Twilio.

Pre-defined Values

Sms

Account Sid Id of the Twilio account
Body Content of the SMS message
From Sending phone number
From Zip Zip code of the sending number
From City City of the sending number 
From State State of the sending number
From Country Country of the sending number
Sms Status Status
To Recipient phone number
To Zip Zip code of the recipient number
To City City of the recipient number
To State State of the recipient number
To Country Country of the recipient number


Example Source Data

{
   "AccountSid":["abc123"],
   "MessageSid":["abc456"],
   "Body":["Test"],
   "ToZip":["55401"],
   "ToCity":["MINNEAPOLIS"],
   "FromState":["MN"],
   "ToState":["MN"],
   "SmsSid":["abc789"],
   "To":["+15555555555"],
   "ToCountry":["US"],
   "FromCountry":["US"],
   "SmsMessageSid":["abc101112"],
   "ApiVersion":["2010-04-01"],
   "FromCity":["MINNEAPOLIS"],
   "SmsStatus":["received"],
   "NumMedia":["0"],
   "From":["+15555555555"],
   "FromZip":["55421"]
}