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

# Twilio

### What is Twilio?

Twilio integration allows you to connect BotPenguin with Twilio's powerful voice and SMS communication platform. It enables data exchange between systems, allowing you to make and receive phone calls, send SMS messages, and automate customer communication workflows seamlessly. With Twilio, you can leverage SIP trunking for reliable voice connectivity and manage your phone numbers and billing all from one platform.

***

### When should you use this?

Use this integration when:

* You want to connect BotPenguin with Twilio's voice communication services
* You need to enable outbound and inbound calling capabilities for your agents
* You are trying to automate voice-based customer interactions and workflows
* You need to manage multiple phone numbers across different regions
* You want to handle compliance requirements for phone numbers in specific countries

***

### Benefits of Twilio Integration

* 🔗 Enables seamless voice and SMS communication between BotPenguin and Twilio
* ⚡ Automates outbound and inbound call workflows with SIP trunking
* 🎯 Improves customer engagement through reliable voice connectivity
* 🔄 Ensures real-time call routing and configuration management
* 📈 Reduces communication setup complexity with integrated number management

***

### Expected Outcome

After setting this up:

* Your Twilio account will be successfully connected to BotPenguin
* Data will flow between BotPenguin ↔ Twilio
* You will be able to make and receive calls through your Twilio phone number
* Your agents will have access to both inbound and outbound calling capabilities

{% hint style="info" icon="lightbulb" %}
**Tip**: Test the integration with sample calls (both inbound and outbound) after setup to ensure everything is working correctly.
{% endhint %}

***

### 🔐 Prerequisites

Before setting up this integration, ensure you have:

* An active Twilio account (sign up at <https://www.twilio.com/>)
* Completed the Twilio verification process with your account
* Purchased at least one phone number from Twilio
* Admin or Owner access to your Twilio account
* Billing information added to your Twilio account (payment method on file)
* Compliance verification completed for your country (required for phone numbers)

{% hint style="warning" icon="triangle-exclamation" %}
Missing prerequisites may result in failed connections or limited functionality. Compliance requirements vary by country—ensure you have met your region's requirements before purchasing a number.
{% endhint %}

***

### How to Use Twilio Integration

#### Phase 1: Set Up Your Twilio Account

1. Visit the Twilio website at <https://www.twilio.com/> and sign up for a free Twilio account.
2. Complete the Twilio verification process to set up your account with your country information and required documentation.
3. Once verified, log into the Twilio Console at <https://console.twilio.com>.

<figure><img src="/files/2knYkVqD7nBgabZOY4if" alt=""><figcaption></figcaption></figure>

***

#### Phase 2: Purchase a Phone Number

1. From your Twilio Console home page, navigate to **"Phone Numbers"** in the left sidebar.
2. Click on **"Buy a Number"** button to purchase a new phone number.

<figure><img src="/files/WrP7p0mmLG9goE5XCe6m" alt=""><figcaption></figcaption></figure>

3. Filter the available numbers by:
   1. **Country:** Select the country where you want the number
   2. **Capabilities:** Select **"Voice"**

<figure><img src="/files/jcMZNyKWhYiccTCWfnSg" alt=""><figcaption></figcaption></figure>

4. Select the phone number you want to purchase and click **"Buy"**.

<figure><img src="/files/hJAGosSyrPtQTe2hHQnx" alt=""><figcaption></figcaption></figure>

5. Configure the purchased number:
   1. Set a **Friendly Name** (internal name for your reference)
   2. Review the number configuration
   3. Click **"Buy this Number"** to complete the purchase

{% hint style="warning" icon="triangle-exclamation" %}
**Important**: Compliance requirements vary by country. During account setup, your country information and documents will be verified for compliance purposes. If your account is not yet compliant in a specific region, you may need to create a new account or contact Twilio support.
{% endhint %}

***

#### Phase 3: Create an Elastic SIP Trunk

1. In the Twilio Console, navigate to **"Elastic SIP Trunking"** → **"Manage"** → **"Trunks"**.
2. Click **"Create new SIP Trunk"** and give it a friendly name (e.g., **"BotPenguin Trunk"** or **"LiveKit Trunk"**)
3. Click **"Create"** to create your new trunk. You will now configure both Origination (inbound) and Termination (outbound) on this single trunk.

***

#### Phase 4: Configure Origination (Inbound Calls)

Origination is how Twilio forwards incoming calls to your BotPenguin agent.

1. Inside your trunk, go to the **"Origination"** tab.
2. Click **"Add New Origination URI"** and enter the following as the SIP URI:

```
   sip:499djd4dwq0.sip.livekit.cloud;transport=tcp
```

{% hint style="warning" %}
**Important**: Include the `sip:` prefix and the `;transport=tcp` suffix. Without these, the trunk will not connect properly.
{% endhint %}

3. Set the following values:
   1. **Priority:** 1
   2. **Weight:** 1
   3. **Enabled:** Make sure this is checked
4. Click **"Save"**.

**Attach Your Phone Number to the Trunk**

5. Inside your trunk, go to the **"Numbers"** tab.
6. Click **"Add an Existing Number"** and select your Twilio phone number from the dropdown.
7. Click **"Save"**.

***

#### Phase 5: Configure Termination (Outbound Calls)

Termination is how your BotPenguin agent sends outbound calls through Twilio. The values configured here will be used in the installation form.

1. Inside your trunk, go to the **"Termination"** tab.
2. Set a **Termination SIP URI**. Pick any unique subdomain, for example:

```
   yourname.pstn.twilio.com
```

{% hint style="info" %}
**Tip**: Replace "yourname" with something unique to your organization. This full URI (without the `sip:` prefix) is what you will paste into the Termination URI field in BotPenguin.
{% endhint %}

3. Click **"Save"**.
4. Under **"Authentication"** → **"Credential Lists"**, click the **"+"** icon to create a new credential list.
5. Create a **Username** and a strong **Password** inside that credential list.

{% hint style="info" icon="triangle-exclamation" %}
**Critical**: Write down the username and password now — you will paste both into the BotPenguin installation form. Twilio will not show the password again.
{% endhint %}

6. Click **"Save"** to create the credential list.
7. Back on the trunk Termination tab, make sure the credential list you just created is attached under **"Termination"** → **"Authentication"** → **"Credential Lists"**.
8. Click **"Save"** to finalize your Termination configuration.

***

#### Phase 6: Fill in the "Install Myself" Form

Now that your Elastic SIP Trunk is configured in Twilio, you'll connect it to BotPenguin using the installation form.

1. Go to the **"Integrations"** section in BotPenguin from the left sidebar.
2. Locate **"Twilio"** and click **"Connect"**.
3. Expand the **"Install Myself"** panel to access the installation form.
4. Fill in the form fields with the following information:

| Form Field             | What to Enter                                                    | Where to Get It                                                   |
| ---------------------- | ---------------------------------------------------------------- | ----------------------------------------------------------------- |
| **Country Code**       | Country code of your Twilio number (e.g., +1, +44)               | Select from dropdown before Phone Number                          |
| **Phone Number**       | Your Twilio phone number without country code                    | Twilio → Phone Numbers → Manage → Active Numbers                  |
| **Termination URI**    | Your Twilio Termination SIP URI (e.g., yourname.pstn.twilio.com) | Twilio → Elastic SIP Trunking → Trunks → your trunk → Termination |
| **Username**           | The username from your Credential List                           | Twilio → Elastic SIP Trunking → Credential Lists                  |
| **Password**           | The password from your Credential List                           | Twilio → Elastic SIP Trunking → Credential Lists                  |
| **Outbound Transport** | TCP                                                              | Select from dropdown (default)                                    |

5. Click **"Configure"** to complete the installation. Installation can take up to 30 seconds.

> 💡 Tip: Keep your Twilio console open during this process to reference the correct values from your trunk and credential list configuration.

***

#### Phase 8: Test the Twilio Setup

After configuration completes, test both inbound and outbound calls to ensure everything is working correctly.

**Inbound Call Test**

1. From any phone, call your Twilio phone number.
2. Your BotPenguin agent should answer the call.

{% hint style="success" %}
**Success**: If your agent answers, inbound calling is working correctly.
{% endhint %}

**Outbound Call Test**

1. In the BotPenguin agent dashboard, trigger an outbound call to your phone number.
2. Your phone should ring and you should be able to hear the agent speak.

{% hint style="success" %}
**Success**: If you receive the call and hear the agent, outbound calling is working correctly.
{% endhint %}

**If Something Fails**

1. Check Twilio's call logs under **Monitor** → **Logs** → **Calls** for error details.
2. Check BotPenguin call logs for any connection errors
3. Verify that:
   1. Your Termination SIP URI is correctly formatted (e.g., yourname.pstn.twilio.com)
   2. Your username and password match your credential list exactly
   3. Your phone number is attached to the correct Origination URI
   4. All credentials are correctly entered in the BotPenguin form

> 💡 Common Issue: Make sure you entered the Termination URI **without** the `sip:` prefix. The form should receive only the domain (e.g., yourname.pstn.twilio.com)

***

### Best Practices

> 💡 Always test the integration with both inbound and outbound test calls before deploying to production.

> ⚠️ Store your SIP credentials and Auth Token securely and never share them in plain text communications.

> 🚀 Use clear, descriptive names for your inbound and outbound trunks to avoid confusion during troubleshooting.

> 🎯 Monitor Twilio logs regularly to identify and resolve connectivity or configuration issues early.

> 📋 Keep your billing information current and monitor your account balance to ensure uninterrupted service.

> 🔄 Ensure compliance documentation is kept up-to-date, as requirements may change by region.

***

### Troubleshooting

<details>

<summary><strong>Issue: Calls not connecting - "Connection Failed" error</strong></summary>

**Solution:**\
Verify all form fields are entered correctly. Check that your **Termination URI** is formatted correctly (for example, `yourname.pstn.twilio.com`) without the `sip:` prefix. Ensure your username and password match exactly what's in your Elastic SIP Trunk Credential List. Check Twilio logs under **Monitor → Logs → Calls** for error details.

</details>

<details>

<summary><strong>Issue: Inbound calls not reaching the agent</strong></summary>

**Solution:**\
In your Twilio Elastic SIP Trunk, verify that the **Origination URI** is exactly:

```
sip:499djd4dwq0.sip.livekit.cloud;transport=tcp
```

</details>

***

### FAQ's

<details>

<summary>What is Elastic SIP Trunking?</summary>

Elastic SIP Trunking is Twilio's SIP trunking solution that allows you to connect your applications directly to Twilio's voice infrastructure. It provides both inbound (Origination) and outbound (Termination) call handling through a single trunk configuration.

</details>

<details>

<summary>Why do I need to create both Origination and Termination configurations?</summary>

Origination handles how Twilio forwards incoming calls to your BotPenguin agent. Termination handles how your agent sends outbound calls through Twilio. Both must be configured for complete two-way calling functionality.

</details>

<details>

<summary>What is the Origination URI and why is the <code>transport=tcp</code> suffix required?</summary>

The Origination URI is the endpoint where Twilio sends incoming calls. The `transport=tcp` suffix ensures secure, reliable delivery of SIP signaling. Without it, the connection will fail.

</details>

<details>

<summary>Can I change my Termination URI after setup?</summary>

Yes, you can modify your Termination URI in the Twilio Elastic SIP Trunking trunk configuration. However, you'll need to update the corresponding value in BotPenguin and reconfigure the integration.

</details>

<details>

<summary>What happens if I forget my SIP credentials password?</summary>

If you forget your SIP credentials password, create a new Credential List in Twilio's Elastic SIP Trunking section. Remove the old credentials from the Termination configuration, attach the new Credential List, and update the password in BotPenguin.

</details>

<details>

<summary>Can I use the same Elastic SIP Trunk for multiple phone numbers?</summary>

Yes, you can attach multiple phone numbers to the same Elastic SIP Trunk. All numbers will use the same Origination and Termination configurations.

</details>

<details>

<summary>What should I do if inbound calls work but outbound calls don't?</summary>

Outbound calls use your Termination configuration. Verify that your Termination URI is correctly formatted (without the `sip:` prefix), your Credential List is attached to the **Termination** tab, and your username and password are correct. Check Twilio's **Monitor → Logs → Calls** for authentication errors.

</details>

<details>

<summary>Is the Origination URI the same for all BotPenguin integrations?</summary>

Yes. The Origination URI below is the same for all Twilio Elastic SIP Trunking integrations with BotPenguin:

```
sip:499djd4dwq0.sip.livekit.cloud;transport=tcp
```

</details>

<details>

<summary>How long does it take for the configuration to be live after clicking Configure?</summary>

Installation can take up to **30 seconds**. After this period, your integration should be ready for testing. Test both inbound and outbound calls to verify everything is working.

</details>

<details>

<summary>Where can I find detailed call logs for debugging?</summary>

Call logs are available in your Twilio Console under **Monitor → Logs → Calls**. This shows detailed information about all calls, including any errors or failures. BotPenguin also maintains its own logs for integration issues.

</details>

***

### Support

If you still have questions for our team, write to us at [**support@botpenguin.com**](mailto:support@botpenguin.com). We'll get back to you within 48 hours.

***

### 🎉 Completion

🎉 Congratulations, you have successfully set up the Twilio integration! You can now enable your agents to make and receive calls, automate voice workflows, and enhance your customer communication capabilities with reliable voice connectivity through Twilio.
