---
canonical: https://amplience.com/developers/docs/integrations/webhooks/twilio/
title: Twilio integration
description: Twilio integration example, for setting up customizable webhooks to provide text message updates to your mobile phone device when content is created, published or updated in Dynamic Content.
image: https://cdn.media.amplience.net/i/ampproduct/Twilio_dashboard?w=1200&h=630
image_width: 1200
image_height: 630
audience: Developer
date_published: 2024-01-30
date_modified: 2024-01-30
---

# Twilio integration

On this page we'll walk you through an example of setting up customizable webhooks to connect Dynamic Content with [Twilio](https://console.twilio.com/). When the user publishes a content item in Dynamic Content, a text message will be sent to the user's mobile phone.

This example demonstrates:

- Setting up your Twilio account, ID and phone number.
- Creating a webhook in Dynamic Content that allows data to be sent to your personal phone number via text message upon specified triggers - ie. Newly published content.
- Using the custom payloads feature to send the data in the format defined by Twilio.

We'll walk you through setting up and testing out this example integration step by step.

## Pre-requisites

- A usable phone number
- A Dynamic Content account with the developer role assigned for the hub in which you want to create webhooks

## Before you begin: configure a Twilio account

Create an account in Twilio. When you log in to your new account, you will be asked to verify a phone number to receive SMS tests.

![Creating a Twilio account](https://cdn.media.amplience.net/i/ampproduct/Twilio_dashboard?w=1880&fmt=png 'Creating a Twilio account')

Once you have verified your phone number, an account SID, auth token and SMS number will be created for you from the Twilio dashboard. Make sure you make note of these credentials as you will need them to build your webhook later.

![Getting your Twilio credentials](https://cdn.media.amplience.net/i/ampproduct/twilio_dashboard_1?w=1880&fmt=png 'Getting your Twilio credentials')

## Step 1: Create a webhook

From Dynamic Content, choose "Webhooks" from the Development menu, then click the "Add webhook" button. Give the webhook a label and paste the webhook URL below into the URL field.

```
https://api.twilio.com/2010-04-01/Accounts/{twilio_account_sid}/Messages.json
```

> **Note:** Make sure to replace `twilio_account_sid` with your Twilio account SID.

## Step 2: Select a trigger and add headers

Select a trigger in the webhook triggers grid, which details the action that will trigger a text message to be sent to your personal mobile device. For example, in the screenshot below, we have ensured that we will receive a message whenever a snapshot is published in Dynamic Content.

![Select your webhook triggers](https://cdn.media.amplience.net/i/ampproduct/webhook_triggers_1?w=1880&fmt=png 'Select your webhook triggers')

In the headers section, click `add a basic auth header`, and enter your details for your Twilio account as follows then click OK:

- Username: `twilio_account_sid`
- Password: `twilio_auth_token`

Now add a new standard header. This will be a content-type header to override our standard content-type header. Enter the label and value credentials as follows then click OK:

- Key: `Content-Type`
- Value: `application/x-www-form-urlencoded`

![Add your webhook headers](https://cdn.media.amplience.net/i/ampproduct/webhook_headers?w=1880&fmt=png 'Add your webhook headers')

## Step 3: Create a custom payload

In this example, we are creating a custom payload for when a content item is published. So we paste the below code snippet into the payload area, ensuring we have selected `custom`.

`From=+{your_twilio_number}&To=+{your_verified_number}&Body=Content%20Item%20Published:%20{{encodeURI payload.rootContentItem.label}}`

Replace `your_twilio_number` with the phone number from the Twilio dashboard and replace `your_verified_number` with the phone number where you will receive SMS messages.

An example of how the code snippet will look with these elements filled out is shown below, using example contact numbers:

`From=+12568576388&To=+447989798798&Body=Content%20Item%20Published:%20{{encodeURI payload.rootContentItem.label}}`

## Step 4: View the results on your phone

Now that our webhook has been created, we can test it by creating and publishing a new content item in our hub in Dynamic Content. As shown in the screenshot below, as soon as our content is published, we get an SMS message on our phone explaining that a new content item has been published.

![We have received our SMS message from Twilio](https://cdn.media.amplience.net/i/ampproduct/twilio_message_2?w=1880&fmt=png 'We have received our SMS message from Twilio')

## Step 5: View the webhook activity log

You can use the webhook activity log to verify the status of your webhook. To do this, choose "Webhooks" from the Development menu and double click your Twilio webhook to open it. Click the "Activity log" tab and in the "Recent deliveries" section you should see a new entry showing that the webhook has been successfully triggered.

Click "View details" to view the request and response.

In the webhook details, the status is `201 Created`, indicating that the webhook was received and processed.

![The webhook activity log shows our webhook was received and processed](https://cdn.media.amplience.net/i/ampproduct/webhook_activity_log_1?w=1880&fmt=png 'The webhook activity log shows our webhook was received and processed')

## Related pages

[Webhooks overview](https://amplience.com/developers/docs/integrations/webhooks)

[Customizable webhooks](https://amplience.com/developers/docs/integrations/webhooks/customize)

[Webhook payloads](https://amplience.com/developers/docs/integrations/webhooks/payloads)
