🩺 Simple Story: Booking an Appointment
1
The patient messages WhatsApp saying they need a visit.
2
The AI greets them, saves their name if this is their first visit, and confirms the best number or email for reminders.
3
It runs an instant availability check.
4
The assistant asks which doctor or specialty they need and shows simple numbered options if they are unsure.
5
The patient shares a day and time, and the AI checks the clinic calendar.
6
If a slot is available, the AI books it immediately and sends confirmation to both patient and doctor.
Every booking quietly updates the patient profile with name, contact preferences, specialty choice, and reminder settings so the next conversation skips straight to availability.
🚨 Why we built this
Today, patients wait for callbacks while coordinators chase doctors and retype names into spreadsheets. Our automated flow captures patient details once, keeps them stored safely, and delivers real-time updates so staff only step in when a human decision is needed.
<3min
Typical end-to-end move
90%
Conversations handled by AI
📊 Core Medical Booking Flow
This map shows how the AI greets a new patient, captures their name and contact details, screens for urgent symptoms, identifies the right specialty, and confirms a slot while saving the profile for next time.
flowchart TD
Start([Patient: Hi, I need to book a visit]) --> Greet[AI greets the patient]
Greet --> KnowName{Do we already know their name?}
KnowName -->|No| AskName[Collect name and save the profile]
AskName --> ConfirmContact[Confirm WhatsApp number or email reminders]
KnowName -->|Yes| ConfirmContact
ConfirmContact --> Safety{Any urgent symptoms mentioned?}
Safety -->|Yes| Triage[Escalate to nurse and send emergency steps]
Triage --> EndTriage([Stop: human care team takes over])
Safety -->|No| Reason[Ask for reason or specialty]
Reason --> Mentioned{Did the patient say the specialty?}
Mentioned -->|Yes| SelectSpecialty[Lock specialty and provider pool]
Mentioned -->|No| OfferMenu[List numbered specialties]
OfferMenu --> SelectSpecialty
SelectSpecialty --> AskWindow[Ask which day and time works best]
AskWindow --> PatientWindow[Patient shares preferred window]
PatientWindow --> CheckCalendar[Check the EMR for compliant slots]
CheckCalendar --> Slots{Slot status}
Slots -->|Open| OfferTimes[Offer up to two open slots]
Slots -->|No slots| Followup[Log request and alert coordinator]
OfferTimes --> PatientChoice[Patient picks an option number]
PatientChoice --> HoldSlot[Hold slot and create appointment]
HoldSlot --> SaveProfile[Save name, contact, specialty preference]
SaveProfile --> Confirmations[Send confirmations to patient and doctor]
Confirmations --> EndBooking([Booking complete])
Followup --> Manual([Manual follow-up needed])
classDef done fill:#d4edda,stroke:#1b5e20,color:#1b5e20;
class EndBooking done;
🔁 Medical Rescheduling Flow
Once a patient already has a visit, we identify the right appointment, collect a new time, coordinate with the doctor, and escalate if the doctor stays silent for five minutes.
flowchart TD
Start([Patient: I need to reschedule my appointment]) --> Safety{Does the message sound urgent?}
Safety -->|Yes| Triage[Alert nurse + send emergency steps]
Triage --> EndTriage([Stop: human care team takes over])
Safety -->|No| FindAppointments[Look up upcoming visits]
FindAppointments --> Count{How many visits?}
Count -->|0| NoVisits[No visit found -> offer to book one]
Count -->|1| OneVisit[One visit -> continue]
Count -->|Many| ListVisits[List visits with simple numbers]
ListVisits --> OneVisit
OneVisit --> AskTime[Ask for new day/time]
AskTime --> PatientTime[Patient shares new slot]
PatientTime --> CheckCalendar[Check clinic rules + doctor calendar]
CheckCalendar --> Status{Calendar result}
Status -->|Open| UpdateVisit[Update visit + save audit note]
Status -->|Needs doctor| AskDoctor[WhatsApp message sent to doctor]
Status -->|Closed| OfferOptions[Send two approved alternatives]
AskDoctor --> TellPatient[Let patient know we asked the doctor + start 5-min timer]
TellPatient --> WaitDoctor{Doctor replies in 5 min?}
WaitDoctor -->|No| EscalateTimeout[Coordinator alerted + patient updated]
WaitDoctor -->|Yes| DoctorResponse{Doctor says?}
DoctorResponse -->|Approved| UpdateVisit
DoctorResponse -->|Suggests other times| EscalateAlternate[Escalate to coordinator + notify doctor coordinator will liaise]
UpdateVisit --> SendConfirmations[Send WhatsApp confirmations to patient and doctor]
SendConfirmations --> EndSuccess([Finished])
EscalateTimeout --> EndEscalated([Manual follow-up])
EscalateAlternate --> EndEscalated
NoVisits --> EndNoVisit([Redirect to booking flow])
🎯 Simplified Happy Path
A single conversation between Maria and Dr. Patel that shows how the AI keeps both people updated, waits for the doctor, and shares the final confirmation in plain language.
sequenceDiagram
participant P as Patient
participant AI as AI Orchestrator
participant EMR as Scheduling DB
participant D as Doctor
Note over P,D: SLA target under 3 minutes
P->>AI: I need to move my cardiology appointment to Tuesday at noon
activate AI
AI->>AI: Intent classification and specialty detection
AI->>EMR: Fetch Maria cardiology appointments
EMR-->>AI: 1 appointment Monday 10am with Dr Patel
AI->>P: Checking availability with Dr Patel Anything urgent today
P->>AI: No urgency just a conflict
AI->>EMR: Verify Tuesday 12pm slot against schedule
EMR-->>AI: Tentative provider confirmation required
AI->>P: I pinged Dr Patel Will confirm shortly
AI->>D: Maria wants to move Mon 10am to Tue 12pm Can you approve
Note over D: Provider reviews 2 min
D-->>AI: Approved
AI->>EMR: Update appointment and record reason code
EMR-->>AI: Updated
AI->>P: Confirmed Your cardiology visit is now Tuesday at noon with Dr Patel
AI->>D: Appointment moved patient notified
deactivate AI
Note over P,D: Rescheduled in under 3 minutes
🏗️ System Architecture
One slide that explains who talks to whom: patients and doctors stay in WhatsApp, the AI brain handles safety + scheduling logic, and a live dashboard lets coordinators jump in when needed.
graph TB
subgraph Users["👥 Healthcare Stakeholders"]
P1[🩺 Patient WhatsApp]
D1[👨⚕️ Provider WhatsApp]
C1[👩💼 Clinical Coordinator Portal]
end
subgraph API["🌐 WhatsApp Business API"]
WA[Message Gateway]
end
subgraph Backend["🖥️ Application Server"]
WH[Message Handler]
AI[AI Orchestrator
NLU + Workflow]
SM[State Machine]
SF[Safety Filter
Triage Logic]
WC[Message Client]
end
subgraph Workers["⚙️ Background Services"]
TM[Timeout Monitor
5-min SLA]
ES[Escalation Service]
end
subgraph Data["💾 Data Layer"]
EMR[(EMR Database
Appointments, Providers)]
RD[(Redis Cache
Session State)]
AU[(Audit Log
HIPAA Trail)]
end
subgraph Dashboard["📊 Clinical Dashboard"]
WS[WebSocket Updates]
UI[Admin UI
Queue Management]
end
P1 <-->|Messages| WA
D1 <-->|Messages| WA
WA -->|Webhook| WH
WH -->|Route| AI
AI -->|Safety Check| SF
SF -->|Urgent| ES
AI -->|Query/Update| EMR
AI -->|Session State| RD
AI -->|Log Actions| AU
AI -->|Manage Flow| SM
SM -->|Send| WC
WC -->|WhatsApp API| WA
AI -->|Queue Timer| TM
TM -->|Check| RD
TM -->|Trigger| ES
ES -->|Notify| C1
ES -->|Alert| WS
WS -->|Live Feed| UI
UI -->|Override| Backend
style Users fill:#e1f5ff
style Backend fill:#fff3cd
style Data fill:#d1ecf1
style Dashboard fill:#d4edda
style Workers fill:#f8d7da