Twilio Node
The Twilio Node allows a workflow to send SMS messages using the configured Twilio account.
Node Properties
There are many configuration options to provide when setting up the Twilio Node, broken up into several sections …
Twilio Configuration
First, choose how to authenticate the request. There are three different options …
-
Choose a Service Credential …: This is the recommended method; however, this method is not available in Edge Workflows. When using this method, you must provide …
- Credential Name Template: A string template resolving to the name of one of your application’s Twilio Service Credentials.
-
Enter API Key …: Twilio recommends this method for third-party integrations, and it is also the method supported by Twilio Service Credentials. When selected, you must provide …
- Twilio Account SID: The unique ID associated with your Twilio account. This value always starts with “AC”.
- Twilio API Key SID: The SID of the API key to authenticate with. This value always starts with “SK”.
- Twilio API Key Secret: The secret value associated with the provided API Key SID.
-
Enter Auth Token …: When selected, you must provide …
- Twilio Account SID: The unique key associated with your Twilio account. This value always starts with “AC”.
- Twilio Auth Token: Your account’s secret auth token, which should be rotated regularly.
All of the account configuration inputs support string templates.
Message Configuration
Next, configure the content of the SMS message …
- Send From: Choose whether to send the message from one of your Twilio phone numbers or from an SID.
- From Template: Depending on the “Send From” choice, provide a string template that resolves to either a phone number or an SID in this field. This value must be associated with your Twilio account provided in the Twilio configuration.
- SMS Message Template: Provide the body of the message. This should resolve to a short, plain-text message.
- Media URL Template: Optionally, you may also provide a publicly available URL to a multimedia object to include as an attachment.
Either the SMS Message Template or the Media URL Template must be provided; you may also provide both.
Recipient Numbers
Provide at least one phone number to send your message to. Multiple recipients can receive the same message, and those recipients can be provided through a combination of the following methods …
- One number per line.
- Multiple numbers per line, separated by commas (
,
) or semicolons (;
). - A string template referencing a phone number, a string of comma- or semicolon-separated numbers, or an array of phone numbers on the payload.
For example, given the following payload …
{
"working": {
"numbers": [
"7894443333, 13214567890, +13026546544",
"+19795753838"
],
"extraNumber": "+18038274238"
}
}
… and a Twilio Node with “To Numbers” defined as follows …
+15135551212; +13753471111
{{working.extraNumber}}
{{working.numbers}}
… this would result in messages being sent to seven different recipients. (Each number is a separate send; the node does not create a group message for all recipients.)
Result
Optionally, provide a payload path where the result of the request can be placed on the current payload. If provided, the Twilio Node will place an array at this path, with one entry per recipient number.
Node Example
The following is an example of a payload after successfully sending a text to one recipient, with a result path of working.twilioResult
:
{
"working": {
"twilioResult": [
{
"success": true,
"number": "+2128675309"
}
]
}
}
Node Errors
The Twilio Node can fail to send for several reasons. For example, In the case of an error, the resulting array contains objects with an error
key and a message
key instead of the success
key.
For example, the following would be placed on the payload at a result path of working.twilioResult
when trying to send the message with a “From” number that is not associated with your account:
{
"working": {
"twilioResult": [
{
"error": true,
"message": "The From phone number +344423439583 is not a valid, SMS-capable inbound phone number or short code for your account.",
"number": "+2128675309"
}
]
}
}
And, the following would be placed at the path when trying to send to an invalid phone number:
{
"working": {
"twilioResult": [
{
"error": true,
"message": "Phone number invalid",
"number": "+344454238712"
}
]
}
}
Related Nodes
Was this page helpful?
Still looking for help? You can also search the Losant Forums or submit your question there.