TIDESa civilization in progress

ArticleWorked example

Building a WhatsApp enquiry agent for a clinic: a full walkthrough

A worked, hypothetical example. We invent a small clinic and design its WhatsApp enquiry agent step by step: the job, the limits, the knowledge, the tools, the conversation flow, the health-specific safety rules, and the testing.

Key points

  • Start from the questions the reception desk already answers every day, not from what the technology can do.
  • Write down what the agent may not do before you write what it may do.
  • Three tools are enough: check slots, book an appointment, hand over to a person.
  • In health, the agent never gives medical advice, and any sign of an emergency goes to a phone number at once.
  • Test with real, messy messages before launch, and read the conversations every week after it.

1. The clinic in this example

This is a hypothetical example. The clinic below is invented for illustration only. It is not a real clinic, not a client, and the details are chosen to make the design decisions easy to follow.

Picture a small family clinic in Lahore with three doctors, one receptionist and a WhatsApp number printed on the signboard. Most patients message before they call. They ask about timings, fees, which doctor sits on which day, and whether they can come today.

The receptionist answers these between phone calls and walk-in patients. Messages sent at night wait until morning. Some are never answered, and those patients go elsewhere. That is the problem the agent is meant to solve, and nothing more.

2. What the clinic needs

Before choosing any tool, list what the reception desk is asked. For a clinic like this, a week of messages would mostly fall into a few groups: timings and location, consultation fees, which doctor to see for a general kind of visit, booking or moving an appointment, and what to bring.

From that list, the job writes itself. The agent answers routine enquiries at any hour, books appointments into free slots, and passes everything else to the receptionist with a short summary.

Notice what is not on the list. The agent does not diagnose, does not discuss test results, does not handle billing disputes and does not replace the receptionist. A narrow job is easier to build and much easier to trust.

3. What the agent may and may not do

Write the limits first. In a clinic, the cost of a wrong action is higher than in a shop, so the list of forbidden things is longer than the list of allowed ones.

  • May: answer questions on timings, location, fees, doctors' schedules and what to bring, using only the clinic's own information.
  • May: offer free slots and book one, after repeating the details back and getting a clear yes.
  • May: hand the conversation to the receptionist at any point.
  • May not: give medical advice, suggest medicines or doses, or interpret symptoms, reports or test results.
  • May not: promise an outcome, a waiting time or a discount.
  • May not: cancel or move another person's appointment, or share any patient's details with anyone.
  • May not: pretend to be a person. It says it is the clinic's automated assistant in its first message.

Each "may not" line should be enforced by what the agent has access to, not only by its instructions. An agent with no access to patient records cannot leak them.

4. The knowledge it needs

The agent's knowledge is small and should stay small. One well-kept document is enough to begin: opening hours for each day, the address with a landmark, each doctor's name, field and sitting days, consultation fees, accepted payment methods, and standard instructions such as bringing previous reports.

Write it as short question-and-answer entries in the words patients use. Many will write in Roman Urdu or mix Urdu and English, so include those phrasings. "Doctor sahab kab bethte hain" should find the timings entry as easily as "what are the timings".

Keep live facts out of the document. Whether a slot is free at five o'clock today is not knowledge. It changes every minute, so it belongs in a tool that checks the calendar. Fees and timings change rarely, but they do change, so the document needs an owner at the clinic and a date on it.

5. The three tools

This agent needs three tools. Each has a narrow purpose, checked inputs and a clear reply.

  • check_slots: takes a doctor and a date, and returns the free appointment times. It reads the calendar and changes nothing.
  • book_appointment: takes a doctor, a date, a time, the patient's name and phone number. It returns either a confirmation with a reference, or a failure with the reason, such as the slot having just been taken.
  • hand_over: takes a short summary and a reason. It alerts the receptionist, marks the conversation as needing a person, and stops the agent replying on that chat until the receptionist releases it.

The agent may say "booked" only after book_appointment returns a confirmation, and it repeats the details from the tool's reply, not from memory.

6. How the pieces connect

The plumbing is straightforward. The clinic's number runs on the WhatsApp Business platform, which can forward each incoming message to your system. A workflow tool such as n8n, or a small program, receives the message, loads the recent conversation, and passes it to the agent with its instructions and tools.

The agent decides whether to answer from the knowledge document, call a tool, or hand over. Its reply goes back through the same channel. Every step is logged: the message, what the agent retrieved, which tool it called and what came back.

Two practical details matter. Check the platform's current rules on when a business may message a customer first, because reminders and follow-ups depend on them. And store as little patient information as the job needs: a name, a phone number and an appointment time are enough.

7. The conversation flow, with samples

The flow has four moves: greet and say what the assistant is, understand the request, answer or act, and confirm or hand over. Here is a routine booking.

Patient: "Salam, kal child specialist available hain?" Agent: "Wa alaikum salam. I am the clinic's automated assistant. Yes, the child specialist is in tomorrow evening. Free times are 5:00, 5:30 and 6:15. Which would you like?" Patient: "5:30". Agent: "Please share the patient's name so I can book it." After the name arrives, the agent calls the booking tool and replies: "Booked: tomorrow, 5:30 pm, child specialist, under the name you gave. Please bring any previous reports and arrive ten minutes early."

Here is a request the agent must refuse. Patient: "Mere bete ko 2 din se bukhar hai, kaunsi dawai doon?" Agent: "I am sorry he is unwell. I am an automated assistant and cannot advise on medicines. A doctor needs to see him. I can book the earliest slot with the child specialist, or connect you to our reception now. Which would you prefer?" The agent is kind, it is clear about its limit, and it offers the two things it can do.

And here is an emergency. Patient: "My father has chest pain and is sweating a lot, can I get an appointment today?" Agent: "This may be an emergency. Please do not wait for an appointment. Call the clinic now on the number in this chat's profile, or go to the nearest hospital emergency department immediately. I am alerting our staff as well." The agent then calls hand_over with the reason marked urgent. It does not offer slots.

8. Safety limits specific to health

The two refusals above are the core of the design. They should not rest on the model's judgement alone.

For medical advice, the instruction is absolute: no medicines, no doses, no opinion on symptoms or reports, no reassurance that something is "probably nothing". Reassurance is advice too. The agent's only response to a health question is to route the patient to a doctor.

For emergencies, add a check in code that runs before the agent replies. If a message mentions signs such as chest pain, difficulty breathing, heavy bleeding, unconsciousness, a seizure or thoughts of self-harm, the system sends the emergency reply and alerts staff, whatever the agent would have said. The clinic's doctors should write and approve this list, not the developer. It is better for this check to trigger too often than to miss one case.

  • The emergency reply always contains a phone number and the instruction to go to a hospital.
  • The agent never tells a patient that waiting is safe.
  • Outside clinic hours, the emergency reply does not depend on staff being available.
  • Patient details are never repeated to a different phone number.

9. Testing before launch

Test with the messages patients would send, not the ones a developer would type. Collect a set of realistic messages with the receptionist's help, including spelling mistakes, Roman Urdu, voice-note style rambling and several questions in one message.

Then test the hard cases on purpose. Ask for medical advice in ten different ways. Describe emergencies in plain and indirect words. Try to book a slot that is already taken. Ask about another patient's appointment. Tell the agent to ignore its instructions. Switch off the calendar and confirm that the agent reports a problem instead of inventing a booking.

Before going public, run the agent in a supervised period. It drafts each reply and the receptionist approves or corrects it before it is sent. This is slower, but it shows exactly where the agent and the clinic disagree, and those corrections become new test cases.

10. What to watch after launch

Launch is the start of the work. In the first weeks, someone at the clinic should read the conversations daily, then a sample each week.

  • Handover conversations: were they necessary, and did the receptionist pick them up in time?
  • Unanswered questions: anything the agent could not answer is a gap in the knowledge document.
  • Bookings: does every confirmed booking in chat exist in the calendar?
  • Safety replies: did every medical question get the refusal, and every emergency the urgent reply?
  • Changes at the clinic: a new doctor, a new fee or holiday timings must reach the document the same day.

The same pattern, a narrow job, a few checked tools and a clear handover, fits a school office or a shop just as well. Learners in the TIDES bootcamp build agents and automation workflows with n8n, LangChain and CrewAI.

Learn to build this.

Four months, hands-on, in Lahore. Admissions are open.