Set up two-way voice for your ElevenLabs AI agent
This tutorial connects an ElevenLabs Conversational AI agent to PSTN through a DIDHub SIP trunk so your agent can both receive calls on a real phone number and place outbound calls. Bridge layer: Twilio-style BYOC compatible bridge (LiveKit, Pipecat, or custom).
Step 1: Provision a SIP trunk in DIDHub
Dashboard → SIP Trunks → New trunk. Choose authentication mode:
- IP ACL: simpler — lock the trunk to your bridge's static egress IP.
- SIP digest auth: use a username + password (recommended for cloud bridges with rotating IPs).
# Trunk credentials shown after creation SIP server : sip.didhub.io SIP port : 5060 (UDP) or 5061 (TLS) Username : trunk_a4f9c2 Password : "<copy from dashboard>" Codecs : PCMU, PCMA, OPUS
Step 2: Bridge layer — LiveKit Agents (recommended)
ElevenLabs ConvAI runs over a WebSocket; PSTN runs over SIP. LiveKit Agents handles the SIP ↔ WebSocket bridge for free.
# livekit-sip-trunk.yaml trunk_id: didhub-elevenlabs inbound_addresses: ["sip.didhub.io"] outbound_address: sip.didhub.io outbound_username: trunk_a4f9c2 outbound_password: "$DIDHUB_TRUNK_PASSWORD" numbers: ["+15551234567"] krisp_enabled: true
lk sip dispatch create --trunk-id didhub-elevenlabs --rule '{"dispatchRuleIndividual":{"roomPrefix":"call-"}}'
Step 3: Wire ElevenLabs ConvAI to LiveKit
# LiveKit agent (Python) from livekit.agents import AgentSession from livekit.plugins import elevenlabs session = AgentSession( stt=elevenlabs.STT(api_key="$ELEVENLABS_API_KEY"), llm=elevenlabs.LLM(agent_id="$ELEVENLABS_AGENT_ID"), tts=elevenlabs.TTS(voice_id="21m00Tcm4TlvDq8ikWAM"), ) await session.start(room=ctx.room)
Step 4: Bind the DID in DIDHub
Numbers → +1 555 123 4567 → Routing → SIP Trunk: didhub-elevenlabs. Save. Inbound calls now hit your LiveKit room which spawns the ElevenLabs agent.
Step 5: Place an outbound call
curl -X POST https://api.livekit.io/twirp/livekit.SIP/CreateSIPParticipant \ -H "Authorization: Bearer $LK_TOKEN" \ -d '{ "sip_trunk_id": "didhub-elevenlabs", "sip_call_to": "+15557654321", "room_name": "call-outbound-001", "participant_identity": "elevenlabs-agent" }'
Audio quality checklist
- OPUS preferred (48 kHz wideband). Falls back to G.711 only on PSTN-side codec mismatch.
- Krisp noise suppression enabled at the LiveKit level cleans residual line noise before STT.
- Set ElevenLabs voice latency mode to
3(lowest) for sub-second turn-taking.
What you just built
An ElevenLabs ConvAI agent that answers a real phone number with sub-300ms first-token latency, supports two-way calling, and runs entirely on standard SIP — portable to any provider that follows BYOC conventions.
Ready to get a number?
Pick a DID in 130+ countries from $1.99/month. Activates instantly on most numbers.