How to Build a Production Voice AI agent: A Reference Architecture Twilio published a reference architecture for production voice AI agents that splits responsibilities: Twilio supplies the Conversations Layer for Voice AI — connectivity across phone, SIP, WebRTC and WhatsApp, call control, Conversation Relay speech-to-text and turn-taking, and shared customer context — while the customer builds and owns the agent runtime, hosting and tests. Twilio frames the design around six rules, including being "agentic where you can, deterministic where you must" and keeping authority out of the model so prompt injection cannot grant permissions, and it measures success by how many calls the agent resolves on its own before handing off to a human or another agent without the caller repeating themselves. How to Build a Production Voice AI agent: A Reference Architecture Time to read: Written by Reviewed by What does it take to put an AI agent on a live phone call – and keep it there? A good voice agent is more than a model and a prompt. Callers expect an agent to know who they are, allow them to change their minds mid-sentence, deal with the flow if they interrupt, and to provide a fluid and conversational experience. A few seconds of silence? They're gone. And an agent has to act safely in your systems: read a balance , move an appointment , take a payment , or hand the call to a human without making the caller start over. It also has to stay inside your guardrails: follow company policy , stick to approved topics , and sound like your brand on every call . Most enterprises we work with want to build and own that agent. They want to pick the models, write the prompts, and wire up their own systems. What they don’t want is to rebuild telephony, speech recognition, turn-taking, and context sharing from scratch. Twilio runs the call. You build the agent. Twilio provides the Conversations Layer for Voice AI: the connectivity, call control, speech, turn-taking, shared context, and handoff infrastructure needed to keep a live conversation moving. You build and own the agent runtime: the models, prompts, tools, guardrails, business logic, and customer experience. That split is the heart of this reference architecture. Twilio handles the communications and conversation orchestration, while your team focuses on the agent itself. At a glance at-a-glance At a glance, this reference architecture shows how Twilio provides the Conversations Layer for Voice AI, while you build the agent that connects to it. Twilio supports the live conversation across three layers: 1. Twilio connectivity gets calls in and out across phone, SIP, WebRTC, and WhatsApp. 2. Twilio call control routes, transfers, conferences, and manages each call. 3. Twilio’s voice/conversational AI infrastructure layer uses Twilio Conversation Relay uses Twilio Conversation Relay and shared customer context to turn speech into text, send each turn to your agent, receive the response, and speak it back to the caller. The architecture is designed to move one number: how many calls the agent resolves on its own. When it can't, it will cleanly hand the caller off – to a person or another agent – without making them repeat themselves. Using the Twilio Conversations Layer https://www.twilio.com/docs/conversations in your voice/conversational AI infrastructure layer makes your agents better by maintaining conversation history and providing conversational intelligence and making them available to your agent for better personalization and outcomes in both the active and subsequent conversations. Using Conversations, your agent has a clear path to be multi-channel SMS, RCS, WhatsApp . Who does what. As we mentioned, while Twilio handles the orchestration and the call, you build the agent . You’ll provide: 1. the runtime with its models, tools, and guardrails 2. the hosting that holds each call's WebSocket 3. and the tests that verify behavior and catch regressions Twilio’s six rules for AI agents toc-heading-6ce1fc5e-4ff0-474f-9e49-dd23201e7302 At Twilio, we see six rules for any AI agent – no matter the communications channel. Every decision later in this post comes back to one of these: 1. Be agentic where you can, deterministic where you must. Let the model hold the conversation and use scripted steps for disclosures, identity checks, and money. 2. Keep authority out of the model. Prompt injection https://genai.owasp.org/llmrisk/llm01-prompt-injection/ only works if the model holds the power it's asked to use. You can avoid prompt injection if you verify identity and enforce permissions off the non-deterministic path. 3. Give each kind of context one canonical home. Who the customer is, what's happening on this call, current business records and rules for everyone each live in exactly one place. 4. Silence is failure. Model responses, data retrieval, tool calls, guardrails, and network hops will introduce delays and latency into your conversation. Budget your latency for every turn, stream replies from your LLM, and give every tool a timeout and something to say when it's waiting on something else. 5. Hand off, never hang up. When the agent can't finish, the person who picks up gets the context. 6. Test your agent like code. A prompt, model or voice change is a release. Run a fixed test set before every one, and score live calls after. Beyond those six rules, you should be aware of two decisions you can't easily undo. Make these product and storage decisions before you create anything: - Twilio Conversation Relay or Twilio Media Streams for each call path. The two need different runtimes, so switching later means a rewrite. - Which system holds call transcripts, and for how long. Data that's already spread across logs, analytics, and model providers is hard to pull back. Start the human steps now. Picking voices, agreeing handoffs, deciding what's scripted and setting how callers are verified each take days – and none of them is a coding problem. Is this the right pattern for you? toc-heading-80974254-41f4-4aa0-8ae2-481929ebf2e3 Follow this Twilio Voice AI Agent reference architecture when you're building your own conversational agent for live inbound calls , on the hosting platform and with the AI models you choose. It covers voice though messaging is a natural https://www.twilio.com/docs/messaging/channels extension, and the same principles carry over. And remember, sometimes a full Voice AI Agent build isn't the right approach. Sometimes, something simpler and cheaper does the job: | If you need… | Use instead | |---|---| | An IVR, or fixed menu, not a conversation "press 1 for billing" | Twilio Studio https://www.twilio.com/docs/studio or TwiML