Dograh

Voice AI Architecture: How an AI Phone Agent Works

Voice AI Architecture: How an AI Phone Agent Works
TechnicalDecember 4, 2026·10 min read

Voice AI Architecture: How an AI Phone Agent Works

Abhishek Kumar
Abhishek Kumar·Co-founder, Dograh AI

Co-founder of Dograh, building the future of open-source voice AI agents. Own your voice AI stack.

An AI phone agent is a chain of parts. The carrier streams the caller's audio in, speech-to-text and turn detection work out what was said and when, a language model replies and calls tools, and text-to-speech speaks. Dograh, the open-source AI voice agent platform, runs that chain on your own servers or on Dograh Cloud.

Key Takeaways

  • Most carriers send 8 kHz audio, so test agents over a real phone line.
  • Turn detection is a tunable setting, and each choice trades speed for patience.
  • Self-hosting Dograh moves the platform and records in-house, while hosted models still hear audio.

A phone agent is more than three models in a row. Here we draw one call as a system, box by box, from the carrier's audio stream to the record it leaves behind. Then we cover speech-to-speech and which boxes move in-house when Dograh runs on your servers.

One phone call, from the carrier to the run record

An AI phone agent has seven parts, and each one hands the call to the next. Laid out in the order a call meets them, they look like this.

  1. The phone line. A carrier owns the number and passes the call to the voice platform.
  2. The audio stream. The platform holds a two-way stream of audio open for the whole call.
  3. Listening. Voice activity detection hears speech, speech-to-text turns it into words, and a turn decision says the caller has finished.
  4. Thinking. A language model reads the words with the current step's prompt and can call tools.
  5. Speaking. Text-to-speech turns the reply into audio, or the platform plays a recorded clip.
  6. Turn-taking. It runs across steps 3 to 5 and decides when the agent stops for an interruption.
  7. After the call. The platform extracts answers, scores the call, sends results and saves the record.
A caller's phone connects to a carrier's mast, then a two-way audio stream runs into the voice platform, where listening, thinking with a language model and tools, and speaking go round in a loop with turn-taking across all three, and the call ends in a filing cabinet labeled run record that holds the transcript, recording and gathered answers.
Speech-to-text, the model and the voice draw the eye, yet the parts on either side of them settle whether the agent copes with real callers on real lines. Give the carrier side and the after-call record the same care.

Steps 3 to 5 get most of the attention, and our post on how the voice AI pipeline works follows one sentence through them. This post spends its time on the boxes around them, because those decide whether an agent works on a real phone line.

Each box maps to a part of how Dograh works. In that design the platform owns the call flow, tools and telephony, while the speech and language models form a layer you pick and can swap.

The phone line and the audio stream

The carrier sends the platform a live stream of small audio packets, and the platform sends its own audio back on the same connection. On Twilio, Plivo, Telnyx, Vobiz and Exotel, that stream reaches Dograh over a WebSocket. A call from your own PBX or SIP trunk arrives through Asterisk ARI or your own Cloudonix account, and the full list sits on the telephony providers page. The format is narrow. On Twilio, incoming audio is always audio/x-mulaw at 8000 Hz on one channel, encoded in base64, as its Media Streams messages define. Dograh runs Twilio, Telnyx, Plivo, Vobiz, Exotel, Cloudonix and Asterisk ARI calls at 8 kHz, while Vonage and WhatsApp calls run at 16 kHz.

That gap matters for testing. Most phone calls still reach the agent as 8 kHz audio, while a browser demo runs at 16 kHz, the most Dograh's pipeline uses. Our glossary explains why a voice agent sounds different on a phone call, and the practical rule is short. Test over a real phone line before you trust a browser test. The stream is also a line on the bill. Twilio charges $0.0044 a minute for Media Streams on top of the $0.0085 inbound local minute, so a cost estimate for a streamed agent carries both.

Hearing the caller and deciding they are done

Listening is three jobs, and only one of them is speech-to-text. First, voice activity detection decides whether a stretch of audio is speech at all. Dograh uses Silero VAD by default. Then speech-to-text streams words as the caller talks. Last, something has to decide that the caller has finished, and that decision sets how the agent feels to talk to.

In Dograh, that last job sits in the agent's Settings under Turn Detection. The default Detection Strategy is "Transcription-based", which suits short answers such as yes, no or a name. The other choice is "Smart Turn Analyzer", which uses the open Smart Turn model to judge whether a sentence sounds complete. Beside it, Incomplete Turn Timeout sets how long the agent waits when a turn sounds unfinished, 2 seconds by default and adjustable from 0.5 to 10. The end-of-turn decision is a trade-off between speed and patience. A short wait makes replies quick but cuts off a caller reading a policy number, and a long wait is polite but slow. Pick per agent, based on what its callers say.

Interruptions are the other half of turn-taking. Dograh's Interruption Strategy is "Minimum words" by default, so the caller must say 2 words before the agent stops, or you can switch it to "Voice activity". Each Agent step also has an Allow Interruption switch, on for every new step, so switch it off where a line must be heard in full. The greeting has its own Allow Greeting Interruption, on by default. The interruption settings page covers how each one behaves.

Dograh

Open Source Alternative to Vapi / Retell

Self-hosted voice agent platform — no per-minute fees

dograh-hq/dograh

Star on GitHub

The language model, the step prompt and tools

The language model never sees the whole agent at once. It gets the transcript so far, the prompt of the step the call is on and any data loaded for this caller. It writes the reply and also reads each step's exit conditions to decide when the call moves on, so a long agent is a chain of short prompts rather than one long one.

Tools are how the agent touches your systems, and they run at three moments. Before the greeting, Pre-Call Data Fetch at the bottom of the Start Call node sends a POST with the caller's details to an endpoint you run, and the greeting waits for the answer. During the call, HTTP API and MCP tools look things up or write records, and a line set in the tool's Messages plays while a slow lookup runs. When the caller needs a person, Transfer Call works on Twilio, Telnyx, Plivo, Cloudonix and Asterisk ARI. Dograh calls the destination first and connects the caller only when someone answers.

Every tool call spends part of the turn. A database on the same network fits inside the time a caller will wait, while a slow outside API needs a spoken line so the caller is not left in silence. Our playbook on speech latency breaks down where each millisecond of a turn goes.

Text to speech and pre-recorded clips

The speaking side runs the listening side in reverse. Text-to-speech streams audio as soon as the first words of the reply exist, and the platform converts it to the carrier's format before it goes out. On Twilio, outbound audio must also be 8 kHz mu-law, so a voice that sounds rich in the browser loses some of that on a phone.

Not every line needs a model. A pre-recorded clip plays a real recording with no synthesis, and the Greeting Text on the Start Call node is spoken word for word. Fixed text and clips are where exact wording holds, which matters for disclosures and names. Everything a step's prompt produces is written fresh by the model on each call.

What happens after the call ends

The second half of the call starts when the line closes, and it is where the business gets its value. Dograh extracts the answers the agent gathered into variables. This is an AI step, so the agent records each answer as the caller stated it, and the transcript and recording stay the exact record.

A QA node can then score the call. It scores each step separately, with tags, a 1 to 10 score, sentiment and a summary, and a Sample Rate below 100 picks calls at random. A Webhook node posts the results to your systems. It adds a call_disposition key to the payload, retries temporary failures, up to five attempts in all, and also fires on calls nobody answered, marked no-answer or busy.

Last, the run record keeps the transcript, the recording and the gathered data, and the run details API returns the same record to your own code. That record is what you audit, retrain prompts from and show a customer when they ask what the agent said.

Join the Dograh Community

Dograh is an OSS alternative to Vapi. Join our Slack community for queries, releases, best practices & community interactions.

Speech-to-speech folds three boxes into one

A speech-to-speech model takes the caller's audio and returns audio, so listening, thinking and speaking become one model. Dograh offers OpenAI Realtime, Google's Gemini Live, Google Vertex Realtime, Azure Realtime, AWS Nova Sonic, Grok Realtime and Ultravox as realtime options, chosen per agent.

The boxes around the model stay the same. The phone line, the audio stream, tools and the after-call half all still run in the platform. Two things change. Turn-taking moves partly into the model, since OpenAI Realtime, Azure Realtime and Grok supply their own speech signals and Dograh skips its local VAD for them. And a few features need text between the steps, so agent handoff, the spoken transfer introduction and text transition lines need a cascade agent. A tool's typed Messages line does not play either, so use a recording there.

Our post on cascade vs speech-to-speech weighs tool calling, latency, tone and cost per minute for each. Because the choice is per agent, one Dograh account can run both side by side.

What moves onto your servers when you self-host

Self-hosting moves the platform and the call records onto your servers. A self-hosted install runs in Docker Compose, with PostgreSQL for call data, MinIO for recordings, Redis, nginx, a TURN server for browser calls, the API and the UI. The Docker deployment guide asks for at least 8 GB of RAM and 4 vCPUs on a remote server, and an install runs 10 concurrent calls by default, raised with one setting.

What still leaves the building is the audio itself. The carrier carries the call, and any hosted speech or language model you pick still hears the caller. Your own key puts the provider contract in your name, but the audio still goes to that provider. Full data sovereignty needs open-weight models on your servers too, and Dograh's "Local Models (Speaches)" provider connects an OpenAI-compatible language model with Speaches for speech-to-text and voices. Placement also changes speed. Putting the platform and the models on one machine or in one region cuts network hops, as our guide to reducing latency with server colocation shows.

When you self-host Dograh, there is no per-minute platform fee. Servers, model keys and phone minutes still cost money, and your team looks after the database and upgrades. If you would rather not run servers, Dograh Cloud runs the same platform for a 1¢-a-minute platform fee.

Glossary

Media stream
The live, two-way flow of small audio packets between a phone carrier and a voice platform for the length of a call, usually over a WebSocket.
Mu-law
The 8-bit audio encoding most phone carriers use at 8 kHz. Twilio's Media Streams send and expect it, so every reply is converted to it before it plays.
Voice activity detection (VAD)
A small model that decides whether a slice of audio is speech. It runs before speech-to-text and feeds the turn and interruption decisions.
Speech-to-speech model
One realtime model that hears audio and answers in audio, replacing separate speech-to-text, language and text-to-speech models in the middle of the call.

Frequently Asked Questions

Get started with Dograh

Build, deploy, and scale AI agents with Dograh. Join the community of developers building the future.