> For the complete documentation index, see [llms.txt](https://docs.stackai.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.stackai.com/integrations/catalog/twilio.md).

# Twilio

Twilio is a cloud communications platform for sending SMS, WhatsApp messages, emails, and managing communications at scale.

## Connectors

Choose the connector that matches your authentication method. The options below use the names shown in StackAI.

| Connector | Authentication |
| --------- | -------------- |
| Twilio    | Auth Token     |

### Twilio

Connect to Twilio to send SMS, WhatsApp messages, and manage communications. Requires an Account SID and Auth Token from the Twilio Console.

#### Set up in Twilio

1. Prepare the Twilio account or service that the workflow will access. Grant access to the required resources and operations.
2. **Account SID:** Your Twilio Account SID from the Twilio Console.
3. **Auth Token:** Your Twilio Auth Token from the Twilio Console.

#### Set up in StackAI

1. Open **Settings → Connections**, add a connection, and select **Twilio**.
2. Enter the credentials and connection details in the fields below.
3. Save the connection and check its connection status. Select this saved connection when configuring an action or feature that uses it.

**Connection fields**

| StackAI field | Required | What to enter                                                                                          |
| ------------- | -------- | ------------------------------------------------------------------------------------------------------ |
| Account SID   | Yes      | Your Twilio Account SID from the Twilio Console. [Provider instructions](https://console.twilio.com/). |
| Auth Token    | Yes      | Your Twilio Auth Token from the Twilio Console. [Provider instructions](https://console.twilio.com/).  |

### Verify the connection

Check that the connection is healthy. Then run a read operation against a resource the connected account can access. A successful connection check confirms authentication; it does not guarantee permission for every action.

If access is denied, check the credential or OAuth permissions, the selected account or environment, and access to the specific resource. Update expired credentials or reconnect after permissions change.

## Use an action

1. Add the required **Twilio** action to the workflow.
2. Select a connection when the action requests one.
3. Complete the required fields. Use the reference picker when a value comes from another workflow step.
4. Run the workflow and inspect the action’s output. Check the result before using it in a later step.

## Actions

### Send SMS

Send an SMS message via Twilio

#### Inputs

| Field             | Type     | Required | Description                                                                                                                                 |
| ----------------- | -------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
| To Phone Number   | string   | Yes      | The destination phone number in E.164 format (e.g. +18575295760).                                                                           |
| From Phone Number | string   | Yes      | Your Twilio phone number in E.164 format (e.g. +17372324091).                                                                               |
| Message Body      | textarea | Yes      | The text content of the SMS message. On Twilio trial accounts, use a predefined template name instead (e.g. 'sms\_appointment\_reminders'). |

#### Outputs

| Field        | Type     | Description                                                    |
| ------------ | -------- | -------------------------------------------------------------- |
| Message SID  | string   | The unique identifier for the sent message.                    |
| Status       | string   | The status of the sent message (e.g. queued, sent, delivered). |
| Date Created | datetime | The date and time the message was created.                     |

### Send WhatsApp Message

Send a WhatsApp message via Twilio

#### Inputs

| Field             | Type     | Required | Description                                                                                                                                                                                                                                                       |
| ----------------- | -------- | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| To Phone Number   | string   | Yes      | The recipient phone number in E.164 format (e.g. +18575295760). The 'whatsapp:' prefix is added automatically.                                                                                                                                                    |
| From Phone Number | string   | Yes      | Your Twilio WhatsApp-enabled phone number in E.164 format (e.g. +17372324091). The 'whatsapp:' prefix is added automatically.                                                                                                                                     |
| Message           | textarea | Yes      | The message text to send. WhatsApp only accepts free-form text inside the 24-hour customer service window, which opens when the recipient last messaged you. Outside that window WhatsApp requires an approved template and rejects the message with error 63016. |

#### Outputs

| Field        | Type     | Description                                                    |
| ------------ | -------- | -------------------------------------------------------------- |
| Message SID  | string   | The unique identifier for the sent message.                    |
| Status       | string   | The status of the sent message (e.g. queued, sent, delivered). |
| Date Created | datetime | The date and time the message was created.                     |

### Send WhatsApp Template

Send a WhatsApp message from an approved content template via Twilio

#### Inputs

| Field             | Type     | Required | Description                                                                                                                                                                                                                                          |
| ----------------- | -------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| To Phone Number   | string   | Yes      | The recipient phone number in E.164 format (e.g. +18575295760). The 'whatsapp:' prefix is added automatically.                                                                                                                                       |
| From Phone Number | string   | Yes      | Your Twilio WhatsApp-enabled phone number in E.164 format (e.g. +17372324091). The 'whatsapp:' prefix is added automatically.                                                                                                                        |
| Content SID       | string   | Yes      | The SID of an approved content template (e.g. HXfe5ab5f00277942d4d4200328b4d403c). Create and submit templates for approval in the Twilio Content Template Builder.                                                                                  |
| Content Variables | textarea | No       | JSON object substituting the template's numbered placeholders (e.g. {"1": "John", "2": "tomorrow at 3pm"}). Keys must match the {{1}}, {{2}} variables in the template and values must be strings. Leave empty to use the template's default values. |

#### Outputs

| Field        | Type     | Description                                                    |
| ------------ | -------- | -------------------------------------------------------------- |
| Message SID  | string   | The unique identifier for the sent message.                    |
| Status       | string   | The status of the sent message (e.g. queued, sent, delivered). |
| Date Created | datetime | The date and time the message was created.                     |

### Get WhatsApp Conversation

Get the WhatsApp conversation history with a phone number via Twilio

#### Inputs

| Field                 | Type    | Required | Description                                                                                                                                                                                                                           |
| --------------------- | ------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Customer Phone Number | string  | Yes      | The other party's phone number in E.164 format (e.g. +18575295760). The 'whatsapp:' prefix is added automatically.                                                                                                                    |
| Your WhatsApp Number  | string  | No       | Optional. Only needed when your account owns several WhatsApp senders and you want just the thread on one of them, in E.164 format (e.g. +17372324091). Leave empty to return the conversation across every number on the connection. |
| Message Limit         | integer | No       | Maximum number of most-recent messages to return across both directions (default 20, max 1000). Default: 20.                                                                                                                          |

#### Outputs

| Field         | Type          | Description                                                                                               |
| ------------- | ------------- | --------------------------------------------------------------------------------------------------------- |
| Transcript    | textarea      | The conversation rendered oldest-first as 'Customer:' and 'Business:' lines, ready to drop into a prompt. |
| Messages      | object\_array | The conversation messages, oldest first.                                                                  |
| Message Count | number        | The number of messages returned.                                                                          |

### Get Message

Get details of a Twilio message by its SID

#### Inputs

| Field       | Type   | Required | Description                         |
| ----------- | ------ | -------- | ----------------------------------- |
| Message SID | string | Yes      | The SID of the message to retrieve. |

#### Outputs

| Field         | Type     | Description                                         |
| ------------- | -------- | --------------------------------------------------- |
| Message SID   | string   | The unique identifier for the message.              |
| To            | string   | The recipient phone number.                         |
| From          | string   | The sender phone number.                            |
| Body          | string   | The text content of the message.                    |
| Status        | string   | The delivery status of the message.                 |
| Direction     | string   | The direction of the message (inbound or outbound). |
| Date Created  | datetime | The date and time the message was created.          |
| Date Sent     | datetime | The date and time the message was sent.             |
| Price         | string   | The cost of the message.                            |
| Error Code    | number   | The error code if the message failed.               |
| Error Message | string   | The error message if the message failed.            |

### List Messages

List Twilio messages with optional filters

#### Inputs

| Field             | Type    | Required | Description                                                       |
| ----------------- | ------- | -------- | ----------------------------------------------------------------- |
| To Phone Number   | string  | No       | Filter messages sent to this phone number (E.164 format).         |
| From Phone Number | string  | No       | Filter messages sent from this phone number (E.164 format).       |
| Date Sent         | string  | No       | Filter messages sent on this date (YYYY-MM-DD format).            |
| Page Size         | integer | No       | Number of messages to return (max 1000, default 20). Default: 20. |

#### Outputs

| Field       | Type          | Description                                |
| ----------- | ------------- | ------------------------------------------ |
| Messages    | object\_array | The list of messages matching the filters. |
| Total Count | number        | The number of messages returned.           |

### Send Email

Send an email via Twilio Email API

#### Inputs

| Field      | Type     | Required | Description                                                                                                         |
| ---------- | -------- | -------- | ------------------------------------------------------------------------------------------------------------------- |
| From Email | string   | Yes      | The sender email address. On trial accounts use {AccountSID}@twilio.email.                                          |
| From Name  | string   | No       | The display name for the sender.                                                                                    |
| To Email   | string   | Yes      | The recipient email address.                                                                                        |
| To Name    | string   | No       | The display name for the recipient.                                                                                 |
| Subject    | string   | Yes      | The email subject line. On trial accounts use a pre-approved subject (e.g. 'Your Order Has Been Confirmed!').       |
| HTML Body  | textarea | Yes      | The HTML content of the email body. On trial accounts, the content must match a pre-approved Twilio email template. |

#### Outputs

| Field       | Type   | Description                                     |
| ----------- | ------ | ----------------------------------------------- |
| Status      | string | The status of the email send request.           |
| Status Code | number | The HTTP status code from the Twilio Email API. |

### Make Call

Make a phone call via Twilio

#### Inputs

| Field               | Type   | Required | Description                                                                                                                                                                   |
| ------------------- | ------ | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| To Phone Number     | string | Yes      | The phone number to call in E.164 format (e.g. +18575295760).                                                                                                                 |
| From Phone Number   | string | Yes      | Your Twilio phone number in E.164 format (e.g. +18662805386).                                                                                                                 |
| TwiML URL           | string | Yes      | URL that returns TwiML instructions for the call. On trial accounts use a Twilio template URL like '<https://webhooks.twilio.com/v1/Voice/Template/voice\\_auto\\_response>'. |
| Status Callback URL | string | No       | URL to receive call status updates via webhook.                                                                                                                               |

#### Outputs

| Field        | Type     | Description                                                 |
| ------------ | -------- | ----------------------------------------------------------- |
| Call SID     | string   | The unique identifier for the call.                         |
| Status       | string   | The status of the call (e.g. queued, ringing, in-progress). |
| To           | string   | The phone number being called.                              |
| From         | string   | The Twilio phone number that placed the call.               |
| Date Created | datetime | The date and time the call was created.                     |

## Triggers

A trigger starts a workflow when its configured event occurs. Configure the event and filters before enabling the trigger.

### On Incoming Message

Trigger a workflow every time an SMS or WhatsApp message is received on your Twilio phone number.

Paste this URL into your Twilio phone number's **Messaging Configuration** webhook: {{webhook\_url}} **Setup steps:** 1. Go to the [Twilio Console](https://console.twilio.com/us1/develop/phone-numbers/manage/incoming). 2. Select the phone number you want to use. 3. Scroll to **Messaging Configuration**. 4. Under **A message comes in**, select **Webhook**, paste the URL above, and choose **HTTP POST**. 5. Click **Save configuration**.

#### Event inputs

| Field           | Type     | Required | Description                                                 |
| --------------- | -------- | -------- | ----------------------------------------------------------- |
| Message SID     | string   | Yes      | The unique identifier of the incoming message.              |
| From            | string   | Yes      | The phone number that sent the message.                     |
| To              | string   | Yes      | The Twilio phone number that received the message.          |
| Message Body    | textarea | Yes      | The text content of the incoming message.                   |
| Number of Media | integer  | No       | The number of media attachments in the message. Default: 0. |
| Channel         | string   | Yes      | The messaging channel (sms or whatsapp). Default: sms.      |
| Profile Name    | string   | No       | The sender's WhatsApp profile name (WhatsApp only).         |

#### Outputs

| Field           | Type     | Description                                         |
| --------------- | -------- | --------------------------------------------------- |
| Message SID     | string   | The unique identifier of the incoming message.      |
| From            | string   | The phone number that sent the message.             |
| To              | string   | The Twilio phone number that received the message.  |
| Message Body    | textarea | The text content of the incoming message.           |
| Number of Media | number   | The number of media attachments in the message.     |
| Channel         | string   | The messaging channel (sms or whatsapp).            |
| Profile Name    | string   | The sender's WhatsApp profile name (WhatsApp only). |

### On SMS Message

Trigger a workflow every time an SMS message is received on your Twilio phone number.

Paste this URL into your Twilio phone number's **Messaging Configuration** webhook: {{webhook\_url}} **Setup steps:** 1. Go to the [Twilio Console](https://console.twilio.com/us1/develop/phone-numbers/manage/incoming). 2. Select the phone number you want to use. 3. Scroll to **Messaging Configuration**. 4. Under **A message comes in**, select **Webhook**, paste the URL above, and choose **HTTP POST**. 5. Click **Save configuration**.

#### Event inputs

| Field           | Type     | Required | Description                                                 |
| --------------- | -------- | -------- | ----------------------------------------------------------- |
| Message SID     | string   | Yes      | The unique identifier of the incoming message.              |
| From            | string   | Yes      | The phone number that sent the message.                     |
| To              | string   | Yes      | The Twilio phone number that received the message.          |
| Message Body    | textarea | Yes      | The text content of the incoming message.                   |
| Number of Media | integer  | No       | The number of media attachments in the message. Default: 0. |
| Channel         | string   | Yes      | The messaging channel (sms or whatsapp). Default: sms.      |
| Profile Name    | string   | No       | The sender's WhatsApp profile name (WhatsApp only).         |

#### Outputs

| Field           | Type     | Description                                         |
| --------------- | -------- | --------------------------------------------------- |
| Message SID     | string   | The unique identifier of the incoming message.      |
| From            | string   | The phone number that sent the message.             |
| To              | string   | The Twilio phone number that received the message.  |
| Message Body    | textarea | The text content of the incoming message.           |
| Number of Media | number   | The number of media attachments in the message.     |
| Channel         | string   | The messaging channel (sms or whatsapp).            |
| Profile Name    | string   | The sender's WhatsApp profile name (WhatsApp only). |

### On WhatsApp Message

Trigger a workflow every time a WhatsApp message is received on your Twilio phone number.

Paste this URL into your Twilio phone number's **Messaging Configuration** webhook: {{webhook\_url}} **Setup steps:** 1. Go to the [Twilio Console](https://console.twilio.com/us1/develop/phone-numbers/manage/incoming). 2. Select the phone number you want to use. 3. Scroll to **Messaging Configuration**. 4. Under **A message comes in**, select **Webhook**, paste the URL above, and choose **HTTP POST**. 5. Click **Save configuration**.

#### Event inputs

| Field           | Type     | Required | Description                                                 |
| --------------- | -------- | -------- | ----------------------------------------------------------- |
| Message SID     | string   | Yes      | The unique identifier of the incoming message.              |
| From            | string   | Yes      | The phone number that sent the message.                     |
| To              | string   | Yes      | The Twilio phone number that received the message.          |
| Message Body    | textarea | Yes      | The text content of the incoming message.                   |
| Number of Media | integer  | No       | The number of media attachments in the message. Default: 0. |
| Channel         | string   | Yes      | The messaging channel (sms or whatsapp). Default: sms.      |
| Profile Name    | string   | No       | The sender's WhatsApp profile name (WhatsApp only).         |

#### Outputs

| Field           | Type     | Description                                         |
| --------------- | -------- | --------------------------------------------------- |
| Message SID     | string   | The unique identifier of the incoming message.      |
| From            | string   | The phone number that sent the message.             |
| To              | string   | The Twilio phone number that received the message.  |
| Message Body    | textarea | The text content of the incoming message.           |
| Number of Media | number   | The number of media attachments in the message.     |
| Channel         | string   | The messaging channel (sms or whatsapp).            |
| Profile Name    | string   | The sender's WhatsApp profile name (WhatsApp only). |

## Important behavior

Actions that create, update, send, or delete data can change the connected service. Review their inputs before running them. A retry can repeat an operation; consider this when configuring retries for actions that change data.

The catalog lists the fields and capabilities available in the supplied provider definition. Availability can also depend on your deployment and organization’s Feature Access settings.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.stackai.com/integrations/catalog/twilio.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
