Commit bcca797
[Example] 021 — Twilio Voice Agent Telephony Integration (Node.js) (#104)
## New example: Twilio Voice + Deepgram Voice Agent — AI Phone Agent
<!-- metadata
type: example
number: 021
slug: twilio-voice-agent-node
language: javascript
products: agent,stt,tts
integrations: twilio
-->
**Integration:** Twilio Voice | **Language:** Node.js | **Products:**
Voice Agent (STT + LLM + TTS)
### What this shows
- Express server bridging Twilio Media Streams to Deepgram's Voice Agent
WebSocket API (`wss://agent.deepgram.com/v1/agent/converse`)
- Bidirectional audio: caller speech → Deepgram STT → LLM → Deepgram TTS
→ caller
- Function calling (tool use) within the voice agent — demo "pizza shop"
order status lookup
- Inbound call handling via TwiML webhook + outbound call initiation via
Twilio REST API
- μ-law 8 kHz audio throughout — no server-side format conversion needed
- Barge-in support: clears Twilio audio buffer when the user interrupts
the agent
### Required secrets
- `DEEPGRAM_API_KEY`
- `TWILIO_ACCOUNT_SID`
- `TWILIO_AUTH_TOKEN`
- `TWILIO_PHONE_NUMBER`
Closes #26
---
*Built by Engineer on 2026-04-01*
Co-authored-by: examples-bot <noreply@deepgram.com>
Co-authored-by: Claude <noreply@anthropic.com>1 parent 5392afc commit bcca797
5 files changed
Lines changed: 737 additions & 0 deletions
File tree
- examples/021-twilio-voice-agent-node
- src
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
0 commit comments