{"slug": "build-a-voice-agent-that-holds-a-live-call-on-telnyx-edge-compute", "title": "Build a Voice Agent That Holds a Live Call on Telnyx Edge Compute", "summary": "Telnyx has published a code example demonstrating a voice agent built on its Edge Compute platform that can hold a live phone call. The agent answers inbound calls, streams transcription, uses Telnyx AI Inference to generate replies, and speaks them via text-to-speech, looping back to listening. The implementation uses a VoiceAgent actor keyed by call_control_id and leverages the Agent SDK's Agent class for state management and zero-credential AI inference.", "body_md": "Getting an AI agent to answer a phone call is only the beginning.\n\nThe harder part is keeping the call going.\n\nThis example builds a voice agent on Telnyx Edge Compute that answers an inbound call, speaks a greeting, listens with streaming transcription, sends the caller's speech to Telnyx AI Inference, speaks the reply with TTS, and then goes back to listening.\n\nCode: [https://github.com/team-telnyx/telnyx-code-examples/tree/main/edge-voice-agent-holds-call](https://github.com/team-telnyx/telnyx-code-examples/tree/main/edge-voice-agent-holds-call)\n\nThe core flow is:\n\n``` php\ncall.initiated\n  -> answer\ncall.answered\n  -> speak greeting\ncall.speak.ended\n  -> start transcription\ncall.transcription final\n  -> stop transcription\n  -> run LLM turn\n  -> speak reply\ncall.speak.ended\n  -> listen again\ncall.hangup\n  -> persist final call state\n```\n\nEach live call gets a `VoiceAgent`\n\nactor keyed by `call_control_id`\n\n.\n\nThat actor stores:\n\n`POST /webhooks/voice`\n\nreceives Call Control webhooks`GET /debug/call?call_control_id=<call_id>`\n\ninspects actor state`POST /debug/respond`\n\ntests an LLM turn without a live call`GET /health/liveness`\n\nand `GET /health/readiness`\n\nsupport health checksThe `VoiceAgent`\n\nextends the Agent SDK `Agent`\n\nclass from `@telnyx/edge-runtime`\n\n.\n\nIt uses:\n\n`this.messages.add()`\n\nto store caller and assistant turns`this.messages.toOpenAI()`\n\nto format history for the model`this.setState()`\n\nand `this.getState()`\n\nfor durable call state`this.env.TELNYX.ai.openai.chat.createCompletion()`\n\nfor zero-credential inference through the `[telnyx]`\n\nbindingThe model call looks like this:\n\n``` js\nconst completion = await this.env.TELNYX.ai.openai.chat.createCompletion({\n  model,\n  messages: [{ role: \"system\", content: SYSTEM_PROMPT }, ...history],\n  max_tokens: 200,\n  temperature: 0.5,\n});\n```\n\nThe webhook handler speaks the returned text through Call Control TTS.\n\nThe sample uses Call Control streaming transcription because the app owns the conversation loop.\n\nThe caller speaks. Telnyx sends a final transcript. The app stops transcription, runs the LLM turn, speaks the reply, and starts transcription again after TTS ends.\n\nThat gives you room to add your own logic:\n\n```\nnpm install\ntelnyx-edge ship\n```\n\nSet the Call Control API key as an Edge secret:\n\n```\ntelnyx-edge secret set TELNYX_API_KEY your_telnyx_api_key\n```\n\nPoint your Call Control application webhook to:\n\n```\nhttps://edge-voice-agent-holds-call-<id>.telnyxcompute.com/webhooks/voice\n```\n\nThen call the Telnyx number assigned to that Call Control application.\n\nBefore shipping this pattern for real callers, I would add:\n\nBut even as a starter, this is a useful reference for building a voice agent that can actually stay on the call.\n\nResources:", "url": "https://wpnews.pro/news/build-a-voice-agent-that-holds-a-live-call-on-telnyx-edge-compute", "canonical_source": "https://dev.to/sonam_50a41a4ced7e6b4f3fa/build-a-voice-agent-that-holds-a-live-call-on-telnyx-edge-compute-33im", "published_at": "2026-08-12 00:35:01+00:00", "updated_at": "2026-08-12 01:15:32.895720+00:00", "lang": "en", "topics": ["ai-agents", "developer-tools", "natural-language-processing", "ai-infrastructure"], "entities": ["Telnyx", "Telnyx Edge Compute", "Telnyx AI Inference", "VoiceAgent", "Agent SDK", "Call Control"], "alternates": {"html": "https://wpnews.pro/news/build-a-voice-agent-that-holds-a-live-call-on-telnyx-edge-compute", "markdown": "https://wpnews.pro/news/build-a-voice-agent-that-holds-a-live-call-on-telnyx-edge-compute.md", "text": "https://wpnews.pro/news/build-a-voice-agent-that-holds-a-live-call-on-telnyx-edge-compute.txt", "jsonld": "https://wpnews.pro/news/build-a-voice-agent-that-holds-a-live-call-on-telnyx-edge-compute.jsonld"}}