Twilio inbound calls
The Python reference bridge terminates a bidirectional Twilio Media Stream and opens one Dialt session per call. Twilio remains responsible for the phone number and call; your service owns deployment and application tools.
- Download the maintained Twilio example from Dialt developer docs.
- Copy
env.exampleto.env, then setDIALT_API_KEY,TWILIO_AUTH_TOKENand the exact externalPUBLIC_BASE_URL. - Run the locked standalone project behind public HTTPS:
mkdir dialt-twilio
cd dialt-twilio
curl -fsSLO https://dialt.com/docs/api/examples/twilio/README.md
curl -fsSLO https://dialt.com/docs/api/examples/twilio/bridge.py
curl -fsSLO https://dialt.com/docs/api/examples/twilio/env.example
curl -fsSLO https://dialt.com/docs/api/examples/twilio/requirements.txt
cp env.example .env
uv venv
uv pip install -r requirements.txt
uv run uvicorn bridge:app --env-file .env --host 0.0.0.0 --port 8000
- Point the Twilio number's incoming Voice webhook at
POST https://your-host/voice.
The bridge validates Twilio signatures, converts 8 kHz G.711 mu-law audio, and maps Twilio mark/clear playback state onto Dialt interruption events. Add your tool schemas and handlers in tool_manifest() and execute_tool(). The recipe README is the source of truth for configuration, tests and operational boundaries.
Optional human handoff
Set TWILIO_ACCOUNT_SID and an HTTPS TWILIO_HUMAN_HANDOFF_URL to enable the permission-gated request_human_handoff tool. When the caller approves a handoff, the bridge redirects the active Twilio call to that customer-owned TwiML endpoint. The endpoint can route to a number, queue, conference, Flex flow or TaskRouter workflow; the destination is configuration and is never supplied by the model.
TWILIO_ACCOUNT_SID=ACxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
TWILIO_HUMAN_HANDOFF_URL=https://voice.example.com/handoff
This is a cold-transfer reference. The tool provides a reason and concise summary to execute_tool(); persist them by CallSid in your application before redirecting if the receiving agent needs context.