Contact Center and Telephony Voice Agents
On a phone line the agent shares the work with people. The design succeeds when callers get their task done, not when they fail to reach a human.
A contact-center voice agent answers calls, identifies the need, verifies the caller when required, completes a small set of tasks and hands everything else to a person with the context attached. Start narrow, keep money and identity rules in code, always offer a human, and judge success by verified resolution rather than by calls that never reached an agent.
What you will learn: how calls reach software, call flow design, verification, handoff, a runnable state machine, rollout stages and metrics.
Prerequisites: Voice Agent Architecture and Real-Time Audio and Voice Latency, Turn-Taking, Quality and Privacy.
The example runs in November 2026 on Python 3.13 with invented calls and rules. It places no real calls. Provider features and telephone rules vary and change; verify them for your provider and countries.
Telephony in plain words
| Term | Meaning |
|---|---|
| PSTN | The public telephone network |
| SIP | Session Initiation Protocol, which sets up and controls internet calls |
| RTP | The protocol that usually carries the audio |
| IVR | An automated menu, often driven by key presses |
| DTMF | The tones sent by keypad presses |
| ACD | Automatic call distribution: queues calls to suitable agents |
| CRM | The system holding customer records and cases |
There are several ways to connect. Some voice model services accept SIP directly: OpenAI publishes a SIP guide for voice agents, and xAI documents SIP for its speech-to-speech service, including keypad presses passed to the model as input. Other setups use a telephony provider that streams audio to your server, or features built into a contact center platform. Whichever you choose, confirm how transfer, hold, recording, keypad input and failure routing work.
Choose the first tasks
Look at real call reasons and pick tasks that are frequent, well defined, low in harm and supported by reliable systems.
| Task | Fit for a first release | Why |
|---|---|---|
| Opening hours, locations | Good | No account access, easy to verify |
| Order or case status | Good with verification | Read-only |
| Appointment booking | Good with read-back | Reversible and structured |
| Small refund within policy | Later | Money moves; needs limits and audit |
| Complaints, hardship, bereavement | Route to people | Judgment and care matter |
| Emergencies | Never automate the decision | Give the emergency instruction and connect people |
A flow with exits at every step
Let the model handle language and let a state machine decide what is allowed next. A model can phrase a question in many ways; it should not be able to skip verification. This script runs seven calls through such rules.
"""A support call as a state machine: verify, act within limits, or hand over."""
from dataclasses import dataclass, field
NEEDS_CODE = {"order status", "refund", "change address"}
SELF_SERVICE = {"opening hours", "order status", "refund"}
REFUND_LIMIT = 50.0
@dataclass
class Call:
id: str
intent: str
code_keyed: str = ""
amount: float = 0.0
wants_person: bool = False
system_updated: bool = True
log: list = field(default_factory=list)
def run(self, expected_code="4821"):
if self.wants_person:
return self.hand_over("caller asked for a person")
if self.intent in NEEDS_CODE:
if self.code_keyed != expected_code: # one-time code, typed on keypad
return self.hand_over("verification failed")
self.log.append("verified by one-time code")
if self.intent not in SELF_SERVICE:
return self.hand_over("not a self-service task")
if self.intent == "refund" and self.amount > REFUND_LIMIT:
return self.hand_over(f"refund {self.amount:.2f} above limit")
if not self.system_updated:
return self.hand_over("system did not confirm the change")
self.log.append(f"completed: {self.intent}")
return {"call": self.id, "end": "contained", "resolved": True}
def hand_over(self, reason):
packet = {"intent": self.intent, "reason": reason,
"verified": "verified by one-time code" in self.log}
return {"call": self.id, "end": "transfer", "resolved": False, "packet": packet}
CALLS = [
Call("A", "opening hours"),
Call("B", "order status", code_keyed="4821"),
Call("C", "refund", code_keyed="4821", amount=20),
Call("D", "refund", code_keyed="4821", amount=400),
Call("E", "change address", code_keyed="0000"),
Call("F", "complaint", wants_person=True),
Call("G", "refund", code_keyed="4821", amount=15, system_updated=False),
]
results = [call.run() for call in CALLS]
for r in results:
note = r.get("packet", {})
print(f"{r['call']} {r['end']:<9} {note.get('reason', '')}"
+ (" (caller already verified)" if note.get("verified") else ""))
contained = sum(r["end"] == "contained" for r in results)
HUNG_UP = 2 # assumed: callers who gave up before any outcome
print(f"resolved by the agent: {contained} of {len(results)} finished calls")
print(f"'not transferred' if hang-ups count as success: "
f"{contained + HUNG_UP} of {len(results) + HUNG_UP}")
Output:
A contained
B contained
C contained
D transfer refund 400.00 above limit (caller already verified)
E transfer verification failed
F transfer caller asked for a person
G transfer system did not confirm the change (caller already verified)
resolved by the agent: 3 of 7 finished calls
'not transferred' if hang-ups count as success: 5 of 9
Reading the result
Calls D and G show why completion and honesty differ. D is a valid request that exceeds a limit. G is a refund the system never confirmed, so the agent must not tell the caller it succeeded. The final two lines show how a number can flatter you: counting abandoned calls as "contained" lifts the figure from 3 of 7 to 5 of 9 while helping nobody. The hang-up count is assumed.
The example compares a fixed code. A real system generates a random one-time code per call, expires it, limits attempts, compares it securely and never shows it to the model or logs.
Write the conversation
Script the moments that must be exact and let the model handle the rest. The opening, consent question, amounts, legal notices and safety messages are fixed text. Questions, clarifications and small talk can vary.
| Moment | Weak wording | Stronger wording |
|---|---|---|
| Opening | "How may I assist you today with your various needs?" | "I'm an automated AI assistant. What are you calling about? You can ask for a person." |
| Not understood | "Invalid input." | "Sorry, I missed that. Is it about an order, a payment, or something else?" |
| Confirmation | "Okay?" | "I'll refund 20 dollars to the card ending 2210. Yes or no?" |
| Slow lookup | Silence | "I'm checking your order. This can take a few seconds." |
| Cannot help | "I can't do that." | "A colleague handles that. I'll pass on what you've told me." |
Limit retries. A common pattern is one rephrased attempt, one simpler choice or keypad option, then a person. Count silence, noise and "no" to a confirmation as separate events, because they need different fixes.
Answers from approved knowledge
Questions about policy should be answered from a reviewed knowledge source with an owner and an effective date, not from the model's general knowledge. Retrieve a short passage, say the answer in one or two sentences and offer to send the full text. If nothing relevant is found, say so and transfer. Prices, terms and eligibility need special care, since a spoken promise may be treated as one your organization made. See RAG Evaluation, Grounding and Debugging.
Verification and fraud
- Match the method to the risk: public information needs none; account changes need more than facts a thief could find.
- Caller ID can be spoofed, and voices can be synthesized. Use neither alone.
- Keep secrets out of speech where possible: keypad entry or a link to an authenticated app.
- Lock out after a few failures and tell a person, without revealing which detail was wrong.
- Re-verify for higher-risk actions, such as changing the contact number that receives codes.
- Watch for patterns across calls: many accounts from one number, or repeated small refunds.
Getting values right
| Value | Capture technique |
|---|---|
| Account or order number | Keypad, or speech with a check digit and read-back in groups |
| Name and address | Look up and confirm; spell when uncertain |
| Date and time | Repeat with weekday and time zone |
| Email address | Prefer an address already on file or a text link |
| Payment card | Dedicated secure payment capture, outside the agent |
| Yes or no for actions | State the action and amount, then ask once, clearly |
Handoff that respects the caller
The person receiving the call should not start over. Send a short, structured packet and say what will happen.
{
"call_id": "D",
"reason_for_call": "refund",
"verified": "one-time code, 2 minutes ago",
"collected": {"order": "A-4279", "amount": "400.00"},
"done": [],
"not_done": ["refund: above agent limit"],
"transfer_reason": "limit",
"language": "en"
}
This packet is an illustration. Mark facts the caller only claimed, keep it brief and exclude secrets. If nobody is available, give an honest wait estimate, offer a callback with a real time and create the case.
A request for a person, repeated misunderstanding, distress, mentions of harm, legal threats, vulnerability or a topic outside scope should each have a defined route.
Fit into the platform
Capacity and peaks
Telephony load is measured in simultaneous calls, not requests per second. A rough estimate is calls arriving per hour multiplied by average call length in hours. For example, 600 calls an hour at 4 minutes each is 40 calls in progress on average; peaks within the hour will be higher. Check limits on trunks, model sessions, recognizers and downstream systems, and decide what happens when one is full: queue, menu fallback or direct routing to people. See Latency, Load Testing and Capacity Planning.
Resilience
- A switch that returns all calls to normal routing, tested regularly
- Health checks that call the number and complete a harmless task
- Fallback routing at the carrier or platform if your service is unreachable
- Idempotent actions so a dropped and repeated call does no double work
- Follow-up messages when a call drops after an action
Outbound calls
Calling people carries heavier duties than answering them. In the United States, the FCC has ruled that AI-generated voices are artificial voices under the Telephone Consumer Protection Act, which brings its rules, including consent requirements, into play. Other countries have their own regimes. Confirm consent, calling hours, identification, opt-out and do-not-call lists with counsel before the first outbound call. In the EU, AI disclosure duties under Article 50 of the AI Act also apply to systems that interact with people.
Test with calls, not only transcripts
Build a call suite that runs before every release. Drive the state machine in text for speed, then place a smaller set of real audio calls through the same number and routing that customers use.
| Group | Examples | Must hold |
|---|---|---|
| Normal | Each supported task, each language | Task confirmed by the system |
| Boundaries | Refund just over the limit, closed account | Transfer with correct reason |
| Verification | Wrong code, expired code, "just trust me" | No protected data or action |
| Audio trouble | Noise, silence, interruptions, keypad mixed with speech | Recovery or transfer, no loop |
| Backend trouble | Timeout, partial failure, duplicate request | Honest message, no double action |
| Sensitive | Distress, threats, emergency words | Defined escalation every time |
Treat a failed safety row as a release blocker rather than something averaged into a score. Keep each production failure, with personal details removed, as a new case.
After the call
The call is not finished when the line closes. Write one case record containing the reason, what was verified, actions attempted, the confirmation returned by each system and any promise made to the caller. Generate the summary from these records first and from the transcript second, so it cannot report an action that never happened. Let staff correct it, and feed corrections into your tests.
Send the caller a short confirmation for anything that changed, using contact details already on file. It gives them a way to spot a wrong or fraudulent change early. Reconcile daily: every action the agent claims should match an entry in the system of record, and every unmatched item needs an owner. Apply the retention periods you decided in Voice Latency, Turn-Taking, Quality and Privacy to recordings, transcripts, summaries and exports alike.
Metrics that keep you honest
| Measure | Definition to agree | Pair it with |
|---|---|---|
| Verified resolution | System confirms the task and no related contact within a set period | Repeat contact rate |
| Containment | Call ends without a person | Abandonment and complaints |
| Transfer quality | Right queue, no repeated questions | Human agent ratings |
| Handle time | Whole journey including transfers | Resolution |
| Wrong actions | Changes that should not have happened | Time to detect and reverse |
| Caller feedback | Short optional survey | Response rate and bias |
| Cost per resolved task | Telephony, models, platform and human time | Baseline before launch |
Take a baseline before launch and compare like with like: the same call reasons, hours and customer groups. See Agent FinOps, Budgets and Chargeback.
Roll out in stages
- Offline: scripted calls, including every refusal and transfer path.
- Staff pilot: employees call with realistic tasks on real phones.
- Listen and suggest: the agent assists human agents with consented summaries and lookups.
- Small live share: one task, business hours, easy transfer, daily review.
- Expand: add tasks one at a time, each with its own entry criteria and rollback.
This invented example shows the reasoning. A clinic group wants calls answered after hours. Release one gives opening times and takes callback requests only. Release two books routine appointments with read-back and a text confirmation. Symptoms, urgent wording or confusion go straight to the on-call process with a fixed safety message. Nothing clinical is decided by the agent.
The people side
Tell human agents what the system does and does not do, give them a quick way to flag mistakes, and plan for the calls they now receive to be harder on average. Include their feedback in release decisions. Accessibility routes, such as text channels and relay services, must keep working.
Common mistakes
| Mistake | Better practice |
|---|---|
| Hiding the route to a person | Offer it early and honor it |
| Optimizing containment alone | Track verified resolution and repeat contact |
| Letting the model decide verification | Enforce it in code before tools unlock |
| Reading card numbers into the transcript | Use separate secure capture |
| Transferring with no context | Send a structured packet |
| Launching all call types together | One task at a time with rollback |
Checklist
- First tasks chosen from real call data
- AI notice, consent and human route in the opening
- Verification and limits enforced outside the model
- Success announced only after system confirmation
- Handoff packet tested with real agents
- Peak concurrency, fallback routing and kill switch tested
- Resolution, repeat contact and wrong actions reviewed weekly
Frequently asked questions
Should the agent replace the keypad menu?
It can sit behind or beside it. Keep keypad options for noisy lines, private values and callers who prefer them.
What containment rate should we target?
Do not start from a target. Measure verified resolution by task, then improve it without raising repeat contacts or complaints.
Can the agent handle angry callers?
It can acknowledge the problem and transfer quickly. Define signals for immediate escalation and test them.
Who is responsible for a wrong action?
Your organization. Name an owner for each task, log approvals and make correction easy for staff.
References and further reading
- OpenAI: SIP for voice agents
- xAI: speech-to-speech over SIP
- RFC 3261: Session Initiation Protocol
- FCC ruling on AI-generated voices
- European Commission FAQ on Article 50
Next steps
Human-in-the-Loop and Approval Gates
Design approvals and escalation.
Task, Tool and Planning Metrics
Define success carefully.
Lab: Voice Agent and Document Agent
Practice with a support agent.