Skip to main content

Twilio Component

Send SMS messages through Twilio

Component key: twilio

Description

Twilio is a platform that allows you to send SMS text messages. You can use the Twilio component to send messages to your end users or to your team.

Connections

Twilio API Key Connection

This component authenticates with Twilio using API key/secret pairs that can be generated from Twilio's app console. To create a Twilio API key and secret pair:

  • Go to the Twilio console
  • On the top-right of the screen click Account -> API Keys & Tokens
  • Select Create API Key
  • Give your key a name and select Standard for Key type
  • Take note of the API key's SID and Secret - you will enter those into Prismatic in a moment

Now, when you create an integration that uses Twilio, a "Twilio API Key Connection" will automatically be generated. Enter your API Key SID (starts with "SK..."), and its Secret. Go back to your Twilio console to find your Account SID (starts with "AC..."), and enter that as well.

InputNotesExample
Account SID
string
/ Required
accountSid
Your account SID (starts with AC)
ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
API Key SID
string
/ Required
apiKey
An API Key SID (starts with SK)
SKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
API Key Secret
string
/ Required
apiSecret
The API secret that was generated when an API key was created
 

Twilio Auth Token Connection

When you create a Twilio account, an Account String Identifier (Account SID) and Auth Token are generated. You can use the account SID and auth token to authenticate with Twilio and to send SMS messages.

Consider API Keys instead

For security reasons, we recommend using an API Key Connection instead. API keys can be revoked and auth tokens generated using API keys are short-lived.

InputNotesExample
Auth Token
string
/ Required
password
Can be found on https://console.twilio.com/
 
Account SID
string
/ Required
username
Your account SID (starts with AC)
ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Triggers

Webhook

Receive and validate webhook requests from Twilio for webhooks you configure. | key: webhook

You can configure a Twilio webhook to send information to a Prismatic webhook URL upon sending a text message.

The webhook configuration takes place when adding/updating contact phone numbers.

{
"payload": {
"headers": {
"accept": "*/*",
"Content-Type": "application/json; charset=UTF-8",
"User-Agent": "TwilioProxy/1.1",
"Host": "hooks.example.prismatic.io"
},
"body": {},
"rawBody": {
"data": {
"type": "Buffer",
"data": [
69,
120,
97,
109,
112,
108,
101
]
}
},
"queryParameters": null,
"webhookUrls": {
"Flow 1": "https://hooks.example.prismatic.io/trigger/EXAMPLEGbG93Q29uZmlnOmRlNmNmNDMyLTliNWMtN0005NDMxLTRmYzA4ZjViODgxOA=="
},
"webhookApiKeys": {
"Flow 1": [
"abc-123"
]
},
"customer": {
"externalId": "customer-example-external-id",
"name": "John Doe"
}
}
}

Actions

Get SMS

Get an SMS message | key: getSMS

InputNotes
Message SID
string
/ Required
sid
 
Connection
connection
/ Required
twilioConnection
 

{
"data": {
"accountSid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
"apiVersion": "2010-04-01",
"body": "body",
"dateCreated": "2010-04-01T00:00:00.000Z",
"dateSent": "2010-04-01T00:00:00.000Z",
"dateUpdated": "2010-04-01T00:00:00.000Z",
"direction": "outbound-api",
"errorCode": null,
"errorMessage": null,
"from": "+15017122661",
"messagingServiceSid": "MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
"numMedia": "0",
"numSegments": "1",
"price": null,
"priceUnit": null,
"sid": "SMXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
"status": "sent",
"subresourceUris": "",
"to": "+15558675310",
"uri": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Messages/SMXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.json"
}
}

List SMS messages

Lists SMS messages | key: listMessages

InputNotes
Connection
connection
/ Required
twilioConnection
 

Raw Request

Send raw HTTP request to Twilio | key: rawRequest

InputDefaultNotesExample
Data
string
data
The HTTP body payload to send to the URL.
{"exampleKey": "Example Data"}
Debug Request
boolean
debugRequest
false
Enabling this flag will log out the current request.
 
File Data
string
Key Value List
fileData
File Data to be sent as a multipart form upload.
[{key: "example.txt", value: "My File Contents"}]
File Data File Names
string
Key Value List
fileDataFileNames
File names to apply to the file data inputs. Keys must match the file data keys above.
 
Form Data
string
Key Value List
formData
The Form Data to be sent as a multipart form upload.
[{"key": "Example Key", "value": new Buffer("Hello World")}]
Header
string
Key Value List
headers
A list of headers to send with the request.
User-Agent: curl/7.64.1
Max Retry Count
string
maxRetries
0
The maximum number of retries to attempt.
 
Method
string
/ Required
method
The HTTP method to use.
 
Query Parameter
string
Key Value List
queryParams
A list of query parameters to send with the request. This is the portion at the end of the URL similar to ?key1=value1&key2=value2.
 
Response Type
string
/ Required
responseType
json
The type of data you expect in the response. You can request json, text, or binary data.
 
Retry On All Errors
boolean
retryAllErrors
false
If true, retries on all erroneous responses regardless of type.
 
Retry Delay (ms)
string
retryDelayMS
0
The delay in milliseconds between retries.
 
Timeout
string
timeout
The maximum time that a client will await a response to its request
2000
Connection
connection
/ Required
twilioConnection
 
 
 
URL
string
/ Required
url
Input the path only (/Accounts/$TWILIO_ACCOUNT_SID/Messages.json), The base URL is already included (https://api.twilio.com/2010-04-01). For example, to connect to https://api.twilio.com/2010-04-01/Accounts/$TWILIO_ACCOUNT_SID/Messages.json, only /Accounts/$TWILIO_ACCOUNT_SID/Messages.json is entered in this field.
/Accounts/$TWILIO_ACCOUNT_SID/Messages.json
Use Exponential Backoff
boolean
useExponentialBackoff
false
Specifies whether to use a pre-defined exponential backoff strategy for retries.
 

Send SMS

Send an SMS message | key: sendSMS

InputNotesExample
From
string
/ Required
from
The SMS sender's phone number.
5555551234
Message
string
/ Required
message
The message body of the SMS message.
Hello from Prismatic!
To
string
/ Required
to
The SMS recipient's phone number.
5551234567
Connection
connection
/ Required
twilioConnection
 
 

{
"data": {
"accountSid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
"apiVersion": "2010-04-01",
"body": "body",
"dateCreated": "2010-04-01T00:00:00.000Z",
"dateSent": "2010-04-01T00:00:00.000Z",
"dateUpdated": "2010-04-01T00:00:00.000Z",
"direction": "outbound-api",
"errorCode": null,
"errorMessage": null,
"from": "+15017122661",
"messagingServiceSid": "MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
"numMedia": "0",
"numSegments": "1",
"price": null,
"priceUnit": null,
"sid": "SMXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
"status": "sent",
"subresourceUris": "",
"to": "+15558675310",
"uri": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Messages/SMXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.json"
}
}