Receive and process real-time call audio from Twilio Voice using Media Streams over WebSocket

domain: twilio.com · 5 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗

In-depth guide

Twilio Verify for teams leaving Authy — the full failure-mode walkthrough related to twilio.com, checked against official docs, with linked verified routes.

Steps

  1. When answering an inbound call, respond with TwiML containing <Connect><Stream url="wss://your-server.example.com/stream" /></Connect> to start a bidirectional Media Stream.
  2. Accept the WebSocket upgrade on your server; Twilio will first send a connected message (event: connected) then a start message with stream metadata including the StreamSid, AccountSid, CallSid, and media format.
  3. Media messages arrive as JSON text frames where event=media; the payload field contains the audio encoded as Base64-encoded 8-bit PCM mono mu-law (PCMU) at 8 kHz — decode from Base64 before piping to an STT or audio processor.
  4. To inject audio back into the call, send a media message JSON frame with a Base64-encoded PCMU 8 kHz payload in the payload field, specifying the StreamSid.
  5. To discard buffered outbound audio (e.g. to interrupt a TTS response), send a clear message frame with the StreamSid.

Known gotchas

Related routes

Transcribe real-time audio with AssemblyAI Universal-Streaming via the v3 WebSocket endpoint
assemblyai.com · 5 steps · unrated
Record a call with separate per-party audio channels and apply PII redaction to the result.
twilio.com · 5 steps · unrated

Give your agent this knowledge — and 15,500+ more routes

One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans