Skip to main content
Twilio passes inbound calls to AssemblyAI over SIP, so there’s no media server, audio bridge, or webhook to run.
You need: Prefer clicking? You can do every Twilio step in the Console under Voice → Manage → Elastic SIP Trunking. The CLI just makes it scriptable. Five steps, three on Twilio and two on AssemblyAI:
  1. Create a SIP trunk
  2. Route its origination to sip:sip.assemblyai.com
  3. Attach your number to the trunk
  4. Register the number with AssemblyAI
  5. Bind your agent to it

1. Set your details

Save these in a .env file in your working directory:
.env
Load it into your shell:
TRUNK_DOMAIN doesn’t exist yet. You’re naming the trunk you create in the next step, and it must end in .pstn.twilio.com and be unique across Twilio, so include your company name.

2. Point Twilio at AssemblyAI

Creates the trunk, points its origination at sip:sip.assemblyai.com, and attaches your number to the trunk.
setup-trunk.sh
The trunk now controls the number. Any Voice webhook set on the number itself no longer applies. Reusing a trunk that already has an origination URL? Delete the old one before running this, or calls may go to the wrong place:

3. Attach your agent to the number

Registers the number with AssemblyAI against your trunk, binds AGENT_ID to it, and prints the result.
register-number.sh
The final jq output should show your agent_id with "type": "imported".
To point the number at a different agent later, re-run only the PUT. Twilio needs no changes, and editing the agent itself changes nothing here: the number is bound to the ID, so updates to that agent take effect on the next call.

4. Call it

Ring the number. You should hear the greeting, then have a real-time conversation with the agent.
Twilio bills the inbound minutes and AssemblyAI bills the session, so a live number draws on both accounts.

If it does not work

Want it scripted?

The Python and JavaScript starters run all five steps as one idempotent command, publishing the agent along the way:

Next steps