kuldeepmishra76/medicare-receptionist-voice-agent
0
๐ฅ Multi-Doctor Voice Appointment Scheduling Agent
An intelligent, multi-doctor hospital voice receptionist agent that handles appointment booking, rescheduling, cancellation, and general medical inquiries through natural voice conversations.
๐ผ๏ธ Preview & Dashboard Screenshots
๐ Key Features
- โก Hybrid Ultra-Fast Pipeline: Uses a 0ms Latency Deterministic State Engine for standard booking steps & specialty inquiries, with automatic fallback to Groq LLM (`llama-3.1-8b-instant`) for complex off-script questions.
- ๐๏ธ Voice Integration: Supports Vapi AI Webhooks, ElevenLabs Scribe STT / Whisper, and ElevenLabs TTS for voice generation.
- ๐ค LangGraph Agent Workflow: State-machine orchestration using LangGraph with LangChain tools for real database querying and conflict validation.
- ๐๏ธ Smart Conflict Validation Engine: Prevents duplicate bookings, doctor overlaps, patient overlaps, and validates doctor working hours, working days, and leave dates.
- ๐ Google Calendar Sync: Automatically creates, updates, or deletes events on Google Calendar for booked appointments (with smart mock mode fallback).
- ๐ฑ Multi-Channel Notifications: Sends confirmation, reschedule, and cancellation alerts via Twilio SMS, Twilio WhatsApp, and Resend HTML Email.
- ๐ฅ๏ธ Interactive Admin Dashboard & Voice Simulator: Web dashboard (
/dashboard) featuring real-time metrics, appointment management, doctor management, patient directory, and a built-in voice call testing environment with Web Speech API support.
๐๏ธ Architecture & Voice Pipeline Flow
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ User Voice Input โ
โโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ ElevenLabs Scribe STT / Vapi โ
โโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Fast Voice Router โ
โโโโโโโโฌโโโโโโโโโโโโโโโโโโโฌโโโโโโโโ
โ โ
(Standard Booking/Inquiry) (Complex Inquiry)
โ โ
โผ โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Deterministic Fast Rule Engine โ โ LangGraph State Machine Agent โ
โ โข Instant <10ms response โ โ โข Groq llama-3.1-8b-instant โ
โ โข 0 Token Cost & Zero Latency โ โ โข Async Database Tools โ
โโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโ
โ โ
โโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Async SQLAlchemy Database (SQLite/Pg) โ
โโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโ
โ โ
โผ โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Google Calendar API Event Sync โ โ Multi-Channel Notifications โ
โ (Create / Reschedule / Cancel) โ โ (Twilio SMS, WhatsApp, Email) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ ElevenLabs TTS Voice Audio Output โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโก Quick Start & Installation
1. Clone Repository & Setup Environment
# Clone the repository
git clone <repository-url>
cd voice-agent-for-doctor
# Create virtual environment
python -m venv venv
# Activate virtual environment
# Windows:
venv\Scripts\activate
# macOS/Linux:
source venv/bin/activate2. Install Dependencies
pip install -r requirements.txt3. Configure Environment Variables
Create a .env file in the project root:
cp .env.example .envEdit .env and fill in your API keys (Groq, ElevenLabs, Twilio, Resend, Google Calendar, etc.).
4. Seed Database with Sample Doctors
Populate the database with initial doctors across 8 medical specializations:
python scripts/seed_doctors.py5. Run Server
python run.py
# OR
uvicorn app.main:app --reload --host 0.0.0.0 --port 8000๐ฅ๏ธ Accessing Interfaces
- Admin Dashboard & Voice Simulator: http://localhost:8000/dashboard
- Swagger API Documentation: http://localhost:8000/docs
- ReDoc API Documentation: http://localhost:8000/redoc
๐ Project Structure
voice-agent-for-doctor/
โโโ app/
โ โโโ main.py # FastAPI application entry point & static mounting
โ โโโ config.py # Pydantic Settings & environment variables
โ โโโ database.py # Async SQLAlchemy engine & session factory
โ โโโ models/ # ORM Models (Patient, Doctor, DoctorLeave, Appointment)
โ โโโ schemas/ # Pydantic Schemas for API validation
โ โโโ agents/ # LangGraph workflow, nodes, tools, and shared state
โ โ โโโ graph.py # StateGraph workflow router definition
โ โ โโโ nodes.py # Node functions with LLM fallback
โ โ โโโ state.py # AgentState TypedDict definition
โ โ โโโ tools.py # Async DB tools for LangGraph agent
โ โโโ api/routes/ # REST API Routers
โ โ โโโ auth.py # Admin security middleware
โ โ โโโ patients.py # Patient CRUD & phone/code lookup
โ โ โโโ doctors.py # Doctor profile & availability slot generation
โ โ โโโ appointments.py # Appointment booking & conflict validation
โ โ โโโ voice.py # Vapi AI webhook & voice simulator routes
โ โโโ services/ # Core Business Logic Layer
โ โโโ appointment_service.py # Conflict validation & booking logic
โ โโโ doctor_service.py # Doctor availability, shift hours & leave
โ โโโ patient_service.py # Patient registration & phone normalization
โ โโโ calendar_service.py # Google Calendar API sync
โ โโโ elevenlabs_service.py # ElevenLabs TTS & STT integration
โ โโโ notification_service.py# SMS (Twilio), WhatsApp, & Email delivery
โโโ frontend/ # Web Admin Dashboard & Simulator UI
โ โโโ index.html # Single page app layout with Dark/Light theme
โ โโโ app.js # Dynamic fetcher & Web Speech API integration
โ โโโ styles.css # Modern CSS design system
โโโ scripts/
โ โโโ seed_doctors.py # Script to seed initial sample doctors
โโโ tests/
โ โโโ test_agents.py # Pytest suite for symptom mapping logic
โโโ run.py # Application runner
โโโ requirements.txt # Project dependencies
โโโ .env.example # Environment configuration template
โโโ README.md # Documentation๐ Environment Configuration (.env)
๐งช Running Tests
Run the test suite using pytest:
pytest tests/ -v๐ License
MIT License. Developed for intelligent automated medical receptionist and voice appointment scheduling systems.


