Send an SMS with Twilio

You can now send text messages through Leanplum using your 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.

You'll need the following:

  1. A Twilio account.
  2. User phone numbers tracked as a Leanplum user attribute (must be in in E.164 format for Twilio's API to parse correctly). 

Once you have those, you can create a webhook in Leanplum's message composer.

Create the 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 webhook URL to Twilio's API endpoint. Be sure to set the URL to the correct Twilio API endpoint, with your Account SID and Auth Token included in the URL for authentication


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.


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

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.

It must be formatted 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.


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