Reference build · Clinics · WhatsApp

A WhatsApp booking agent for a three-doctor clinic

An agent that books, reschedules and reminds over WhatsApp inside the clinic’s rules, collects intake before the visit, and hands anything symptom-shaped to a nurse without attempting to triage.

Reference build — a working agent and a worked example, not a client deployment

01 · The problem

The front desk is a switchboard, and the patients who message at night book somewhere else.

A typical outpatient clinic with three doctors handles around sixty booking-related messages and calls a day. Each takes about four minutes of a receptionist’s time once you count finding the slot, confirming it, typing the patient into the system and sending the reminder. That is roughly four hours a day, and it is the part of the job that cannot wait, so it always wins over the patient standing at the counter.

The WhatsApp inbox makes it worse rather than better. Messages arrive at 9:40 pm and sit until 8:10 am; by the time the desk replies with two slot options the patient has either booked elsewhere or stopped checking. Reschedules are the same two-minute job repeated thirty times, and a slot that opens at 10:40 stays empty because nobody had time to work the waitlist.

Constraints that shaped the design

  • No medical advice, under any phrasing. A symptom in a message ends the booking conversation and starts an escalation.
  • The agent may write to the appointment book and to draft records. Nothing clinical.
  • The booking rules (which doctors, which slots, how far ahead, how many reschedules) belong to the practice manager and change without a developer.
  • Patient data stays in the clinic’s systems; the model sees the conversation and the offered slots, not the record history.
02 · Agent design

One agent, five tools, and a rulebook it reads before every reply.

  1. 1A message arrives on the WhatsApp Business number. The webhook writes it to the conversation table and wakes the agent.
  2. 2The agent loads the rulebook (doctors, hours, slot lengths, lead time, reschedule limit, approved FAQ answers, urgent-care text) and the last few turns of this conversation.
  3. 3It classifies intent: book, reschedule, cancel, question, or something that needs a person. Red-flag phrases short-circuit to escalation before any booking logic runs.
  4. 4For a booking it asks the one or two things it does not yet know (doctor, new or returning, preferred day), calls check_availability, and offers three slots.
  5. 5On a choice it calls book_appointment, which writes to the practice system, then sends the confirmation and the pre-visit instructions the clinic approved. New patients get the intake link.
  6. 6Every tool call, with the message that caused it, is logged. The morning summary lists bookings, exceptions and escalations for the desk.

Why an agent, and not a chatbot or a Zap: A form cannot hold a conversation ("Thursday is bad, anything Friday morning?"). A scripted chatbot breaks the moment a patient writes two things in one message. A Zapier flow cannot decide that "my daughter has had a fever since Saturday" is not a booking. The agent reads the message, decides which of five tools applies, and is forbidden from everything else.

03 · Tools

The 5 tools it may call, and nothing else

The tool list is the permission list. If a capability is not here, the agent does not have it, however it is asked.

ToolWhat it doesWhat it may touch
check_availabilityLists open slots for a doctor and date range within the rulesReads the practice calendar
book_appointmentBooks a slot for a named patient, returns the confirmationWrites to the appointment book only
reschedule_appointmentMoves or cancels an existing booking within the reschedule limitWrites to the appointment book only
send_intake_formSends the intake link to a new patient; answers land as a draft recordCreates a draft patient record
escalate_to_staffFlags the conversation to a named person with the transcript and a reasonWrites to the staff queue; sends the approved urgent-care text

Model and orchestration

  • Claude (Anthropic API) with tool use
  • Supabase Edge Functions (Deno) for the agent loop
  • Postgres for memory, logs and the approval queue

Channels

  • WhatsApp Business API (Meta Cloud API)
  • Website chat widget
  • SMS fallback for reminders

Systems

  • Practice management system (PHMS, Practo Ray, Cliniko) or Google Calendar
  • Google Sheets for the rulebook and the morning summary
04 · Guardrails

What keeps it safe to run on real data

Guardrails

  • A red-flag classifier runs before the agent, on every message, and its decision is not something the model can override.
  • The tool list is the permission list: there is no tool that reads a clinical record or writes a prescription, so the agent cannot be talked into either.
  • Bookings outside the rulebook (a doctor’s day off, a fourth reschedule) are refused and escalated rather than improvised.
  • Consent language for WhatsApp and intake is the clinic’s, approved before go-live.
  • The conversation log is reviewable per message, and the practice manager can mark any reply wrong, which feeds the weekly rule tightening.
05 · Result

What the reference build does, and the worked example of what it is worth.

What the build does

  • Holds a multi-turn booking conversation, including a change of mind mid-way, and books into a live calendar
  • Reschedules and cancels within a configurable limit, and refuses outside it with a handover
  • Answers hours, fees, directions and which-doctor questions from an editable knowledge base and nothing else
  • Recognises symptom-shaped messages and escalates with the approved text, with no triage attempted
  • Sends intake links and writes the answers to a draft record
  • Produces a morning summary of bookings, exceptions and escalations
Staff time on bookings, per day~4 hours → ~1.2 hoursWorked example
First reply to a patient messageNext morning → under a minuteWorked example
Share of booking conversations completed by the agent70% (design target; measured in a pilot)Target
Escalation of red-flag messages100% by design; tested against a 60-message red-flag set before each changeWorked example

Assumptions

  • Three doctors, about 60 booking-related contacts a day, four minutes of staff time each
  • The agent completes 70% within the rules; the remaining 30% still reach the desk, with context

What a pilot measures that this page cannot

  • No-show rate before and after reminders and confirmations
  • Slots backfilled from the waitlist
  • Median time from first message to confirmed booking
  • Escalations per hundred conversations, and how many were right

Want this agent for your clinic?

A pilot runs it on your data in two to three weeks for a fixed fee, measured against your own baseline. Thirty minutes to scope it, free.

Other case studies