twilio plugin bridges PSTN phone calls into a Vision Agents + Stream call through Twilio voice webhooks, TwiML Media Streams, and bidirectional WebSocket audio.
Vision Agents uses Stream Video for real-time WebRTC transport by default. External WebRTC transports are supported as well. Most AI providers offer free tiers to get started.
What the plugin provides
- Twilio Media Streams over WebSocket with bidirectional audio
TwilioCallRegistryfor call/session/token trackingattach_phone_to_callto bridge Twilio mulaw audio ↔ Stream WebRTC- Built-in FastAPI helpers:
verify_twilio_signature,CallWebhookInput, TwiML response builders - Automatic mulaw/PCM conversion at 8 kHz
Prerequisites
Installation
Environment Variables
Twilio account setup
- Buy or assign a Twilio phone number.
- Under Phone Numbers → Manage → Active numbers, open your number.
-
Set A call comes in to Webhook pointing at:
- Use HTTP POST.
Quick Start
The plugin gives you registry, media stream, and bridge primitives. Your FastAPI server wires them to Twilio webhooks and WebSockets:Inbound calls
Twilio sends a webhook when someone calls your number. Validate the signature, register the call, and return TwiML to start the media stream:Outbound calls
Pre-register the call in the registry, start your server, then dial via the Twilio REST API:Key Components
Audio
Twilio Media Streams use mulaw encoding at 8 kHz. The plugin converts between mulaw and PCM automatically inTwilioMediaStream and exposes conversion helpers if you need them directly.
Common setup errors
Next Steps
Twilio Phone Agent
Step-by-step inbound and outbound phone tutorial
Phone Support Agent (RAG)
Add knowledge retrieval to phone calls
Phone Calling
Provider overview and learning path
Telnyx
Alternative telephony provider
Stream Video RTC
Default edge transport for agent calls
Build a Voice Agent
Get started with voice