Send an SMS with Twilio

You can now send text messages through Leanplum using a Twilio account. While we do not offer an integration with Twilio, you can use a Leanplum webhook to send text messages via the Twilio API.

Create a Webhook

To send SMS messages, you'll need to create a webhook message in Leanplum that POSTs data to Twilio's API, which will ask Twilio to deliver the text message to your users. 

To successfully send the webhook to Twilio, you'll need to configure the webhook with the following settings.

Set the URL to Twilio's API endpoint. Be sure to set the webhook URL to the correct Twilio API endpoint, with your Account SID and Auth Token included in the URL for authentication

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

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

Set the content type to x-www-form-urlencoded. This is requited by Twilio to receive the webhook successfully.

wh-contenttype.png 

Set the Twilio parameters as Data. Twilio requires the three following values to be sent in the request. Add these as Data attributes.

parameter definition
To

The 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).

From A 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.
Body The text of the message you want to send, limited to 1600 characters.

wh-data.png

Schedule the webhook. Finally, you need to schedule or set the trigger for the webhook. For a general overview, see Send a Webhook.


Was this article helpful?
Have more questions? Submit a request