VonyxDocs

ElevenLabs

Connect an ElevenLabs Agents Platform agent to Vonyx numbers over WebSocket or a SIP trunk.

View this page as Markdown

There are two ways to connect an ElevenLabs agent to Vonyx. The Call API streams outbound call audio straight to the agent's WebSocket, with no SIP setup. A SIP trunk import gives you both outbound and inbound calls.

Before you start

  • A Vonyx SIP trunk with a number attached
  • An ElevenLabs account with an agent on the Agents Platform, and its agent ID
  • An ElevenLabs API key, if your agent is private or you place calls through the ElevenLabs API

Outbound calls

Vonyx dials the number. When the call is answered, it opens the agent's WebSocket and speaks the ElevenLabs conversation protocol (ws_protocol: "elevenlabs").

Set the agent's audio format

The agent's input and output audio formats must match the sample_rate you send to Vonyx. Set both to the same value:

Agent settingValuesample_rate
User input audio format (conversation_config.asr.user_input_audio_format)pcm_16000 (the ElevenLabs default)16000
Agent output audio format (conversation_config.tts.agent_output_audio_format)pcm_1600016000

For 8 kHz audio, set both to pcm_8000 and send sample_rate: 8000. Use pcm_16000 unless you have a reason not to.

Get the agent's WebSocket URL

For a public agent, use:

wss://api.elevenlabs.io/v1/convai/conversation?agent_id=YOUR_AGENT_ID

For a private agent (authentication turned on in the agent's Security settings), get a signed URL from your server before each call:

Get a signed URL
curl "https://api.elevenlabs.io/v1/convai/conversation/get-signed-url?agent_id=YOUR_AGENT_ID" \
  -H "xi-api-key: YOUR_ELEVENLABS_API_KEY"

The response's signed_url field is the WebSocket URL to use. It is valid for 15 minutes, so request it just before you place the call. Keep the API key on your server.

Place the call

Place a call
curl -X POST https://api.vocalstack.site/v1/calls \
  -H "Content-Type: application/json" \
  -d '{
    "did": "91XXXXXXXXXX",
    "phone_number": "91XXXXXXXXXX",
    "websocket_url": "wss://api.elevenlabs.io/v1/convai/conversation?agent_id=YOUR_AGENT_ID",
    "ws_protocol": "elevenlabs",
    "sample_rate": 16000
  }'
FieldValue
didYour Vonyx number, used as the caller ID
phone_numberThe number to call
websocket_urlThe public URL or the signed URL from the last step
ws_protocolelevenlabs
sample_rate16000 for pcm_16000, 8000 for pcm_8000
webhook_urlOptional. Where Vonyx sends call status updates

See the Call API reference for every field.

Let the agent end the call

Give the agent the end_call system tool. Agents created in the ElevenLabs dashboard have it by default; agents created through the API need it added under built_in_tools. The agent calls it when the conversation is done.

Inbound calls

Use the SIP trunk for inbound

The Call API places outbound calls only. To have the agent answer calls to your Vonyx number, use the SIP trunk tab.

Test the connection

  • WebSocket: place a call to your own phone with the Call API. The agent should speak its first message once you answer.
  • SIP outbound: run a Test call from the batch call form, or call the outbound endpoint with your own number as to_number.
  • SIP inbound: call your Vonyx number from another phone. The assigned agent should answer.

Limitations

  • DTMF and call transfer are not available on Vonyx yet, so ElevenLabs' transfer and keypad tools won't work on these calls.
  • New accounts make 1 call at a time (raise limits).
  • The caller ID must be one of your Vonyx numbers.
  • Vonyx has no TLS or SRTP, so ElevenLabs' TLS transport and encrypted media can't be used.
  • The Call API is outbound only. Inbound calls need the SIP trunk.
  • ElevenLabs limits concurrent calls by subscription tier.

Troubleshooting

ProblemFix
Agent sounds sped up, slowed down or garbledThe agent's input and output formats don't match sample_rate. Set both to pcm_16000 with 16000, or pcm_8000 with 8000.
WebSocket call connects, then drops at onceThe private agent needs a signed URL, or the signed URL is older than 15 minutes. Request a new one per call.
Outbound SIP calls fail to connectCheck the address is 43.204.9.41 with no sip: prefix, the trunk username and password, and that the number is attached to the trunk.
One-way or no audio on SIPMake sure PCMU or PCMA is enabled and media encryption is Disabled.
Inbound calls don't reach the agentCheck the inbound address is sip.rtc.elevenlabs.io:5060, the number's + matches what Vonyx sends, and an agent is assigned. If you set allowed source IPs, include 43.204.9.41.
Calls rejected when a second one startsYou hit the 1-channel default. Raise limits.

See SIP troubleshooting for more.