Production-grade AI phone receptionist β answers calls, books appointments, handles emergencies, routes to staff
"Recovered 18 missed appointments in the first month β the agent paid for itself on day 3." β Dental clinic client, New York
π Live Demo β’ π₯ Watch It Work β’ Features β’ Architecture β’ Verticals β’ Edge Cases β’ Setup β’ Hire Me
π’ Call the demo right now:
+1 (XXX) XXX-XXXXTell Sophie you'd like to book a teeth cleaning. She'll check the calendar live, offer real time slots, confirm your details, book the appointment, and text you confirmation β all in under 90 seconds.
Demo agent runs 24/7. You'll receive a real SMS. No real appointment is booked at any actual clinic.
Live phone call β real-time appointment booking β calendar updated β SMS confirmation, end to end.
Small businesses lose an average of $126,000/year from missed calls. 85% of callers who don't reach someone won't call back.
This system deploys a 24/7 AI phone agent that:
- Answers every call β even at 2am, weekends, holidays
- Books, reschedules and cancels appointments directly into Google Calendar
- Handles dental/medical emergencies β detects urgency, routes to staff instantly
- Sends SMS confirmations automatically after every booking
- Qualifies real estate leads and books showings without a human agent
- Never forgets, never gets sick, never puts callers on hold
- 12 conversation flows covering every real-world scenario
- Natural language understanding β handles "tomorrow afternoon", "next Monday", "sometime this week"
- Graceful handling of angry callers, language barriers, silence, robocalls
- Context-aware: distinguishes new vs returning patients, emergency vs routine
- Checks live availability before confirming any slot β zero double bookings
- Race condition prevention β re-validates slot at booking moment (handles concurrent callers)
- Supports multiple doctors/providers on separate calendars
- Soft cancellations (events marked
[CANCELLED], never deleted β preserves history)
- Booking confirmation SMS sent instantly after scheduling
- 24-hour and 2-hour appointment reminders
- New patient intake form link via SMS
- Staff alerts for emergencies and new patients
- Retell webhook signature verification (rejects spoofed requests)
- Exponential backoff on Google Calendar API rate limits
- 8-second function timeout (prevents Retell's 10s hard cutoff)
- Global error handler β server never crashes mid-call
unhandledRejection+uncaughtExceptionhandlers at process level
Every call is automatically analyzed for:
call_outcome β’ patient_type β’ caller_sentiment β’ was_emergency β’ unhandled_requests
graph LR
A[π± Caller dials<br/>Twilio Number] --> B[ποΈ Retell AI<br/>STT + LLM + TTS]
B -->|Function Calls| C[βοΈ Express Webhook<br/>Signature verified]
C --> D{Router}
D -->|check_availability<br/>book_appointment| E[π
Google Calendar API]
D -->|transfer_to_staff| F[π Twilio Voice<br/>Transfer]
D -->|emergency| G[π¨ Staff SMS Alert]
E --> H[π² Twilio SMS<br/>Confirmation]
E --> I[π§ Email Backup]
style A fill:#4F46E5,color:#fff
style B fill:#7C3AED,color:#fff
style C fill:#059669,color:#fff
style E fill:#4285F4,color:#fff
style F fill:#F22F46,color:#fff
style G fill:#DC2626,color:#fff
style H fill:#F22F46,color:#fff
stateDiagram-v2
[*] --> Greeting
Greeting --> IntentDetection: Caller speaks
IntentDetection --> Booking: "Book appointment"
IntentDetection --> Reschedule: "Change appointment"
IntentDetection --> Cancel: "Cancel"
IntentDetection --> FAQ: "Question"
IntentDetection --> Emergency: "Pain / urgent"
IntentDetection --> Transfer: "Speak to human"
Booking --> CollectInfo
CollectInfo --> CheckCalendar
CheckCalendar --> OfferSlots: Available
CheckCalendar --> Alternatives: Full
OfferSlots --> ConfirmDetails
ConfirmDetails --> BookSlot
BookSlot --> SendSMS
SendSMS --> [*]
Emergency --> AssessUrgency
AssessUrgency --> SameDayBook: Pain < 7
AssessUrgency --> TransferUrgent: Pain β₯ 7
TransferUrgent --> StaffAlert
StaffAlert --> [*]
βββββββββββββββββββββββββββββββββββββββ
β INCOMING CALL β
β (Patient dials clinic number) β
ββββββββββββββββ¬βββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββ
β RETELL AI β
β Voice Orchestration Layer β
β β’ Speech-to-Text (STT) β
β β’ LLM (GPT-4o mini) β
β β’ Text-to-Speech (ElevenLabs) β
β β’ ~600ms response latency β
ββββββββββββββββ¬βββββββββββββββββββββββ
β Function Calls (webhook)
βΌ
βββββββββββββββββββββββββββββββββββββββ
β EXPRESS SERVER β
β β’ Signature verification β
β β’ Rate limiting + Helmet β
β β’ 8s function timeout guard β
β β’ Graceful error handling β
ββββββ¬ββββββββββ¬βββββββββββ¬ββββββββββββ
β β β
ββββββββββββΌβββ βββββΌβββββ βββΌβββββββββββ
β GOOGLE β β TWILIO β β LOGGING β
β CALENDAR β β SMS β β + ALERTS β
β β β β β β
β β’ Free/busy β β β’ Book β β β’ Winston β
β query β β conf β β β’ Staff β
β β’ Create β β β’ 24hr β β SMS β
β β’ Update β β rmndrβ β β’ Health β
β β’ Soft del β β β’ Staffβ β check β
βββββββββββββββ ββββββββββ ββββββββββββββ
| Vertical | Agent Name | Key Flows | Status |
|---|---|---|---|
| π¦· Dental Clinics | Sophie | Book/Reschedule/Cancel, Emergency triage, FAQ, Insurance | β Production |
| π Real Estate | Alex | Lead qualification, Showing scheduler, Discovery call booking | β Production |
| π§ Home Services | Coming soon | Emergency dispatch, Job booking, Quote requests | π |
| π₯ Medical Clinics | Coming soon | HIPAA-compliant scheduling, Referral routing | π |
50+ edge cases across 5 categories β documented in docs/EDGE-CASES.md
Booking Flow (15 cases)
- Requested slot taken β offers 3 alternatives automatically
- Race condition (2 callers booking same slot simultaneously) β pre-booking re-check
- Booking too close to current time β enforces configurable minimum advance hours
- Holiday/closed day β skipped in availability scan
- Patient changes mind mid-booking β restarts from date selection, no partial booking saved
- Vague time preference ("afternoon") β maps to 1:00 PM starting point
- Multiple services β books longest duration, notes both in calendar
Technical / API (15 cases)
- Google Calendar 429 rate limit β exponential backoff (2s, 4s, 8s)
- OAuth token expiry β auto-refresh via refresh token
- Retell function timeout β 8s guard returns graceful fallback before 10s hard limit
- Twilio error 21610 (unsubscribed) β permanent flag, no retry loop
- Server crash during call β
uncaughtExceptionlogs + restarts via PM2
Caller Behavior (15 cases)
- Complete silence β 3s prompt β 5s bridge β 8s end call
- Angry/frustrated caller β validate β empathize β escalate (never argue)
- "Are you a robot?" β "I'm Sophie, the virtual receptionist!" (honest, not evasive)
- Caller wants to book for someone else β collects patient's info, not caller's
- Robocall/spam β silent end after 8s, no engagement
Emergency Scenarios (9 cases)
- Pain 7+/10 β immediate transfer (critical urgency) + staff SMS
- Knocked-out tooth β immediate transfer + ER guidance
- Emergency after hours β emergency phone number + callback logging
- Emergency with no same-day slots β first morning slot + OTC pain guidance
| Metric | Before AI Agent | After AI Agent |
|---|---|---|
| Missed calls per week | 22 | 0 |
| New appointments (month 1) | Baseline | +18 recovered bookings |
| After-hours coverage | β None | β 24/7 |
| Staff time on phones | ~3 hrs/day | ~30 min/day |
| Patient no-show rate | Baseline | -15% (SMS reminders) |
| ROI payback period | β | Day 3 |
| Layer | Technology | Why |
|---|---|---|
| Voice orchestration | Retell AI | Lowest latency (~600ms), best calendar integrations |
| LLM | GPT-4o mini | Cost-efficient, fast, reliable function calling |
| TTS / Voice | ElevenLabs | Most natural-sounding voices |
| Phone numbers | Twilio | Industry standard, global coverage |
| Calendar | Google Calendar API | Universal β every clinic already uses it |
| Backend | Node.js + Express | Fast, async-first, WebSocket support |
| SMS | Twilio Messaging | Reliable delivery, detailed error codes |
| Date / Time | date-fns + date-fns-tz | Timezone-safe, no moment.js bloat |
| Logging | Winston | Structured logs, file rotation |
| Deployment | Railway / Render / PM2 | Zero-downtime, auto-restart |
# 1. Clone
git clone https://github.com/ajit-data-ai/voice-ai-agent-system.git
cd voice-ai-agent-system
# 2. Install
npm install
# 3. Configure
cp .env.example .env
# Fill in your credentials (see docs/DEPLOYMENT.md for step-by-step)
# 4. Get Google refresh token (one-time)
node scripts/google-auth-setup.js
# 5. Run locally
npm run dev
# 6. Expose to internet (for Retell webhooks)
npx ngrok http 3000Full deployment guide β docs/DEPLOYMENT.md
voice-ai-agent-system/
βββ server.js β Express server (entry point)
βββ agents/
β βββ dental/
β β βββ system-prompt.txt β 12 conversation flows, full edge case handling
β βββ real-estate/
β βββ system-prompt.txt β Lead qualification + showing booking
βββ config/
β βββ agent-config.json β Retell agent config + 7 function schemas
β βββ clinic-config.json β Per-client config template
βββ functions/
β βββ calendar.js β Google Calendar (check/book/reschedule/cancel)
β βββ sms.js β Twilio (confirmations, reminders, alerts)
β βββ appointments.js β Orchestration layer
βββ webhooks/
β βββ retell-webhook.js β Webhook handler + signature verification
βββ utils/
β βββ date-helpers.js β Natural language date/time parsing
β βββ logger.js β Structured logging
βββ monitoring/
β βββ health-check.js β /health + /ping endpoints
βββ scripts/
β βββ google-auth-setup.js β One-time OAuth token setup
βββ docs/
βββ ARCHITECTURE.md β System architecture, sequence diagrams, reliability patterns
βββ DEPLOYMENT.md β Local β production deployment guide
βββ EDGE-CASES.md β 50+ edge cases documented
Each client gets their own isolated instance:
- Dedicated Retell AI agent (cloned from vertical template)
- Their own phone number (Twilio)
- Connected to their Google Calendar
- Customized prompt (name, hours, services, doctors, policies)
- Staff notification routing
Setup time per new client: 2β4 hours β covered by a one-time setup fee.
24 test scenarios covering happy path, edge cases, emergency flows, and failure modes.
cat tests/scenarios.mdNo client goes live until all 24 scenarios pass.
I build, deploy, and maintain custom AI voice agents for service businesses β typically dental clinics, real estate agencies, home services, medical practices, and law firms.
A typical engagement includes:
- β Custom-trained agent for your business (services, hours, providers, policies)
- β Local phone number
- β Direct Google Calendar / Calendly / Jane App integration
- β SMS confirmations + appointment reminders
- β Monthly performance report + ongoing prompt optimization
- β Staff escalation routing for emergencies + complex cases
- β Unlimited prompt updates as your business changes
- β Production monitoring + uptime SLA
π Free 14-day pilot available for qualifying service businesses β call the live demo first, then book a discovery call.
π§ Discuss your project: your-email@domain.com Β· πΌ Upwork Β· π LinkedIn
MIT Β© Ajit
Built for deployment. Tested on real calls. Ready for your business.