Voice agentsIntermediateAbout 4 min· Updated 6 hours ago
Build a voice agent: from phone call to answer
Eight steps to build an AI voice agent that answers a phone line: choose one job, connect the call, write the limits, handle delay, add a human hand-off, test with real calls and go live safely.
You will use:A phone number providerA speech-to-text serviceA language modelA text-to-speech service
A voice agent answers phone calls with a spoken conversation. This playbook builds one in eight steps, in the order that avoids the most common mistakes. Use it as a checklist, and swap in whichever services you prefer.
Picture it
The call, end to end
1
Caller speaks
audio comes in
↓→
2
Speech to text
becomes words
↓→
3
Model and tools
decide and act
↓→
4
Text to speech
audio goes out
Step 1: Pick one job and write its limits
Choose one narrow job, such as booking an appointment or answering opening-hours questions. Write down three things:
What the agent may do, for example look up a booking or create one.
What it must never do, for example give medical advice or promise a refund.
When it must hand the call to a person.
TipA voice agent that does one job well beats one that tries to do everything.
Step 2: Choose how the voice flows
There are two common designs.
A chain of three services. Speech to text, then a language model, then text to speech. It is easy to inspect and fix each step, but every step adds delay.
One live voice model. It listens and speaks in one flow, so it feels quicker and handles interruptions better. It is harder to inspect and control.
Start with the chain. You can move to a live voice model later, once you know what the calls look like.
Step 3: Get a phone number and connect the call
Rent a phone number from a telephony provider, and point it at your agent so that call audio streams to your code and your answers stream back. Test with your own phone before anything else. Check that you can hear the agent, and that it can hear you.
Step 4: Write the prompt and the tools
Write a short prompt that says the job, the tone, the limits from Step 1 and what to do when it is unsure. Give the agent only the tools it needs, such as look up a booking. Let your code check every tool call before it runs.
CarefulNever rely on the prompt alone to stop a risky action. Put the rule in code.
python voice_turn.py
# A sketch of one turn. Replace the helper functions with your own services.
MAX_TURNS = 20
def handle_turn(call, audio_chunk):
text = speech_to_text(audio_chunk) # hear
if wants_a_person(text) or call.turns >= MAX_TURNS:
return hand_off(call) # send to a human
reply = ask_model(call.history, text) # think (may ask for a tool)
if reply.tool:
check_allowed(reply.tool, reply.args) # guard in code
result = run_tool(reply.tool, reply.args)
reply = ask_model(call.history, result)
call.history.append((text, reply.text))
return text_to_speech(reply.text) # speak
Step 5: Handle delay and interruptions
A pause of more than about a second feels strange on a phone. Stream audio in small pieces, start speaking before the whole answer is ready, and stop talking at once when the caller speaks. If a tool call is slow, say a short line such as "One moment while I check that."
Step 6: Add a human hand-off
Always give an easy way to reach a person. Hand over when the caller asks, when the agent is unsure twice in a row, when the topic is outside the limits, or when the call runs long. Pass the person a short summary, so the caller does not have to repeat everything.
Step 7: Test with real calls
Test with real recorded calls from your own callers, in their languages and with background noise. Check names, numbers and codes by reading them back. Keep a list of twenty calls and replay it after every change. Mark each call pass or fail, and fix the failures that matter most.
Step 8: Go live safely
Tell callers they are speaking to an AI.
Record only with consent, and keep recordings no longer than you need.
Set limits on call length and cost.
Watch a sample of real calls every week.
Keep a switch that sends every call to a person if something goes wrong.
TipStart with a small share of calls, watch them, then widen.