> ## Documentation Index
> Fetch the complete documentation index at: https://docs.jinba.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Twilio

> Send SMS, MMS, WhatsApp messages, and make voice calls via Twilio API

## Overview

Twilio tools enable sending and receiving messages and calls through Twilio's communication platform. Supports SMS, MMS with media, WhatsApp messaging, and voice calls.

## Key Features

### Outbound Communications

* `TWILIO_SEND_SMS`
  * Send SMS text messages to any phone number
* `TWILIO_SEND_WHATSAPP`
  * Send WhatsApp messages via Twilio API for WhatsApp Business

## Authentication

All tools require Twilio credentials:

* **Account SID**: Found in your [Twilio Console](https://console.twilio.com/)
* **Auth Token**: Found in your Twilio Console

You can provide credentials via:

1. Environment variables: `TWILIO_ACCOUNT_SID` and `TWILIO_AUTH_TOKEN`
2. Tool config parameters
3. JinbaFlow secrets manager

## Setup

### 1. Get Twilio Account

1. Sign up at [Twilio](https://www.twilio.com/try-twilio)
2. Verify your account and phone number
3. Copy your Account SID and Auth Token from the console

### 2. Get Phone Number

For first-time users, get a trial phone number by clicking [Get a Trial Number](https://www.twilio.com/console/phone-numbers/trial-number/modal?capability%5B%5D=sms) in the console. This number can send and receive SMS messages.

For WhatsApp, join the [Twilio Sandbox](https://console.twilio.com/us1/develop/sms/try-it-out/whatsapp-learn) for testing.

**Trial Account Limitations**:

* Only 1 phone number available
* Can only send to [verified phone numbers](https://console.twilio.com/us1/develop/phone-numbers/manage/verified)
  * **IMPORTANT**: Twilio virtual numbers (e.g., +18777804236) CANNOT be verified
  * You must verify YOUR OWN real phone number
* Maximum 50 messages per day
* All messages include a "Sent from your Twilio trial account" signature

## Examples

**Note**: The examples below are testable with trial accounts.

## Inbound (Webhook)

Twilio inbound delivery uses webhooks. Configure your Twilio number to call the inbound URL below.

* Inbound endpoint: `POST /api/v2/external/flows/:flowId/twilio-run`
* Twilio sends `application/x-www-form-urlencoded` by default
* JinbaFlow returns an empty TwiML response (`<Response></Response>`)

### Example 5: Receive SMS (Webhook)

```yaml theme={null}
- id: receive_sms
  tool: INPUT_TWILIO_SMS
  config:
    - name: validate_signature
      value: false
  input: []
```

### Example 1: Send SMS

```yaml theme={null}
- id: send_sms
  tool: TWILIO_SEND_SMS
  config:
    - name: account_sid
      value: "{{secrets.TWILIO.account_sid}}"
    - name: auth_token
      value: "{{secrets.TWILIO.auth_token}}"
  input:
    - name: to
      value: "+819012345678"
    - name: from
      value: "+15017122661"
    - name: body
      value: "Hello from JinbaFlow!"
```

### Example 3: Send WhatsApp Message

```yaml theme={null}
- id: send_whatsapp
  tool: TWILIO_SEND_WHATSAPP
  config:
    - name: account_sid
      value: "{{secrets.TWILIO.account_sid}}"
    - name: auth_token
      value: "{{secrets.TWILIO.auth_token}}"
  input:
    - name: to
      value: "+819012345678"
    - name: from
      value: "+14155238886"  # Twilio WhatsApp number
    - name: body
      value: "Hello via WhatsApp!"
```

## Phone Number Format

All phone numbers must be in **E.164 format**:

* Include country code with `+` prefix
* No spaces, dashes, or parentheses
* Examples:
  * US: `+15551234567`
  * Japan: `+819012345678`
  * UK: `+447911123456`

## Media Support (MMS/WhatsApp)

Supported media types:

* **Images**: JPEG, PNG, GIF
* **Videos**: MP4
* **Documents**: PDF

Maximum 10 media URLs per message.

## Resources

* [Twilio Documentation](https://www.twilio.com/docs)
* [Twilio Console](https://console.twilio.com/)
* [TwiML Voice Instructions](https://www.twilio.com/docs/voice/twiml)
* [WhatsApp Business API](https://www.twilio.com/docs/whatsapp)
