For this example, we’ll configure the Braze webhook channel to send SMS and MMS to your users, via Twilio’s message sending API. For your convenience, a Twilio webhook template is included on the dashboard.
The Webhook URL is provided by Twilio in your dashboard. This URL is unique to your Twilio account, since it contains your Twilio account ID (
In our Twilio example, the webhook URL is
https://api.twilio.com/2010-04-01/Accounts/TWILIO_ACCOUNT_SID/Messages.json. You can find this URL in the Getting Started section of the Twilio console.
The Twilio API expects the request body to be URL-encoded, so we have to start by changing the request type in the Braze webhook composer to
Raw Text. The required parameters for the body of the request are To, From and Body.
The screenshot below is an example of what your request might look like if you are sending an SMS to each user’s phone number, with the body “Hello from Braze!”.
- You’ll need to have valid phone numbers on each user profile in your target audience.
- In order to meet Twilio’s request format, use the
url_param_escapeLiquid filter on your message contents. This filter encodes a string so all the characters are allowed in an HTML request; for example, the plus character (
+) in the phone number
+12125551212is forbidden in URL-encoded data, and will be converted to
Request Headers and Method
Twilio requires two request headers, the request Content-Type and an HTTP Basic Authentication header. Add them to your webhook by clicking the gear icon on the right side of the webhook composer, then clicking Add New Pair twice.
|Header Name||Header Value|
Be sure to replace
TWILIO_AUTH_TOKEN with values from your Twilio dashboard. Lastly, Twilio’s API endpoint is expecting an HTTP POST request, so choose that option in the dropdown for HTTP Method.
Preview Your Request
Use the webhook composer to preview the request for a random user, or for a user with particular credentials, to ensure that the request is rendering properly.