Voice Agent API — front desk agent for a medical practice
# Voice Agent API: front desk agent for a medical practice
import asyncio, json, websockets
API_KEY = "YOUR_API_KEY"
async def run_front_desk():
async with websockets.connect(
"wss://agents.assemblyai.com/v1/ws",
additional_headers={"Authorization": f"Bearer {API_KEY}"},
) as ws:
await ws.send(json.dumps({
"type": "session.update",
"session": {
"system_prompt": (
"You are the front desk agent for Lakewood Family Practice. "
"Schedule, reschedule, and cancel appointments. Route urgent "
"calls to on-call staff. Collect new-patient info: name, DOB, "
"insurance, reason for visit. Always confirm details before "
"booking. Never give medical advice."
),
"greeting": "Thanks for calling Lakewood Family Practice — how can I help?",
"input": {"keyterms": ["Dr. Patel", "panoramic x-ray", "deep cleaning", "Lakewood office", "Downtown office"]},
"output": {"voice": "ivy"},
"tools": [{
"type": "function",
"name": "book_appointment",
"description": "Book an appointment in the practice management system.",
"parameters": {
"type": "object",
"properties": {
"patient_name": {"type": "string"},
"dob": {"type": "string"},
"provider": {"type": "string"},
"appointment_time": {"type": "string"},
"reason": {"type": "string"},
},
"required": ["patient_name", "appointment_time"],
},
}],
},
}))
async for msg in ws:
handle(json.loads(msg)) # transcript.user, reply.audio, tool.call, ...
LiveKit + Universal-3.5 Pro Realtime — multi-location routing
# LiveKit + AssemblyAI Universal-3.5 Pro Realtime: multi-location routing
from livekit.agents import Agent, AgentSession, TurnHandlingOptions
from livekit.plugins import assemblyai, cartesia, openai, silero
from livekit.plugins.turn_detector.multilingual import MultilingualModel
class FrontDeskAgent(Agent):
def __init__(self):
super().__init__(
instructions=(
"You are a front desk receptionist for a multi-location dental "
"group. Identify which office the caller needs. Check availability "
"across all locations. Book appointments, collect insurance details, "
"and route complex billing questions to the office manager."
),
)
async def entrypoint(ctx):
session = AgentSession(
stt=assemblyai.STT(
model="u3-rt-pro",
keyterms_prompt=["Dr. Patel", "panoramic x-ray", "deep cleaning",
"Lakewood office", "Downtown office"],
),
llm=openai.LLM(model="gpt-4o"),
tts=cartesia.TTS(),
vad=silero.VAD.load(activation_threshold=0.3),
turn_handling=TurnHandlingOptions(
turn_detection=MultilingualModel(),
endpointing={"min_delay": 0.5, "max_delay": 3.0},
),
)
await session.start(room=ctx.room, agent=FrontDeskAgent())