Twilio integration

Using a Leanplum webhook, you can send text messages through the Twilio API.

Set up the Webhook with Twilio API

STEP 1. Set the Webhook URL to Twilio's API endpoint.

Be sure to set the webhook URL to the correct Twilio API endpoint, entering your Account SID and Auth Token in the URL as shown below. This is required for authentication to Twilio's service.

https://{AccountSID}:{AuthToken}@api.twilio.com/2010-04-01/Accounts/{AccountSID}/Messages

NOTE: For more, see Twilio's API docs on Sending Messages.

STEP 2. Set the content type in Leanplu to x-www-form-urlencoded.

This is required by Twilio to receive the webhook successfully.

704

STEP 3. Set the Twilio parameters in the Webhook data.

Twilio requires the following three parameters and values to be sent in the request. These will need to be added as Data attributes as shown in the picture below.

parameterdefinition
ToThe destination phone number. You should set each user's phone number as a user attribute in Leanplum, so you can use it to dynamically personalize each webhook with the correct phone number for that user.

Format it with a '+' and country code e.g., +16175551212 (E.164 format).
FromA Twilio phone number (in E.164 format) or alphanumeric sender ID enabled for the type of message you wish to send. Phone numbers or short codes purchased from Twilio work here. You cannot (for example) spoof messages from your own cell phone number.
BodyThe text of the message you want to send, limited to 1600 characters.
710

STEP 4. Set the delivery method of the webhook and start the message

For a general overview, see our Send a Webhook doc.