- A Twilio account (Account SID + Auth Token from the Console home page) with a phone number you already own
- An AssemblyAI API key
- An
agent_id. Don’t have one? Create an agent first. - The Twilio CLI installed and logged in (
twilio login), pluscurl,jq, anduuidgen
- Create a SIP trunk
- Route its origination to
sip:sip.assemblyai.com - Attach your number to the trunk
- Register the number with AssemblyAI
- Bind your agent to it
1. Set your details
Save these in a.env file in your working directory:
.env
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 atsip:sip.assemblyai.com, and attaches your number to the trunk.
setup-trunk.sh
3. Attach your agent to the number
Registers the number with AssemblyAI against your trunk, bindsAGENT_ID to it, and prints the result.
register-number.sh
jq output should show your agent_id with "type": "imported".
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
- Configure your agent: Customize the system prompt, greeting, and turn detection.
- Choose a voice: Pick a voice for your agent.
- Add tools to your agent: Give your agent the ability to call functions.