> This page is for Platform.

> Fetch clean Markdown by appending `.md` to any page URL under https://signalwire.com/docs or requesting it with the HTTP header `Accept: text/markdown`. The root index at https://signalwire.com/docs/llms.txt lists the available documentation indexes.

# ElevenLabs integration

> Connect an ElevenLabs agent to a SignalWire phone number over SIP, for inbound calls to the agent and outbound calls from it.

[signup]: https://signalwire.com/signup

[elevenlabs]: https://elevenlabs.io/app

[elevenlabs-sip-guide]: https://elevenlabs.io/docs/eleven-agents/phone-numbers/sip-trunking

[resources]: https://my.signalwire.com?page=resources

[sip-addresses-guide]: /docs/platform/voice/sip/sip-credentials#resource-sip-addresses

[swml-guide]: /docs/swml

[swml-connect]: /docs/swml/reference/calling/connect

[phone-numbers]: /docs/platform/phone-numbers

[segment-ids]: /docs/platform/what-is-a-sid

[verified-caller-id]: /docs/platform/voice/how-to-set-caller-id-or-cnam#verified-caller-id

[international]: /docs/platform/how-to-enable-international-services

[make-and-receive-calls]: /docs/platform/voice/make-and-receive-calls

[support]: https://support.signalwire.com/portal

An ElevenLabs agent needs a phone number, and SignalWire supplies one over SIP in both directions.
Callers dial your SignalWire number and reach the agent, and the agent places calls that show your
SignalWire number as caller ID.

Each direction is one [SWML][swml-guide] script in SignalWire. Inbound calls run a script that
bridges the caller to ElevenLabs over TLS. Outbound calls arrive at a SIP address on a second script,
which bridges them onto the public telephone network with digest authentication. Set up the
direction you need, or both.

## What you'll need

* A SignalWire account with at least one phone number ([sign up here][signup])
* An [ElevenLabs][elevenlabs] account with an agent ready to take calls
* [International outbound dialing][international] enabled on your Space, if the agent will call
  numbers outside your country

> **Use TLS on port 5061**
>
> Every SIP connection between ElevenLabs and SignalWire in this guide uses TLS on port 5061. Keep
> that transport on both sides.

## Inbound calls to your agent

A call to your SignalWire number is bridged to ElevenLabs over SIP with TLS, where your agent
answers it. That takes one SWML script and one setting on the number.

### Create the inbound routing script

In your SignalWire Dashboard, go to [**Resources**][resources], then **Add**, **Script**, and
**SWML Script**. Give the script a name you will recognize later, such as `Inbound to ElevenLabs`,
then paste this document:

**`Inbound to ElevenLabs`**

```yaml title="Inbound to ElevenLabs"
version: 1.0.0
sections:
  main:
    - connect:
        to: "sip:%{call.to}@sip.rtc.elevenlabs.io:5061;transport=tls"
```

The `%{call.to}` variable carries the number the caller dialed, which is how ElevenLabs matches the
call to your imported number. The [`connect` method][swml-connect] bridges the call to ElevenLabs
over SIP with TLS.

### Connect the script to your phone number

Assign the `Inbound to ElevenLabs` script to your phone number as its call handler:

Open **Phone Numbers**, select the number, and select **Edit Settings**. Under **Inbound Call
Settings**, select **Assign Resource**, choose the Resource, and save. To assign from the Resource
instead, open its **Addresses & Phone Numbers** tab, select **+ Add**, then **Phone Number**, and
pick a number you own.

Every call to that number now reaches ElevenLabs.

## Outbound calls from your agent

For outbound calls, the roles reverse. SignalWire publishes a SIP address that ElevenLabs dials, and
a second SWML script bridges each call onto the public telephone network with your SignalWire number
as the caller ID. ElevenLabs authenticates to that SIP address with a password you set in SignalWire.

### Create the outbound routing script

Go to [**Resources**][resources], then **Add**, **Script**, and **SWML Script**. Give the script a
name such as `Outbound via SignalWire`, then paste this document:

**`Outbound via SignalWire`**

```yaml title="Outbound via SignalWire" {5}
version: 1.0.0
sections:
  main:
    - connect:
        from: "+15551234567"
        answer_on_bridge: true
        to: "%{call.to.replace(/^sip:/i, '').replace(/@.*/, '')}"
```

Replace `+15551234567` with a phone number in E.164 format that you purchased from SignalWire or
added as a [verified caller ID][verified-caller-id]. That number is the caller ID people see when
your agent calls them, whatever ElevenLabs sends in its own `From` header. The `to` expression
extracts the destination number from the SIP request that ElevenLabs sends.

### Add a SIP address to the outbound script

The script needs a [SIP address][sip-addresses-guide] that ElevenLabs can dial.

1. Open the saved `Outbound via SignalWire` script and select the **Addresses & Phone Numbers** tab.
2. Choose **Add**, then **SIP Address**.
3. Give the address a descriptive name, such as `elevenlabs-outbound`.
4. Leave the **User** field set to `*`, its default.
5. Set a password. ElevenLabs uses it for digest authentication.
6. Save the address.

Copy the SIP domain the Dashboard shows. It has the form `<your-sip-address>.dapp.signalwire.com`,
and you'll enter it in ElevenLabs next.

## Configure the SIP trunk in ElevenLabs

For the ElevenLabs steps, follow ElevenLabs' own [SIP trunking guide][elevenlabs-sip-guide] and use
the SignalWire values below.

In the [ElevenLabs][elevenlabs] dashboard, open **Phone Numbers**, choose **Import Number**, and
select **From SIP Trunk**. Then configure the trunk with these values:

| ElevenLabs setting      | Value                                                                                                       |
| ----------------------- | ----------------------------------------------------------------------------------------------------------- |
| **SIP Server / Domain** | Your SIP domain, `<your-sip-address>.dapp.signalwire.com`                                                   |
| **Transport Type**      | **TLS**                                                                                                     |
| **Auth Username**       | Any value, such as your SignalWire number in E.164 format. SignalWire checks the password, not the username |
| **Auth Password**       | The password you set on the SIP address                                                                     |

Attach your ElevenLabs agent to the trunk so it can answer and handle calls.

## Test the integration

To test the inbound direction, call your SignalWire number from a mobile or landline. The call
routes from your number through the inbound script to your ElevenLabs agent, which answers.

To test the outbound direction, place a call from ElevenLabs using the trunk you configured.
ElevenLabs sends the request to your SignalWire SIP address over TLS on port 5061 and
authenticates, and the outbound script places the call to the public telephone network with your
SignalWire number as the caller ID.

If either call fails, the troubleshooting section below lists the common causes, grouped by the SIP
response code that ElevenLabs reports.

## Troubleshoot the ElevenLabs integration

### 603 Decline as soon as the call starts

SignalWire rejected the call from ElevenLabs before routing it. The usual causes are a wrong
password for the SIP address, a trunk that points at the wrong SIP domain, a SIP address that isn't
attached to the outbound script, or a `from` number that isn't a purchased SignalWire number or a
[verified caller ID][verified-caller-id]. To fix it, re-enter the password and confirm that the
trunk points at `<your-sip-address>.dapp.signalwire.com` exactly. Then open the outbound script,
confirm that the SIP address is listed under **Addresses & Phone Numbers**, and check the `from`
value.

### 480 Temporarily Unavailable on some calls

The destination, or its carrier, didn't accept the call on this attempt. Confirm that the
destination is a valid number in E.164 format, then retry after a short delay. To isolate where the
call fails, place the same call directly from SignalWire by following the
[make and receive calls guide][make-and-receive-calls]. If the call keeps failing, open a Support ticket with
the [Segment IDs][segment-ids] and timestamps.

### 408 Request Timeout

ElevenLabs sent the request and got no response from SignalWire. On the trunk in ElevenLabs, check
that **SIP Server / Domain** is your SIP domain, `<your-sip-address>.dapp.signalwire.com`, with no
typos, and that **Transport Type** is **TLS**. If both are correct and calls still time out, open a
Support ticket with the details below.

### What to send Support

If you open a ticket with [SignalWire Support][support], include:

* The direction of the failing calls, inbound or outbound, and the destination number you attempted
* The SIP response code that ElevenLabs shows
* Two or three Segment IDs, or exact timestamps with a time zone
* Confirmation that you are using TLS on port 5061, and the exact SIP domain you configured

Leave passwords out of the ticket.

## Next steps

#### [Make and receive calls](/docs/platform/voice/make-and-receive-calls)

Call your own phone from SignalWire and answer calls to your number with SWML, Relay, or the Browser SDK

#### [SIP credentials and addresses](/docs/platform/voice/sip/sip-credentials)

How resource SIP addresses route inbound SIP traffic to your scripts and agents

#### [SWML connect reference](/docs/swml/reference/calling/connect)

Every option on the method both routing scripts use