[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill-twilio-twilio-voice-conversation-relay":3,"mdc--p497rh-key":36,"related-org-twilio-twilio-voice-conversation-relay":1596,"related-repo-twilio-twilio-voice-conversation-relay":1776},{"slug":4,"name":4,"fn":5,"description":6,"org":7,"tags":11,"stars":26,"repoUrl":27,"updatedAt":28,"license":29,"forks":30,"topics":31,"repo":32,"sourceUrl":34,"mdContent":35},"twilio-voice-conversation-relay","build voice agents with Twilio ConversationRelay","Build AI-powered voice agents using Twilio ConversationRelay. Handles real-time speech recognition (ASR), text-to-speech (TTS), and bidirectional audio streaming via WebSocket. Covers TwiML setup, WebSocket message types, LLM integration, streaming responses, and voice provider configuration. Use this skill to build voice bots, IVR replacements, or real-time AI voice assistants on Twilio calls.\n",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},"twilio","Twilio","https:\u002F\u002Fpexgzepcugksgbtrxkhf.supabase.co\u002Fstorage\u002Fv1\u002Fobject\u002Fpublic\u002Forg-logos\u002Ftwilio.png",[12,16,19,22,25],{"name":13,"slug":14,"type":15},"WebSockets","websockets","tag",{"name":17,"slug":18,"type":15},"Agents","agents",{"name":20,"slug":21,"type":15},"Audio","audio",{"name":23,"slug":24,"type":15},"Speech","speech",{"name":9,"slug":8,"type":15},25,"https:\u002F\u002Fgithub.com\u002Ftwilio\u002Fai","2026-07-17T06:04:25.95899",null,7,[],{"repoUrl":27,"stars":26,"forks":30,"topics":33,"description":29},[],"https:\u002F\u002Fgithub.com\u002Ftwilio\u002Fai\u002Ftree\u002FHEAD\u002Fskills\u002Ftwilio\u002Ftwilio-voice-conversation-relay","---\nname: twilio-voice-conversation-relay\ndescription: >\n  Build AI-powered voice agents using Twilio ConversationRelay. Handles\n  real-time speech recognition (ASR), text-to-speech (TTS), and bidirectional\n  audio streaming via WebSocket. Covers TwiML setup, WebSocket message types,\n  LLM integration, streaming responses, and voice provider configuration. Use\n  this skill to build voice bots, IVR replacements, or real-time AI voice\n  assistants on Twilio calls.\n---\n\n## Overview\n\nConversationRelay connects Twilio's telephony layer to your app via a persistent WebSocket. Twilio handles ASR (speech-to-text) and TTS (text-to-speech); your app receives transcripts, calls an LLM, and sends text back for playback.\n\n```\nCaller ←→ Twilio (ASR\u002FTTS) ←→ WebSocket ←→ Your App ←→ LLM\n```\n\n---\n\n## Prerequisites\n\n- Upgraded Twilio account with ConversationRelay access (requires onboarding)\n  — New to Twilio? See `twilio-account-setup`\n  — Start onboarding at: [Console > Voice > ConversationRelay](https:\u002F\u002Fconsole.twilio.com\u002Fus1\u002Fvoice\u002Fconversation-relay) — access is **not** instant\n- A voice-capable Twilio phone number\n- `TWILIO_ACCOUNT_SID` and `TWILIO_AUTH_TOKEN` — see `twilio-iam-auth-setup`\n- WebSocket server reachable via `wss:\u002F\u002F` (TLS required)\n- An LLM integration (OpenAI, Anthropic, etc.)\n- For placing calls: see `twilio-voice-outbound-calls`\n\n**Onboarding:** Complete via Console > Voice > ConversationRelay > Onboarding. Select TTS\u002FASR providers:\n- **TTS:** Deepgram, Amazon Polly, Google Cloud TTS, ElevenLabs\n- **ASR:** Deepgram, Google Cloud STT\n\n---\n\n## Quickstart\n\n**Step 1 — Return TwiML pointing to your WebSocket server**\n\n**Python (Flask)**\n```python\nfrom flask import Flask\nfrom twilio.twiml.voice_response import VoiceResponse, Connect, ConversationRelay\n\napp = Flask(__name__)\n\n@app.route(\"\u002Fvoice\", methods=[\"POST\"])\ndef voice():\n    response = VoiceResponse()\n    connect = Connect()\n    connect.conversation_relay(\n        url=\"wss:\u002F\u002Fyourapp.com\u002Fws\u002Fvoice\",\n        welcome_greeting=\"Hello! How can I help you today?\"\n    )\n    response.append(connect)\n    return str(response)\n```\n\n**Node.js (Express)**\n```node\nconst { VoiceResponse } = require(\"twilio\").twiml;\n\napp.post(\"\u002Fvoice\", (req, res) => {\n    const response = new VoiceResponse();\n    const connect = response.connect();\n    connect.conversationRelay({\n        url: \"wss:\u002F\u002Fyourapp.com\u002Fws\u002Fvoice\",\n        welcomeGreeting: \"Hello! How can I help you today?\",\n    });\n    res.type(\"text\u002Fxml\").send(response.toString());\n});\n```\n\n**Step 2 — Handle WebSocket events and respond with text**\n\n**Python (websockets)**\n```python\nimport asyncio, json, websockets\n\nasync def handle_call(websocket):\n    async for message in websocket:\n        event = json.loads(message)\n        if event[\"type\"] == \"prompt\":\n            ai_response = await call_llm(event[\"voicePrompt\"])\n            await websocket.send(json.dumps({\"type\": \"text\", \"token\": ai_response, \"last\": True}))\n\nasync def main():\n    async with websockets.serve(handle_call, \"0.0.0.0\", 8080):\n        await asyncio.Future()\n\nasyncio.run(main())\n```\n\n**Node.js (ws)**\n```node\nconst WebSocket = require(\"ws\");\nconst wss = new WebSocket.Server({ port: 8080 });\n\nwss.on(\"connection\", (ws) => {\n    ws.on(\"message\", async (data) => {\n        const event = JSON.parse(data);\n        if (event.type === \"prompt\") {\n            const aiResponse = await callLLM(event.voicePrompt);\n            ws.send(JSON.stringify({ type: \"text\", token: aiResponse, last: true }));\n        }\n    });\n});\n```\n\n> **Security:** The `voicePrompt` field contains ASR-transcribed caller speech — it is untrusted external input. When passing to an LLM, isolate it as user input within a structured system prompt. Implement topic boundaries and output filtering to prevent the LLM from disclosing system instructions or speaking inappropriate content. ConversationRelay is a pure transport layer with no built-in content safety — any LLM output is spoken to the caller verbatim.\n\n---\n\n## Key Patterns\n\n### WebSocket Message Types\n\n**Received from Twilio:**\n\n| Type | When | Key fields |\n|------|------|-----------|\n| `connected` | WebSocket opened | `callSid`, `streamSid` |\n| `prompt` | User finished speaking | `voicePrompt` (transcript) |\n| `interrupt` | User interrupted TTS | — |\n| `dtmf` | User pressed keypad key | `digit` |\n| `error` | An error occurred | `description` |\n\n**Sent to Twilio:**\n\n| Type | Purpose | Key fields |\n|------|---------|-----------|\n| `text` | Send TTS response | `token` (text), `last` (bool) |\n| `interrupt` | Stop current TTS | — |\n| `end` | Hang up the call | `reason` |\n\n### Stream LLM Responses Token-by-Token\n\nLower latency by streaming as the LLM generates output — Twilio starts speaking before the full response is ready.\n\n**Python**\n```python\nasync for chunk in llm_stream:\n    await websocket.send(json.dumps({\"type\": \"text\", \"token\": chunk, \"last\": False}))\nawait websocket.send(json.dumps({\"type\": \"text\", \"token\": \"\", \"last\": True}))\n```\n\n**Node.js**\n```node\nfor await (const chunk of llmStream) {\n    ws.send(JSON.stringify({ type: \"text\", token: chunk, last: false }));\n}\nws.send(JSON.stringify({ type: \"text\", token: \"\", last: true }));\n```\n\n### Voice Configuration\n\n**Python**\n```python\nconnect.conversation_relay(\n    url=\"wss:\u002F\u002Fyourapp.com\u002Fws\u002Fvoice\",\n    voice=\"en-US-Neural2-F\",\n    language=\"en-US\",\n    transcription_provider=\"deepgram\",\n    speech_model=\"nova-2-phonecall\",\n    interrupt_by_dtmf=True,\n)\n```\n\n**Node.js**\n```node\nconnect.conversationRelay({\n    url: \"wss:\u002F\u002Fyourapp.com\u002Fws\u002Fvoice\",\n    voice: \"en-US-Neural2-F\",\n    language: \"en-US\",\n    transcriptionProvider: \"deepgram\",\n    speechModel: \"nova-2-phonecall\",\n    interruptByDtmf: true,\n});\n```\n\n---\n\n## CANNOT\n\n- **No raw audio access** — Text in, text out only. For raw audio, use `\u003CConnect>\u003CStream>` (Media Streams).\n- **Cannot mix with Media Streams** — `\u003CConnect>\u003CStream>` and `\u003CConnect>\u003CConversationRelay>` are mutually exclusive on the same call. No error — one is silently ignored.\n- **No custom STT\u002FTTS engines** — Limited to Deepgram + Google (STT) and Deepgram + Amazon Polly + Google + ElevenLabs (TTS).\n- **No mid-session voice\u002Fprovider changes** — Voice and provider are set at TwiML time. Only `language` can be switched mid-session via WebSocket message.\n- **No WebSocket auto-reconnection** — If the WebSocket drops, the call disconnects. Implement recovery via `\u003CConnect action>` URL.\n- **Voice only** — No SMS\u002Fmessaging support. For omnichannel, use Conversation Orchestrator.\n- **No built-in memory or context** — BYO conversation history and context management.\n- **No LLM integration** — Pure transport layer. You bring your own LLM via the WebSocket server.\n- **No server-side recording via REST API** — `record:true` on the Calls API is silently ignored. Must use `\u003CStart>\u003CRecording>` before `\u003CConnect>` in TwiML.\n- **Not PCI compliant with Voice Intelligence v2** — Do not enable `intelligenceService` in PCI workflows.\n- **ElevenLabs requires account enablement** — Accounts without ElevenLabs access get error 64101. Voice IDs (not human-readable names) are required.\n- **Cannot use ConversationRelay without onboarding** — Not available immediately on a new account\n- **Cannot use non-TLS WebSocket** — Server must be reachable via `wss:\u002F\u002F` (TLS required)\n- **Cannot stream audio without `last: true`** — Twilio won't play audio until it sees a `last: true` token in the stream\n\n---\n\n## Next Steps\n\n- **Place outbound calls:** `twilio-voice-outbound-calls`\n- **Standard IVR without AI:** `twilio-voice-twiml`\n",{"data":37,"body":38},{"name":4,"description":6},{"type":39,"children":40},"root",[41,50,56,69,73,79,175,185,208,211,217,225,233,378,386,482,490,498,614,622,722,744,747,753,760,768,936,944,1050,1056,1061,1069,1100,1108,1147,1153,1160,1231,1238,1308,1311,1317,1548,1551,1557,1590],{"type":42,"tag":43,"props":44,"children":46},"element","h2",{"id":45},"overview",[47],{"type":48,"value":49},"text","Overview",{"type":42,"tag":51,"props":52,"children":53},"p",{},[54],{"type":48,"value":55},"ConversationRelay connects Twilio's telephony layer to your app via a persistent WebSocket. Twilio handles ASR (speech-to-text) and TTS (text-to-speech); your app receives transcripts, calls an LLM, and sends text back for playback.",{"type":42,"tag":57,"props":58,"children":62},"pre",{"className":59,"code":61,"language":48},[60],"language-text","Caller ←→ Twilio (ASR\u002FTTS) ←→ WebSocket ←→ Your App ←→ LLM\n",[63],{"type":42,"tag":64,"props":65,"children":67},"code",{"__ignoreMap":66},"",[68],{"type":48,"value":61},{"type":42,"tag":70,"props":71,"children":72},"hr",{},[],{"type":42,"tag":43,"props":74,"children":76},{"id":75},"prerequisites",[77],{"type":48,"value":78},"Prerequisites",{"type":42,"tag":80,"props":81,"children":82},"ul",{},[83,116,121,146,159,164],{"type":42,"tag":84,"props":85,"children":86},"li",{},[87,89,95,97,106,108,114],{"type":48,"value":88},"Upgraded Twilio account with ConversationRelay access (requires onboarding)\n— New to Twilio? See ",{"type":42,"tag":64,"props":90,"children":92},{"className":91},[],[93],{"type":48,"value":94},"twilio-account-setup",{"type":48,"value":96},"\n— Start onboarding at: ",{"type":42,"tag":98,"props":99,"children":103},"a",{"href":100,"rel":101},"https:\u002F\u002Fconsole.twilio.com\u002Fus1\u002Fvoice\u002Fconversation-relay",[102],"nofollow",[104],{"type":48,"value":105},"Console > Voice > ConversationRelay",{"type":48,"value":107}," — access is ",{"type":42,"tag":109,"props":110,"children":111},"strong",{},[112],{"type":48,"value":113},"not",{"type":48,"value":115}," instant",{"type":42,"tag":84,"props":117,"children":118},{},[119],{"type":48,"value":120},"A voice-capable Twilio phone number",{"type":42,"tag":84,"props":122,"children":123},{},[124,130,132,138,140],{"type":42,"tag":64,"props":125,"children":127},{"className":126},[],[128],{"type":48,"value":129},"TWILIO_ACCOUNT_SID",{"type":48,"value":131}," and ",{"type":42,"tag":64,"props":133,"children":135},{"className":134},[],[136],{"type":48,"value":137},"TWILIO_AUTH_TOKEN",{"type":48,"value":139}," — see ",{"type":42,"tag":64,"props":141,"children":143},{"className":142},[],[144],{"type":48,"value":145},"twilio-iam-auth-setup",{"type":42,"tag":84,"props":147,"children":148},{},[149,151,157],{"type":48,"value":150},"WebSocket server reachable via ",{"type":42,"tag":64,"props":152,"children":154},{"className":153},[],[155],{"type":48,"value":156},"wss:\u002F\u002F",{"type":48,"value":158}," (TLS required)",{"type":42,"tag":84,"props":160,"children":161},{},[162],{"type":48,"value":163},"An LLM integration (OpenAI, Anthropic, etc.)",{"type":42,"tag":84,"props":165,"children":166},{},[167,169],{"type":48,"value":168},"For placing calls: see ",{"type":42,"tag":64,"props":170,"children":172},{"className":171},[],[173],{"type":48,"value":174},"twilio-voice-outbound-calls",{"type":42,"tag":51,"props":176,"children":177},{},[178,183],{"type":42,"tag":109,"props":179,"children":180},{},[181],{"type":48,"value":182},"Onboarding:",{"type":48,"value":184}," Complete via Console > Voice > ConversationRelay > Onboarding. Select TTS\u002FASR providers:",{"type":42,"tag":80,"props":186,"children":187},{},[188,198],{"type":42,"tag":84,"props":189,"children":190},{},[191,196],{"type":42,"tag":109,"props":192,"children":193},{},[194],{"type":48,"value":195},"TTS:",{"type":48,"value":197}," Deepgram, Amazon Polly, Google Cloud TTS, ElevenLabs",{"type":42,"tag":84,"props":199,"children":200},{},[201,206],{"type":42,"tag":109,"props":202,"children":203},{},[204],{"type":48,"value":205},"ASR:",{"type":48,"value":207}," Deepgram, Google Cloud STT",{"type":42,"tag":70,"props":209,"children":210},{},[],{"type":42,"tag":43,"props":212,"children":214},{"id":213},"quickstart",[215],{"type":48,"value":216},"Quickstart",{"type":42,"tag":51,"props":218,"children":219},{},[220],{"type":42,"tag":109,"props":221,"children":222},{},[223],{"type":48,"value":224},"Step 1 — Return TwiML pointing to your WebSocket server",{"type":42,"tag":51,"props":226,"children":227},{},[228],{"type":42,"tag":109,"props":229,"children":230},{},[231],{"type":48,"value":232},"Python (Flask)",{"type":42,"tag":57,"props":234,"children":238},{"className":235,"code":236,"language":237,"meta":66,"style":66},"language-python shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","from flask import Flask\nfrom twilio.twiml.voice_response import VoiceResponse, Connect, ConversationRelay\n\napp = Flask(__name__)\n\n@app.route(\"\u002Fvoice\", methods=[\"POST\"])\ndef voice():\n    response = VoiceResponse()\n    connect = Connect()\n    connect.conversation_relay(\n        url=\"wss:\u002F\u002Fyourapp.com\u002Fws\u002Fvoice\",\n        welcome_greeting=\"Hello! How can I help you today?\"\n    )\n    response.append(connect)\n    return str(response)\n","python",[239],{"type":42,"tag":64,"props":240,"children":241},{"__ignoreMap":66},[242,253,262,272,281,289,298,306,315,324,333,342,351,360,369],{"type":42,"tag":243,"props":244,"children":247},"span",{"class":245,"line":246},"line",1,[248],{"type":42,"tag":243,"props":249,"children":250},{},[251],{"type":48,"value":252},"from flask import Flask\n",{"type":42,"tag":243,"props":254,"children":256},{"class":245,"line":255},2,[257],{"type":42,"tag":243,"props":258,"children":259},{},[260],{"type":48,"value":261},"from twilio.twiml.voice_response import VoiceResponse, Connect, ConversationRelay\n",{"type":42,"tag":243,"props":263,"children":265},{"class":245,"line":264},3,[266],{"type":42,"tag":243,"props":267,"children":269},{"emptyLinePlaceholder":268},true,[270],{"type":48,"value":271},"\n",{"type":42,"tag":243,"props":273,"children":275},{"class":245,"line":274},4,[276],{"type":42,"tag":243,"props":277,"children":278},{},[279],{"type":48,"value":280},"app = Flask(__name__)\n",{"type":42,"tag":243,"props":282,"children":284},{"class":245,"line":283},5,[285],{"type":42,"tag":243,"props":286,"children":287},{"emptyLinePlaceholder":268},[288],{"type":48,"value":271},{"type":42,"tag":243,"props":290,"children":292},{"class":245,"line":291},6,[293],{"type":42,"tag":243,"props":294,"children":295},{},[296],{"type":48,"value":297},"@app.route(\"\u002Fvoice\", methods=[\"POST\"])\n",{"type":42,"tag":243,"props":299,"children":300},{"class":245,"line":30},[301],{"type":42,"tag":243,"props":302,"children":303},{},[304],{"type":48,"value":305},"def voice():\n",{"type":42,"tag":243,"props":307,"children":309},{"class":245,"line":308},8,[310],{"type":42,"tag":243,"props":311,"children":312},{},[313],{"type":48,"value":314},"    response = VoiceResponse()\n",{"type":42,"tag":243,"props":316,"children":318},{"class":245,"line":317},9,[319],{"type":42,"tag":243,"props":320,"children":321},{},[322],{"type":48,"value":323},"    connect = Connect()\n",{"type":42,"tag":243,"props":325,"children":327},{"class":245,"line":326},10,[328],{"type":42,"tag":243,"props":329,"children":330},{},[331],{"type":48,"value":332},"    connect.conversation_relay(\n",{"type":42,"tag":243,"props":334,"children":336},{"class":245,"line":335},11,[337],{"type":42,"tag":243,"props":338,"children":339},{},[340],{"type":48,"value":341},"        url=\"wss:\u002F\u002Fyourapp.com\u002Fws\u002Fvoice\",\n",{"type":42,"tag":243,"props":343,"children":345},{"class":245,"line":344},12,[346],{"type":42,"tag":243,"props":347,"children":348},{},[349],{"type":48,"value":350},"        welcome_greeting=\"Hello! How can I help you today?\"\n",{"type":42,"tag":243,"props":352,"children":354},{"class":245,"line":353},13,[355],{"type":42,"tag":243,"props":356,"children":357},{},[358],{"type":48,"value":359},"    )\n",{"type":42,"tag":243,"props":361,"children":363},{"class":245,"line":362},14,[364],{"type":42,"tag":243,"props":365,"children":366},{},[367],{"type":48,"value":368},"    response.append(connect)\n",{"type":42,"tag":243,"props":370,"children":372},{"class":245,"line":371},15,[373],{"type":42,"tag":243,"props":374,"children":375},{},[376],{"type":48,"value":377},"    return str(response)\n",{"type":42,"tag":51,"props":379,"children":380},{},[381],{"type":42,"tag":109,"props":382,"children":383},{},[384],{"type":48,"value":385},"Node.js (Express)",{"type":42,"tag":57,"props":387,"children":391},{"className":388,"code":389,"language":390,"meta":66,"style":66},"language-node shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","const { VoiceResponse } = require(\"twilio\").twiml;\n\napp.post(\"\u002Fvoice\", (req, res) => {\n    const response = new VoiceResponse();\n    const connect = response.connect();\n    connect.conversationRelay({\n        url: \"wss:\u002F\u002Fyourapp.com\u002Fws\u002Fvoice\",\n        welcomeGreeting: \"Hello! How can I help you today?\",\n    });\n    res.type(\"text\u002Fxml\").send(response.toString());\n});\n","node",[392],{"type":42,"tag":64,"props":393,"children":394},{"__ignoreMap":66},[395,403,410,418,426,434,442,450,458,466,474],{"type":42,"tag":243,"props":396,"children":397},{"class":245,"line":246},[398],{"type":42,"tag":243,"props":399,"children":400},{},[401],{"type":48,"value":402},"const { VoiceResponse } = require(\"twilio\").twiml;\n",{"type":42,"tag":243,"props":404,"children":405},{"class":245,"line":255},[406],{"type":42,"tag":243,"props":407,"children":408},{"emptyLinePlaceholder":268},[409],{"type":48,"value":271},{"type":42,"tag":243,"props":411,"children":412},{"class":245,"line":264},[413],{"type":42,"tag":243,"props":414,"children":415},{},[416],{"type":48,"value":417},"app.post(\"\u002Fvoice\", (req, res) => {\n",{"type":42,"tag":243,"props":419,"children":420},{"class":245,"line":274},[421],{"type":42,"tag":243,"props":422,"children":423},{},[424],{"type":48,"value":425},"    const response = new VoiceResponse();\n",{"type":42,"tag":243,"props":427,"children":428},{"class":245,"line":283},[429],{"type":42,"tag":243,"props":430,"children":431},{},[432],{"type":48,"value":433},"    const connect = response.connect();\n",{"type":42,"tag":243,"props":435,"children":436},{"class":245,"line":291},[437],{"type":42,"tag":243,"props":438,"children":439},{},[440],{"type":48,"value":441},"    connect.conversationRelay({\n",{"type":42,"tag":243,"props":443,"children":444},{"class":245,"line":30},[445],{"type":42,"tag":243,"props":446,"children":447},{},[448],{"type":48,"value":449},"        url: \"wss:\u002F\u002Fyourapp.com\u002Fws\u002Fvoice\",\n",{"type":42,"tag":243,"props":451,"children":452},{"class":245,"line":308},[453],{"type":42,"tag":243,"props":454,"children":455},{},[456],{"type":48,"value":457},"        welcomeGreeting: \"Hello! How can I help you today?\",\n",{"type":42,"tag":243,"props":459,"children":460},{"class":245,"line":317},[461],{"type":42,"tag":243,"props":462,"children":463},{},[464],{"type":48,"value":465},"    });\n",{"type":42,"tag":243,"props":467,"children":468},{"class":245,"line":326},[469],{"type":42,"tag":243,"props":470,"children":471},{},[472],{"type":48,"value":473},"    res.type(\"text\u002Fxml\").send(response.toString());\n",{"type":42,"tag":243,"props":475,"children":476},{"class":245,"line":335},[477],{"type":42,"tag":243,"props":478,"children":479},{},[480],{"type":48,"value":481},"});\n",{"type":42,"tag":51,"props":483,"children":484},{},[485],{"type":42,"tag":109,"props":486,"children":487},{},[488],{"type":48,"value":489},"Step 2 — Handle WebSocket events and respond with text",{"type":42,"tag":51,"props":491,"children":492},{},[493],{"type":42,"tag":109,"props":494,"children":495},{},[496],{"type":48,"value":497},"Python (websockets)",{"type":42,"tag":57,"props":499,"children":501},{"className":235,"code":500,"language":237,"meta":66,"style":66},"import asyncio, json, websockets\n\nasync def handle_call(websocket):\n    async for message in websocket:\n        event = json.loads(message)\n        if event[\"type\"] == \"prompt\":\n            ai_response = await call_llm(event[\"voicePrompt\"])\n            await websocket.send(json.dumps({\"type\": \"text\", \"token\": ai_response, \"last\": True}))\n\nasync def main():\n    async with websockets.serve(handle_call, \"0.0.0.0\", 8080):\n        await asyncio.Future()\n\nasyncio.run(main())\n",[502],{"type":42,"tag":64,"props":503,"children":504},{"__ignoreMap":66},[505,513,520,528,536,544,552,560,568,575,583,591,599,606],{"type":42,"tag":243,"props":506,"children":507},{"class":245,"line":246},[508],{"type":42,"tag":243,"props":509,"children":510},{},[511],{"type":48,"value":512},"import asyncio, json, websockets\n",{"type":42,"tag":243,"props":514,"children":515},{"class":245,"line":255},[516],{"type":42,"tag":243,"props":517,"children":518},{"emptyLinePlaceholder":268},[519],{"type":48,"value":271},{"type":42,"tag":243,"props":521,"children":522},{"class":245,"line":264},[523],{"type":42,"tag":243,"props":524,"children":525},{},[526],{"type":48,"value":527},"async def handle_call(websocket):\n",{"type":42,"tag":243,"props":529,"children":530},{"class":245,"line":274},[531],{"type":42,"tag":243,"props":532,"children":533},{},[534],{"type":48,"value":535},"    async for message in websocket:\n",{"type":42,"tag":243,"props":537,"children":538},{"class":245,"line":283},[539],{"type":42,"tag":243,"props":540,"children":541},{},[542],{"type":48,"value":543},"        event = json.loads(message)\n",{"type":42,"tag":243,"props":545,"children":546},{"class":245,"line":291},[547],{"type":42,"tag":243,"props":548,"children":549},{},[550],{"type":48,"value":551},"        if event[\"type\"] == \"prompt\":\n",{"type":42,"tag":243,"props":553,"children":554},{"class":245,"line":30},[555],{"type":42,"tag":243,"props":556,"children":557},{},[558],{"type":48,"value":559},"            ai_response = await call_llm(event[\"voicePrompt\"])\n",{"type":42,"tag":243,"props":561,"children":562},{"class":245,"line":308},[563],{"type":42,"tag":243,"props":564,"children":565},{},[566],{"type":48,"value":567},"            await websocket.send(json.dumps({\"type\": \"text\", \"token\": ai_response, \"last\": True}))\n",{"type":42,"tag":243,"props":569,"children":570},{"class":245,"line":317},[571],{"type":42,"tag":243,"props":572,"children":573},{"emptyLinePlaceholder":268},[574],{"type":48,"value":271},{"type":42,"tag":243,"props":576,"children":577},{"class":245,"line":326},[578],{"type":42,"tag":243,"props":579,"children":580},{},[581],{"type":48,"value":582},"async def main():\n",{"type":42,"tag":243,"props":584,"children":585},{"class":245,"line":335},[586],{"type":42,"tag":243,"props":587,"children":588},{},[589],{"type":48,"value":590},"    async with websockets.serve(handle_call, \"0.0.0.0\", 8080):\n",{"type":42,"tag":243,"props":592,"children":593},{"class":245,"line":344},[594],{"type":42,"tag":243,"props":595,"children":596},{},[597],{"type":48,"value":598},"        await asyncio.Future()\n",{"type":42,"tag":243,"props":600,"children":601},{"class":245,"line":353},[602],{"type":42,"tag":243,"props":603,"children":604},{"emptyLinePlaceholder":268},[605],{"type":48,"value":271},{"type":42,"tag":243,"props":607,"children":608},{"class":245,"line":362},[609],{"type":42,"tag":243,"props":610,"children":611},{},[612],{"type":48,"value":613},"asyncio.run(main())\n",{"type":42,"tag":51,"props":615,"children":616},{},[617],{"type":42,"tag":109,"props":618,"children":619},{},[620],{"type":48,"value":621},"Node.js (ws)",{"type":42,"tag":57,"props":623,"children":625},{"className":388,"code":624,"language":390,"meta":66,"style":66},"const WebSocket = require(\"ws\");\nconst wss = new WebSocket.Server({ port: 8080 });\n\nwss.on(\"connection\", (ws) => {\n    ws.on(\"message\", async (data) => {\n        const event = JSON.parse(data);\n        if (event.type === \"prompt\") {\n            const aiResponse = await callLLM(event.voicePrompt);\n            ws.send(JSON.stringify({ type: \"text\", token: aiResponse, last: true }));\n        }\n    });\n});\n",[626],{"type":42,"tag":64,"props":627,"children":628},{"__ignoreMap":66},[629,637,645,652,660,668,676,684,692,700,708,715],{"type":42,"tag":243,"props":630,"children":631},{"class":245,"line":246},[632],{"type":42,"tag":243,"props":633,"children":634},{},[635],{"type":48,"value":636},"const WebSocket = require(\"ws\");\n",{"type":42,"tag":243,"props":638,"children":639},{"class":245,"line":255},[640],{"type":42,"tag":243,"props":641,"children":642},{},[643],{"type":48,"value":644},"const wss = new WebSocket.Server({ port: 8080 });\n",{"type":42,"tag":243,"props":646,"children":647},{"class":245,"line":264},[648],{"type":42,"tag":243,"props":649,"children":650},{"emptyLinePlaceholder":268},[651],{"type":48,"value":271},{"type":42,"tag":243,"props":653,"children":654},{"class":245,"line":274},[655],{"type":42,"tag":243,"props":656,"children":657},{},[658],{"type":48,"value":659},"wss.on(\"connection\", (ws) => {\n",{"type":42,"tag":243,"props":661,"children":662},{"class":245,"line":283},[663],{"type":42,"tag":243,"props":664,"children":665},{},[666],{"type":48,"value":667},"    ws.on(\"message\", async (data) => {\n",{"type":42,"tag":243,"props":669,"children":670},{"class":245,"line":291},[671],{"type":42,"tag":243,"props":672,"children":673},{},[674],{"type":48,"value":675},"        const event = JSON.parse(data);\n",{"type":42,"tag":243,"props":677,"children":678},{"class":245,"line":30},[679],{"type":42,"tag":243,"props":680,"children":681},{},[682],{"type":48,"value":683},"        if (event.type === \"prompt\") {\n",{"type":42,"tag":243,"props":685,"children":686},{"class":245,"line":308},[687],{"type":42,"tag":243,"props":688,"children":689},{},[690],{"type":48,"value":691},"            const aiResponse = await callLLM(event.voicePrompt);\n",{"type":42,"tag":243,"props":693,"children":694},{"class":245,"line":317},[695],{"type":42,"tag":243,"props":696,"children":697},{},[698],{"type":48,"value":699},"            ws.send(JSON.stringify({ type: \"text\", token: aiResponse, last: true }));\n",{"type":42,"tag":243,"props":701,"children":702},{"class":245,"line":326},[703],{"type":42,"tag":243,"props":704,"children":705},{},[706],{"type":48,"value":707},"        }\n",{"type":42,"tag":243,"props":709,"children":710},{"class":245,"line":335},[711],{"type":42,"tag":243,"props":712,"children":713},{},[714],{"type":48,"value":465},{"type":42,"tag":243,"props":716,"children":717},{"class":245,"line":344},[718],{"type":42,"tag":243,"props":719,"children":720},{},[721],{"type":48,"value":481},{"type":42,"tag":723,"props":724,"children":725},"blockquote",{},[726],{"type":42,"tag":51,"props":727,"children":728},{},[729,734,736,742],{"type":42,"tag":109,"props":730,"children":731},{},[732],{"type":48,"value":733},"Security:",{"type":48,"value":735}," The ",{"type":42,"tag":64,"props":737,"children":739},{"className":738},[],[740],{"type":48,"value":741},"voicePrompt",{"type":48,"value":743}," field contains ASR-transcribed caller speech — it is untrusted external input. When passing to an LLM, isolate it as user input within a structured system prompt. Implement topic boundaries and output filtering to prevent the LLM from disclosing system instructions or speaking inappropriate content. ConversationRelay is a pure transport layer with no built-in content safety — any LLM output is spoken to the caller verbatim.",{"type":42,"tag":70,"props":745,"children":746},{},[],{"type":42,"tag":43,"props":748,"children":750},{"id":749},"key-patterns",[751],{"type":48,"value":752},"Key Patterns",{"type":42,"tag":754,"props":755,"children":757},"h3",{"id":756},"websocket-message-types",[758],{"type":48,"value":759},"WebSocket Message Types",{"type":42,"tag":51,"props":761,"children":762},{},[763],{"type":42,"tag":109,"props":764,"children":765},{},[766],{"type":48,"value":767},"Received from Twilio:",{"type":42,"tag":769,"props":770,"children":771},"table",{},[772,796],{"type":42,"tag":773,"props":774,"children":775},"thead",{},[776],{"type":42,"tag":777,"props":778,"children":779},"tr",{},[780,786,791],{"type":42,"tag":781,"props":782,"children":783},"th",{},[784],{"type":48,"value":785},"Type",{"type":42,"tag":781,"props":787,"children":788},{},[789],{"type":48,"value":790},"When",{"type":42,"tag":781,"props":792,"children":793},{},[794],{"type":48,"value":795},"Key fields",{"type":42,"tag":797,"props":798,"children":799},"tbody",{},[800,835,862,884,910],{"type":42,"tag":777,"props":801,"children":802},{},[803,813,818],{"type":42,"tag":804,"props":805,"children":806},"td",{},[807],{"type":42,"tag":64,"props":808,"children":810},{"className":809},[],[811],{"type":48,"value":812},"connected",{"type":42,"tag":804,"props":814,"children":815},{},[816],{"type":48,"value":817},"WebSocket opened",{"type":42,"tag":804,"props":819,"children":820},{},[821,827,829],{"type":42,"tag":64,"props":822,"children":824},{"className":823},[],[825],{"type":48,"value":826},"callSid",{"type":48,"value":828},", ",{"type":42,"tag":64,"props":830,"children":832},{"className":831},[],[833],{"type":48,"value":834},"streamSid",{"type":42,"tag":777,"props":836,"children":837},{},[838,847,852],{"type":42,"tag":804,"props":839,"children":840},{},[841],{"type":42,"tag":64,"props":842,"children":844},{"className":843},[],[845],{"type":48,"value":846},"prompt",{"type":42,"tag":804,"props":848,"children":849},{},[850],{"type":48,"value":851},"User finished speaking",{"type":42,"tag":804,"props":853,"children":854},{},[855,860],{"type":42,"tag":64,"props":856,"children":858},{"className":857},[],[859],{"type":48,"value":741},{"type":48,"value":861}," (transcript)",{"type":42,"tag":777,"props":863,"children":864},{},[865,874,879],{"type":42,"tag":804,"props":866,"children":867},{},[868],{"type":42,"tag":64,"props":869,"children":871},{"className":870},[],[872],{"type":48,"value":873},"interrupt",{"type":42,"tag":804,"props":875,"children":876},{},[877],{"type":48,"value":878},"User interrupted TTS",{"type":42,"tag":804,"props":880,"children":881},{},[882],{"type":48,"value":883},"—",{"type":42,"tag":777,"props":885,"children":886},{},[887,896,901],{"type":42,"tag":804,"props":888,"children":889},{},[890],{"type":42,"tag":64,"props":891,"children":893},{"className":892},[],[894],{"type":48,"value":895},"dtmf",{"type":42,"tag":804,"props":897,"children":898},{},[899],{"type":48,"value":900},"User pressed keypad key",{"type":42,"tag":804,"props":902,"children":903},{},[904],{"type":42,"tag":64,"props":905,"children":907},{"className":906},[],[908],{"type":48,"value":909},"digit",{"type":42,"tag":777,"props":911,"children":912},{},[913,922,927],{"type":42,"tag":804,"props":914,"children":915},{},[916],{"type":42,"tag":64,"props":917,"children":919},{"className":918},[],[920],{"type":48,"value":921},"error",{"type":42,"tag":804,"props":923,"children":924},{},[925],{"type":48,"value":926},"An error occurred",{"type":42,"tag":804,"props":928,"children":929},{},[930],{"type":42,"tag":64,"props":931,"children":933},{"className":932},[],[934],{"type":48,"value":935},"description",{"type":42,"tag":51,"props":937,"children":938},{},[939],{"type":42,"tag":109,"props":940,"children":941},{},[942],{"type":48,"value":943},"Sent to Twilio:",{"type":42,"tag":769,"props":945,"children":946},{},[947,966],{"type":42,"tag":773,"props":948,"children":949},{},[950],{"type":42,"tag":777,"props":951,"children":952},{},[953,957,962],{"type":42,"tag":781,"props":954,"children":955},{},[956],{"type":48,"value":785},{"type":42,"tag":781,"props":958,"children":959},{},[960],{"type":48,"value":961},"Purpose",{"type":42,"tag":781,"props":963,"children":964},{},[965],{"type":48,"value":795},{"type":42,"tag":797,"props":967,"children":968},{},[969,1004,1024],{"type":42,"tag":777,"props":970,"children":971},{},[972,980,985],{"type":42,"tag":804,"props":973,"children":974},{},[975],{"type":42,"tag":64,"props":976,"children":978},{"className":977},[],[979],{"type":48,"value":48},{"type":42,"tag":804,"props":981,"children":982},{},[983],{"type":48,"value":984},"Send TTS response",{"type":42,"tag":804,"props":986,"children":987},{},[988,994,996,1002],{"type":42,"tag":64,"props":989,"children":991},{"className":990},[],[992],{"type":48,"value":993},"token",{"type":48,"value":995}," (text), ",{"type":42,"tag":64,"props":997,"children":999},{"className":998},[],[1000],{"type":48,"value":1001},"last",{"type":48,"value":1003}," (bool)",{"type":42,"tag":777,"props":1005,"children":1006},{},[1007,1015,1020],{"type":42,"tag":804,"props":1008,"children":1009},{},[1010],{"type":42,"tag":64,"props":1011,"children":1013},{"className":1012},[],[1014],{"type":48,"value":873},{"type":42,"tag":804,"props":1016,"children":1017},{},[1018],{"type":48,"value":1019},"Stop current TTS",{"type":42,"tag":804,"props":1021,"children":1022},{},[1023],{"type":48,"value":883},{"type":42,"tag":777,"props":1025,"children":1026},{},[1027,1036,1041],{"type":42,"tag":804,"props":1028,"children":1029},{},[1030],{"type":42,"tag":64,"props":1031,"children":1033},{"className":1032},[],[1034],{"type":48,"value":1035},"end",{"type":42,"tag":804,"props":1037,"children":1038},{},[1039],{"type":48,"value":1040},"Hang up the call",{"type":42,"tag":804,"props":1042,"children":1043},{},[1044],{"type":42,"tag":64,"props":1045,"children":1047},{"className":1046},[],[1048],{"type":48,"value":1049},"reason",{"type":42,"tag":754,"props":1051,"children":1053},{"id":1052},"stream-llm-responses-token-by-token",[1054],{"type":48,"value":1055},"Stream LLM Responses Token-by-Token",{"type":42,"tag":51,"props":1057,"children":1058},{},[1059],{"type":48,"value":1060},"Lower latency by streaming as the LLM generates output — Twilio starts speaking before the full response is ready.",{"type":42,"tag":51,"props":1062,"children":1063},{},[1064],{"type":42,"tag":109,"props":1065,"children":1066},{},[1067],{"type":48,"value":1068},"Python",{"type":42,"tag":57,"props":1070,"children":1072},{"className":235,"code":1071,"language":237,"meta":66,"style":66},"async for chunk in llm_stream:\n    await websocket.send(json.dumps({\"type\": \"text\", \"token\": chunk, \"last\": False}))\nawait websocket.send(json.dumps({\"type\": \"text\", \"token\": \"\", \"last\": True}))\n",[1073],{"type":42,"tag":64,"props":1074,"children":1075},{"__ignoreMap":66},[1076,1084,1092],{"type":42,"tag":243,"props":1077,"children":1078},{"class":245,"line":246},[1079],{"type":42,"tag":243,"props":1080,"children":1081},{},[1082],{"type":48,"value":1083},"async for chunk in llm_stream:\n",{"type":42,"tag":243,"props":1085,"children":1086},{"class":245,"line":255},[1087],{"type":42,"tag":243,"props":1088,"children":1089},{},[1090],{"type":48,"value":1091},"    await websocket.send(json.dumps({\"type\": \"text\", \"token\": chunk, \"last\": False}))\n",{"type":42,"tag":243,"props":1093,"children":1094},{"class":245,"line":264},[1095],{"type":42,"tag":243,"props":1096,"children":1097},{},[1098],{"type":48,"value":1099},"await websocket.send(json.dumps({\"type\": \"text\", \"token\": \"\", \"last\": True}))\n",{"type":42,"tag":51,"props":1101,"children":1102},{},[1103],{"type":42,"tag":109,"props":1104,"children":1105},{},[1106],{"type":48,"value":1107},"Node.js",{"type":42,"tag":57,"props":1109,"children":1111},{"className":388,"code":1110,"language":390,"meta":66,"style":66},"for await (const chunk of llmStream) {\n    ws.send(JSON.stringify({ type: \"text\", token: chunk, last: false }));\n}\nws.send(JSON.stringify({ type: \"text\", token: \"\", last: true }));\n",[1112],{"type":42,"tag":64,"props":1113,"children":1114},{"__ignoreMap":66},[1115,1123,1131,1139],{"type":42,"tag":243,"props":1116,"children":1117},{"class":245,"line":246},[1118],{"type":42,"tag":243,"props":1119,"children":1120},{},[1121],{"type":48,"value":1122},"for await (const chunk of llmStream) {\n",{"type":42,"tag":243,"props":1124,"children":1125},{"class":245,"line":255},[1126],{"type":42,"tag":243,"props":1127,"children":1128},{},[1129],{"type":48,"value":1130},"    ws.send(JSON.stringify({ type: \"text\", token: chunk, last: false }));\n",{"type":42,"tag":243,"props":1132,"children":1133},{"class":245,"line":264},[1134],{"type":42,"tag":243,"props":1135,"children":1136},{},[1137],{"type":48,"value":1138},"}\n",{"type":42,"tag":243,"props":1140,"children":1141},{"class":245,"line":274},[1142],{"type":42,"tag":243,"props":1143,"children":1144},{},[1145],{"type":48,"value":1146},"ws.send(JSON.stringify({ type: \"text\", token: \"\", last: true }));\n",{"type":42,"tag":754,"props":1148,"children":1150},{"id":1149},"voice-configuration",[1151],{"type":48,"value":1152},"Voice Configuration",{"type":42,"tag":51,"props":1154,"children":1155},{},[1156],{"type":42,"tag":109,"props":1157,"children":1158},{},[1159],{"type":48,"value":1068},{"type":42,"tag":57,"props":1161,"children":1163},{"className":235,"code":1162,"language":237,"meta":66,"style":66},"connect.conversation_relay(\n    url=\"wss:\u002F\u002Fyourapp.com\u002Fws\u002Fvoice\",\n    voice=\"en-US-Neural2-F\",\n    language=\"en-US\",\n    transcription_provider=\"deepgram\",\n    speech_model=\"nova-2-phonecall\",\n    interrupt_by_dtmf=True,\n)\n",[1164],{"type":42,"tag":64,"props":1165,"children":1166},{"__ignoreMap":66},[1167,1175,1183,1191,1199,1207,1215,1223],{"type":42,"tag":243,"props":1168,"children":1169},{"class":245,"line":246},[1170],{"type":42,"tag":243,"props":1171,"children":1172},{},[1173],{"type":48,"value":1174},"connect.conversation_relay(\n",{"type":42,"tag":243,"props":1176,"children":1177},{"class":245,"line":255},[1178],{"type":42,"tag":243,"props":1179,"children":1180},{},[1181],{"type":48,"value":1182},"    url=\"wss:\u002F\u002Fyourapp.com\u002Fws\u002Fvoice\",\n",{"type":42,"tag":243,"props":1184,"children":1185},{"class":245,"line":264},[1186],{"type":42,"tag":243,"props":1187,"children":1188},{},[1189],{"type":48,"value":1190},"    voice=\"en-US-Neural2-F\",\n",{"type":42,"tag":243,"props":1192,"children":1193},{"class":245,"line":274},[1194],{"type":42,"tag":243,"props":1195,"children":1196},{},[1197],{"type":48,"value":1198},"    language=\"en-US\",\n",{"type":42,"tag":243,"props":1200,"children":1201},{"class":245,"line":283},[1202],{"type":42,"tag":243,"props":1203,"children":1204},{},[1205],{"type":48,"value":1206},"    transcription_provider=\"deepgram\",\n",{"type":42,"tag":243,"props":1208,"children":1209},{"class":245,"line":291},[1210],{"type":42,"tag":243,"props":1211,"children":1212},{},[1213],{"type":48,"value":1214},"    speech_model=\"nova-2-phonecall\",\n",{"type":42,"tag":243,"props":1216,"children":1217},{"class":245,"line":30},[1218],{"type":42,"tag":243,"props":1219,"children":1220},{},[1221],{"type":48,"value":1222},"    interrupt_by_dtmf=True,\n",{"type":42,"tag":243,"props":1224,"children":1225},{"class":245,"line":308},[1226],{"type":42,"tag":243,"props":1227,"children":1228},{},[1229],{"type":48,"value":1230},")\n",{"type":42,"tag":51,"props":1232,"children":1233},{},[1234],{"type":42,"tag":109,"props":1235,"children":1236},{},[1237],{"type":48,"value":1107},{"type":42,"tag":57,"props":1239,"children":1241},{"className":388,"code":1240,"language":390,"meta":66,"style":66},"connect.conversationRelay({\n    url: \"wss:\u002F\u002Fyourapp.com\u002Fws\u002Fvoice\",\n    voice: \"en-US-Neural2-F\",\n    language: \"en-US\",\n    transcriptionProvider: \"deepgram\",\n    speechModel: \"nova-2-phonecall\",\n    interruptByDtmf: true,\n});\n",[1242],{"type":42,"tag":64,"props":1243,"children":1244},{"__ignoreMap":66},[1245,1253,1261,1269,1277,1285,1293,1301],{"type":42,"tag":243,"props":1246,"children":1247},{"class":245,"line":246},[1248],{"type":42,"tag":243,"props":1249,"children":1250},{},[1251],{"type":48,"value":1252},"connect.conversationRelay({\n",{"type":42,"tag":243,"props":1254,"children":1255},{"class":245,"line":255},[1256],{"type":42,"tag":243,"props":1257,"children":1258},{},[1259],{"type":48,"value":1260},"    url: \"wss:\u002F\u002Fyourapp.com\u002Fws\u002Fvoice\",\n",{"type":42,"tag":243,"props":1262,"children":1263},{"class":245,"line":264},[1264],{"type":42,"tag":243,"props":1265,"children":1266},{},[1267],{"type":48,"value":1268},"    voice: \"en-US-Neural2-F\",\n",{"type":42,"tag":243,"props":1270,"children":1271},{"class":245,"line":274},[1272],{"type":42,"tag":243,"props":1273,"children":1274},{},[1275],{"type":48,"value":1276},"    language: \"en-US\",\n",{"type":42,"tag":243,"props":1278,"children":1279},{"class":245,"line":283},[1280],{"type":42,"tag":243,"props":1281,"children":1282},{},[1283],{"type":48,"value":1284},"    transcriptionProvider: \"deepgram\",\n",{"type":42,"tag":243,"props":1286,"children":1287},{"class":245,"line":291},[1288],{"type":42,"tag":243,"props":1289,"children":1290},{},[1291],{"type":48,"value":1292},"    speechModel: \"nova-2-phonecall\",\n",{"type":42,"tag":243,"props":1294,"children":1295},{"class":245,"line":30},[1296],{"type":42,"tag":243,"props":1297,"children":1298},{},[1299],{"type":48,"value":1300},"    interruptByDtmf: true,\n",{"type":42,"tag":243,"props":1302,"children":1303},{"class":245,"line":308},[1304],{"type":42,"tag":243,"props":1305,"children":1306},{},[1307],{"type":48,"value":481},{"type":42,"tag":70,"props":1309,"children":1310},{},[],{"type":42,"tag":43,"props":1312,"children":1314},{"id":1313},"cannot",[1315],{"type":48,"value":1316},"CANNOT",{"type":42,"tag":80,"props":1318,"children":1319},{},[1320,1338,1362,1372,1390,1408,1418,1428,1438,1471,1489,1499,1509,1525],{"type":42,"tag":84,"props":1321,"children":1322},{},[1323,1328,1330,1336],{"type":42,"tag":109,"props":1324,"children":1325},{},[1326],{"type":48,"value":1327},"No raw audio access",{"type":48,"value":1329}," — Text in, text out only. For raw audio, use ",{"type":42,"tag":64,"props":1331,"children":1333},{"className":1332},[],[1334],{"type":48,"value":1335},"\u003CConnect>\u003CStream>",{"type":48,"value":1337}," (Media Streams).",{"type":42,"tag":84,"props":1339,"children":1340},{},[1341,1346,1348,1353,1354,1360],{"type":42,"tag":109,"props":1342,"children":1343},{},[1344],{"type":48,"value":1345},"Cannot mix with Media Streams",{"type":48,"value":1347}," — ",{"type":42,"tag":64,"props":1349,"children":1351},{"className":1350},[],[1352],{"type":48,"value":1335},{"type":48,"value":131},{"type":42,"tag":64,"props":1355,"children":1357},{"className":1356},[],[1358],{"type":48,"value":1359},"\u003CConnect>\u003CConversationRelay>",{"type":48,"value":1361}," are mutually exclusive on the same call. No error — one is silently ignored.",{"type":42,"tag":84,"props":1363,"children":1364},{},[1365,1370],{"type":42,"tag":109,"props":1366,"children":1367},{},[1368],{"type":48,"value":1369},"No custom STT\u002FTTS engines",{"type":48,"value":1371}," — Limited to Deepgram + Google (STT) and Deepgram + Amazon Polly + Google + ElevenLabs (TTS).",{"type":42,"tag":84,"props":1373,"children":1374},{},[1375,1380,1382,1388],{"type":42,"tag":109,"props":1376,"children":1377},{},[1378],{"type":48,"value":1379},"No mid-session voice\u002Fprovider changes",{"type":48,"value":1381}," — Voice and provider are set at TwiML time. Only ",{"type":42,"tag":64,"props":1383,"children":1385},{"className":1384},[],[1386],{"type":48,"value":1387},"language",{"type":48,"value":1389}," can be switched mid-session via WebSocket message.",{"type":42,"tag":84,"props":1391,"children":1392},{},[1393,1398,1400,1406],{"type":42,"tag":109,"props":1394,"children":1395},{},[1396],{"type":48,"value":1397},"No WebSocket auto-reconnection",{"type":48,"value":1399}," — If the WebSocket drops, the call disconnects. Implement recovery via ",{"type":42,"tag":64,"props":1401,"children":1403},{"className":1402},[],[1404],{"type":48,"value":1405},"\u003CConnect action>",{"type":48,"value":1407}," URL.",{"type":42,"tag":84,"props":1409,"children":1410},{},[1411,1416],{"type":42,"tag":109,"props":1412,"children":1413},{},[1414],{"type":48,"value":1415},"Voice only",{"type":48,"value":1417}," — No SMS\u002Fmessaging support. For omnichannel, use Conversation Orchestrator.",{"type":42,"tag":84,"props":1419,"children":1420},{},[1421,1426],{"type":42,"tag":109,"props":1422,"children":1423},{},[1424],{"type":48,"value":1425},"No built-in memory or context",{"type":48,"value":1427}," — BYO conversation history and context management.",{"type":42,"tag":84,"props":1429,"children":1430},{},[1431,1436],{"type":42,"tag":109,"props":1432,"children":1433},{},[1434],{"type":48,"value":1435},"No LLM integration",{"type":48,"value":1437}," — Pure transport layer. You bring your own LLM via the WebSocket server.",{"type":42,"tag":84,"props":1439,"children":1440},{},[1441,1446,1447,1453,1455,1461,1463,1469],{"type":42,"tag":109,"props":1442,"children":1443},{},[1444],{"type":48,"value":1445},"No server-side recording via REST API",{"type":48,"value":1347},{"type":42,"tag":64,"props":1448,"children":1450},{"className":1449},[],[1451],{"type":48,"value":1452},"record:true",{"type":48,"value":1454}," on the Calls API is silently ignored. Must use ",{"type":42,"tag":64,"props":1456,"children":1458},{"className":1457},[],[1459],{"type":48,"value":1460},"\u003CStart>\u003CRecording>",{"type":48,"value":1462}," before ",{"type":42,"tag":64,"props":1464,"children":1466},{"className":1465},[],[1467],{"type":48,"value":1468},"\u003CConnect>",{"type":48,"value":1470}," in TwiML.",{"type":42,"tag":84,"props":1472,"children":1473},{},[1474,1479,1481,1487],{"type":42,"tag":109,"props":1475,"children":1476},{},[1477],{"type":48,"value":1478},"Not PCI compliant with Voice Intelligence v2",{"type":48,"value":1480}," — Do not enable ",{"type":42,"tag":64,"props":1482,"children":1484},{"className":1483},[],[1485],{"type":48,"value":1486},"intelligenceService",{"type":48,"value":1488}," in PCI workflows.",{"type":42,"tag":84,"props":1490,"children":1491},{},[1492,1497],{"type":42,"tag":109,"props":1493,"children":1494},{},[1495],{"type":48,"value":1496},"ElevenLabs requires account enablement",{"type":48,"value":1498}," — Accounts without ElevenLabs access get error 64101. Voice IDs (not human-readable names) are required.",{"type":42,"tag":84,"props":1500,"children":1501},{},[1502,1507],{"type":42,"tag":109,"props":1503,"children":1504},{},[1505],{"type":48,"value":1506},"Cannot use ConversationRelay without onboarding",{"type":48,"value":1508}," — Not available immediately on a new account",{"type":42,"tag":84,"props":1510,"children":1511},{},[1512,1517,1519,1524],{"type":42,"tag":109,"props":1513,"children":1514},{},[1515],{"type":48,"value":1516},"Cannot use non-TLS WebSocket",{"type":48,"value":1518}," — Server must be reachable via ",{"type":42,"tag":64,"props":1520,"children":1522},{"className":1521},[],[1523],{"type":48,"value":156},{"type":48,"value":158},{"type":42,"tag":84,"props":1526,"children":1527},{},[1528,1539,1541,1546],{"type":42,"tag":109,"props":1529,"children":1530},{},[1531,1533],{"type":48,"value":1532},"Cannot stream audio without ",{"type":42,"tag":64,"props":1534,"children":1536},{"className":1535},[],[1537],{"type":48,"value":1538},"last: true",{"type":48,"value":1540}," — Twilio won't play audio until it sees a ",{"type":42,"tag":64,"props":1542,"children":1544},{"className":1543},[],[1545],{"type":48,"value":1538},{"type":48,"value":1547}," token in the stream",{"type":42,"tag":70,"props":1549,"children":1550},{},[],{"type":42,"tag":43,"props":1552,"children":1554},{"id":1553},"next-steps",[1555],{"type":48,"value":1556},"Next Steps",{"type":42,"tag":80,"props":1558,"children":1559},{},[1560,1575],{"type":42,"tag":84,"props":1561,"children":1562},{},[1563,1568,1570],{"type":42,"tag":109,"props":1564,"children":1565},{},[1566],{"type":48,"value":1567},"Place outbound calls:",{"type":48,"value":1569}," ",{"type":42,"tag":64,"props":1571,"children":1573},{"className":1572},[],[1574],{"type":48,"value":174},{"type":42,"tag":84,"props":1576,"children":1577},{},[1578,1583,1584],{"type":42,"tag":109,"props":1579,"children":1580},{},[1581],{"type":48,"value":1582},"Standard IVR without AI:",{"type":48,"value":1569},{"type":42,"tag":64,"props":1585,"children":1587},{"className":1586},[],[1588],{"type":48,"value":1589},"twilio-voice-twiml",{"type":42,"tag":1591,"props":1592,"children":1593},"style",{},[1594],{"type":48,"value":1595},"html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"items":1597,"total":1775},[1598,1613,1631,1642,1654,1667,1684,1700,1716,1729,1745,1763],{"slug":94,"name":94,"fn":1599,"description":1600,"org":1601,"tags":1602,"stars":26,"repoUrl":27,"updatedAt":1612},"configure Twilio accounts and credentials","Create and configure a Twilio account from scratch. Covers free trial signup, trial limitations, getting credentials (Account SID and Auth Token), buying a phone number, verifying recipient numbers for trial use, SDK installation, first API call, subaccount management (creation, inheritance, credential isolation, limits), and enabling specific products (AI Assistants, Conversations, Verify, ConversationRelay, WhatsApp). Use this skill before any other Twilio skill if you do not yet have a Twilio account or need to enable a product. For Organization-level governance (SSO, SCIM, multi-team), see `twilio-organizations-setup`.\n",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[1603,1606,1609],{"name":1604,"slug":1605,"type":15},"API Development","api-development",{"name":1607,"slug":1608,"type":15},"Communications","communications",{"name":1610,"slug":1611,"type":15},"SMS","sms","2026-08-01T05:43:28.968968",{"slug":1614,"name":1614,"fn":1615,"description":1616,"org":1617,"tags":1618,"stars":26,"repoUrl":27,"updatedAt":1630},"twilio-agent-augmentation-architect","augment human agents with AI intelligence","Planning skill for augmenting human agents with real-time AI intelligence. Qualifies the developer's use case across coaching, compliance, QA, and routing to recommend the right Conversation Intelligence + Conversation Memory + TaskRouter architecture. Handles both \"I want to add AI coaching to my call center\" and \"configure Conversation Intelligence operators for script adherence.\"\n",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[1619,1620,1623,1626,1629],{"name":17,"slug":18,"type":15},{"name":1621,"slug":1622,"type":15},"AI","ai",{"name":1624,"slug":1625,"type":15},"Coaching","coaching",{"name":1627,"slug":1628,"type":15},"QA","qa",{"name":9,"slug":8,"type":15},"2026-07-17T06:07:58.250609",{"slug":1632,"name":1632,"fn":1633,"description":1634,"org":1635,"tags":1636,"stars":26,"repoUrl":27,"updatedAt":1641},"twilio-agent-connect","connect AI agents to Twilio channels","Connect third-party AI agents (OpenAI, Bedrock, LangChain, Microsoft Foundry) to Twilio's communication channels using the Twilio Agent Connect SDK. Covers identity resolution, memory and context management via Conversation Memory, conversation orchestration via Conversation Orchestrator, multi-channel handling (Voice, SMS, RCS, WhatsApp, Chat), and AI-to-human escalation. Use this skill when integrating an existing LLM agent with Twilio services.\n",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[1637,1638,1639,1640],{"name":17,"slug":18,"type":15},{"name":1604,"slug":1605,"type":15},{"name":1607,"slug":1608,"type":15},{"name":9,"slug":8,"type":15},"2026-07-17T06:06:05.217098",{"slug":1643,"name":1643,"fn":1644,"description":1645,"org":1646,"tags":1647,"stars":26,"repoUrl":27,"updatedAt":1653},"twilio-ai-agent-architect","plan Twilio conversational AI agents","Planning skill for AI-powered conversational agents. Qualifies the developer's use case across outcome sophistication, entry point, and customer profile to recommend the right Twilio Conversations architecture and implementation skills. Handles both high-level requests (\"build me a voice AI assistant\") and specific ones (\"integrate ConversationRelay with my OpenAI backend\").\n",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[1648,1649,1652],{"name":17,"slug":18,"type":15},{"name":1650,"slug":1651,"type":15},"Architecture","architecture",{"name":9,"slug":8,"type":15},"2026-07-17T06:07:48.883723",{"slug":1655,"name":1655,"fn":1656,"description":1657,"org":1658,"tags":1659,"stars":26,"repoUrl":27,"updatedAt":1666},"twilio-call-recordings","record and manage Twilio voice calls","Record Twilio voice calls correctly. Covers the critical distinction between Record verb (voicemail) and Dial record (call recording), dual-channel for QA, mid-call pause for PCI, Conference recording, and the ConversationRelay workaround. Use this skill whenever you need to capture call audio for compliance, QA, or analytics.\n",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[1660,1661,1664,1665],{"name":20,"slug":21,"type":15},{"name":1662,"slug":1663,"type":15},"Compliance","compliance",{"name":1627,"slug":1628,"type":15},{"name":9,"slug":8,"type":15},"2026-07-17T06:07:55.268412",{"slug":1668,"name":1668,"fn":1669,"description":1670,"org":1671,"tags":1672,"stars":26,"repoUrl":27,"updatedAt":1683},"twilio-cli-reference","manage Twilio resources via CLI","Twilio CLI reference for managing Twilio resources from the terminal. Covers installation, credential profiles, phone number provisioning, sending SMS and email, webhook configuration, local development with a tunneling service, debugging with watch and logs, serverless deployment, and plugin ecosystem. Use when the developer asks to \"just do it\", \"set this up\", \"run a command\", mentions \"CLI\", \"command line\", or \"terminal\", or when an AI agent can execute a task directly instead of writing application code.\n",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[1673,1676,1679,1682],{"name":1674,"slug":1675,"type":15},"CLI","cli",{"name":1677,"slug":1678,"type":15},"Local Development","local-development",{"name":1680,"slug":1681,"type":15},"Operations","operations",{"name":9,"slug":8,"type":15},"2026-07-17T06:07:54.925664",{"slug":1685,"name":1685,"fn":1686,"description":1687,"org":1688,"tags":1689,"stars":26,"repoUrl":27,"updatedAt":1699},"twilio-compliance-onboarding","manage Twilio messaging and voice compliance","Registrations required BEFORE Twilio traffic works. Covers messaging programs (A2P 10DLC, toll-free verification, WhatsApp WABA, RCS, short code, alphanumeric sender) and voice trust programs (STIR\u002FSHAKEN, Voice Integrity, Branded Calling, CNAM). Each number\u002Fsender type has its own program — registration blocks traffic until complete.\n",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[1690,1691,1694,1695,1696],{"name":1662,"slug":1663,"type":15},{"name":1692,"slug":1693,"type":15},"Messaging","messaging",{"name":1610,"slug":1611,"type":15},{"name":9,"slug":8,"type":15},{"name":1697,"slug":1698,"type":15},"WhatsApp","whatsapp","2026-07-17T06:05:47.897229",{"slug":1701,"name":1701,"fn":1702,"description":1703,"org":1704,"tags":1705,"stars":26,"repoUrl":27,"updatedAt":1715},"twilio-compliance-traffic","ensure compliance for Twilio messaging traffic","Rules you must follow for Twilio messaging and voice traffic. Covers TCPA (consent tiers, quiet hours, DNC), GDPR (EU consent, right to deletion), PCI DSS (payment recording, Pay verb), HIPAA (BAA, PHI), FDCPA (debt collection limits), CAN-SPAM, WhatsApp policies, SHAKEN\u002FSTIR, and consent management patterns. Use this skill proactively when developers have working traffic to ensure they follow the rules.\n",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[1706,1707,1708,1711,1714],{"name":1662,"slug":1663,"type":15},{"name":1692,"slug":1693,"type":15},{"name":1709,"slug":1710,"type":15},"Regulatory Compliance","regulatory-compliance",{"name":1712,"slug":1713,"type":15},"Security","security",{"name":9,"slug":8,"type":15},"2026-07-17T06:07:55.952779",{"slug":1717,"name":1717,"fn":1718,"description":1719,"org":1720,"tags":1721,"stars":26,"repoUrl":27,"updatedAt":1728},"twilio-conference-calls","build multi-party calls with Twilio Conference","Build multi-party calls using Twilio Conference. Covers warm transfer, cold transfer, coaching (whisper), hold vs mute, participant modes, and supervisor barge. Use this skill for any contact center, support line, or scenario requiring transfers, holds, or multi-party calls.\n",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[1722,1723,1724,1727],{"name":20,"slug":21,"type":15},{"name":1607,"slug":1608,"type":15},{"name":1725,"slug":1726,"type":15},"Meetings","meetings",{"name":9,"slug":8,"type":15},"2026-07-17T06:07:55.603708",{"slug":1730,"name":1730,"fn":1731,"description":1732,"org":1733,"tags":1734,"stars":26,"repoUrl":27,"updatedAt":1744},"twilio-content-template-builder","create and send message templates with Twilio","Create, manage, and send message templates using Twilio's Content API. Covers template creation for WhatsApp, SMS, RCS, and MMS; variable usage; WhatsApp Meta approval; and sending templates via ContentSid. Use this skill when building structured messages that require pre-approval or consistent formatting across channels.\n",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[1735,1738,1739,1740,1743],{"name":1736,"slug":1737,"type":15},"Email","email",{"name":1692,"slug":1693,"type":15},{"name":1610,"slug":1611,"type":15},{"name":1741,"slug":1742,"type":15},"Templates","templates",{"name":9,"slug":8,"type":15},"2026-07-17T06:04:26.637309",{"slug":1746,"name":1746,"fn":1747,"description":1748,"org":1749,"tags":1750,"stars":26,"repoUrl":27,"updatedAt":1762},"twilio-conversation-intelligence","build conversation intelligence pipelines","Twilio Conversation Intelligence development guide. Use when building real-time or post-call conversation analysis, language operator pipelines, sentiment analysis, agent assist, cross-channel analytics, or querying aggregated conversation insights (sentiment trends, escalation rates, dashboards).",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[1751,1752,1755,1758,1761],{"name":17,"slug":18,"type":15},{"name":1753,"slug":1754,"type":15},"Analytics","analytics",{"name":1756,"slug":1757,"type":15},"Monitoring","monitoring",{"name":1759,"slug":1760,"type":15},"NLP","nlp",{"name":9,"slug":8,"type":15},"2026-07-17T06:07:52.545387",{"slug":1764,"name":1764,"fn":1765,"description":1766,"org":1767,"tags":1768,"stars":26,"repoUrl":27,"updatedAt":1774},"twilio-conversation-memory","manage conversation memory with Twilio","Store and retrieve conversation context using Twilio Conversation Memory. Covers Memory Store provisioning, profile management, traits, observations, conversation summaries, and semantic Recall. Use this skill to give AI agents or human agents persistent memory of conversations across sessions and channels.\n",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[1769,1770,1773],{"name":17,"slug":18,"type":15},{"name":1771,"slug":1772,"type":15},"Memory","memory",{"name":9,"slug":8,"type":15},"2026-07-17T06:04:19.526724",57,{"items":1777,"total":1775},[1778,1784,1792,1799,1805,1812,1819],{"slug":94,"name":94,"fn":1599,"description":1600,"org":1779,"tags":1780,"stars":26,"repoUrl":27,"updatedAt":1612},{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[1781,1782,1783],{"name":1604,"slug":1605,"type":15},{"name":1607,"slug":1608,"type":15},{"name":1610,"slug":1611,"type":15},{"slug":1614,"name":1614,"fn":1615,"description":1616,"org":1785,"tags":1786,"stars":26,"repoUrl":27,"updatedAt":1630},{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[1787,1788,1789,1790,1791],{"name":17,"slug":18,"type":15},{"name":1621,"slug":1622,"type":15},{"name":1624,"slug":1625,"type":15},{"name":1627,"slug":1628,"type":15},{"name":9,"slug":8,"type":15},{"slug":1632,"name":1632,"fn":1633,"description":1634,"org":1793,"tags":1794,"stars":26,"repoUrl":27,"updatedAt":1641},{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[1795,1796,1797,1798],{"name":17,"slug":18,"type":15},{"name":1604,"slug":1605,"type":15},{"name":1607,"slug":1608,"type":15},{"name":9,"slug":8,"type":15},{"slug":1643,"name":1643,"fn":1644,"description":1645,"org":1800,"tags":1801,"stars":26,"repoUrl":27,"updatedAt":1653},{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[1802,1803,1804],{"name":17,"slug":18,"type":15},{"name":1650,"slug":1651,"type":15},{"name":9,"slug":8,"type":15},{"slug":1655,"name":1655,"fn":1656,"description":1657,"org":1806,"tags":1807,"stars":26,"repoUrl":27,"updatedAt":1666},{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[1808,1809,1810,1811],{"name":20,"slug":21,"type":15},{"name":1662,"slug":1663,"type":15},{"name":1627,"slug":1628,"type":15},{"name":9,"slug":8,"type":15},{"slug":1668,"name":1668,"fn":1669,"description":1670,"org":1813,"tags":1814,"stars":26,"repoUrl":27,"updatedAt":1683},{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[1815,1816,1817,1818],{"name":1674,"slug":1675,"type":15},{"name":1677,"slug":1678,"type":15},{"name":1680,"slug":1681,"type":15},{"name":9,"slug":8,"type":15},{"slug":1685,"name":1685,"fn":1686,"description":1687,"org":1820,"tags":1821,"stars":26,"repoUrl":27,"updatedAt":1699},{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[1822,1823,1824,1825,1826],{"name":1662,"slug":1663,"type":15},{"name":1692,"slug":1693,"type":15},{"name":1610,"slug":1611,"type":15},{"name":9,"slug":8,"type":15},{"name":1697,"slug":1698,"type":15}]