cd /news/ai-agents/build-a-voice-agent-that-holds-a-liv… · home topics ai-agents article
[ARTICLE · art-92884] src=dev.to ↗ pub= topic=ai-agents verified=true sentiment=· neutral

Build a Voice Agent That Holds a Live Call on Telnyx Edge Compute

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.

read2 min views1 publishedAug 12, 2026

Getting an AI agent to answer a phone call is only the beginning.

The harder part is keeping the call going.

This 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.

Code: https://github.com/team-telnyx/telnyx-code-examples/tree/main/edge-voice-agent-holds-call

The core flow is:

call.initiated
  -> answer
call.answered
  -> speak greeting
call.speak.ended
  -> start transcription
call.transcription final
  -> stop transcription
  -> run LLM turn
  -> speak reply
call.speak.ended
  -> listen again
call.hangup
  -> persist final call state

Each live call gets a VoiceAgent

actor keyed by call_control_id

.

That actor stores:

POST /webhooks/voice

receives Call Control webhooksGET /debug/call?call_control_id=<call_id>

inspects actor statePOST /debug/respond

tests an LLM turn without a live callGET /health/liveness

and GET /health/readiness

support health checksThe VoiceAgent

extends the Agent SDK Agent

class from @telnyx/edge-runtime

.

It uses:

this.messages.add()

to store caller and assistant turnsthis.messages.toOpenAI()

to format history for the modelthis.setState()

and this.getState()

for durable call statethis.env.TELNYX.ai.openai.chat.createCompletion()

for zero-credential inference through the [telnyx]

bindingThe model call looks like this:

const completion = await this.env.TELNYX.ai.openai.chat.createCompletion({
  model,
  messages: [{ role: "system", content: SYSTEM_PROMPT }, ...history],
  max_tokens: 200,
  temperature: 0.5,
});

The webhook handler speaks the returned text through Call Control TTS.

The sample uses Call Control streaming transcription because the app owns the conversation loop.

The 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.

That gives you room to add your own logic:

npm install
telnyx-edge ship

Set the Call Control API key as an Edge secret:

telnyx-edge secret set TELNYX_API_KEY your_telnyx_api_key

Point your Call Control application webhook to:

https://edge-voice-agent-holds-call-<id>.telnyxcompute.com/webhooks/voice

Then call the Telnyx number assigned to that Call Control application.

Before shipping this pattern for real callers, I would add:

But even as a starter, this is a useful reference for building a voice agent that can actually stay on the call.

Resources:

── more in #ai-agents 4 stories · sorted by recency
── more on @telnyx 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
Live at https://your-agent.zahid.host
Get free account → Pricing
from €0/mo · no card required
LIVE [news/build-a-voice-agent-…] indexed:0 read:2min 2026-08-12 ·