Contact Us

Case study · Automation · Healthcare

Appointment Automation

A FastAPI platform for a dental clinic in Portugal that talks to patients on WhatsApp first, falls back to SMS, and keeps every action in sync with the clinic's appointment system.

  • Python & FastAPI
  • WhatsApp Cloud API
  • Twilio SMS
  • iMED GraphQL
  • Cron scheduling

At a glance

Channels: WhatsApp first, SMS as fallback
2
Reminder steps before the front desk steps in
3
Languages: Portuguese and English
2
  • Reminders
  • Confirm
  • Reschedule
  • Cancel
  • New booking

The project

Fewer manual reminders, fewer missed appointments

The clinic's front desk sent reminders by hand, so they were inconsistent and slow. Patients had no simple way to confirm, cancel or reschedule without calling.

We designed a platform that handles those conversations automatically, and writes every change to the real appointment so the bot and the clinic's system never drift apart.

01

Manual reminders

Reminders were sent by hand, which made them inconsistent and time-consuming.
02

Calls to change plans

Patients could not confirm, cancel or reschedule without phoning the clinic.
03

Not everyone is on WhatsApp

A WhatsApp-only solution would have left gaps, so SMS was built in as a fallback.
04

Two languages

Portuguese and international patients each needed messages in their own language.
05

One source of truth

Every patient action had to update the real appointment in iMED, not just the bot.
06

A record for staff

Staff needed to see what was sent to each patient and how they responded.

The platform

What we built

01 / 06

Reminders & escalation

Reminders that run themselves, and a clear path when a patient does not reply.

  • A first reminder 48 hours before, with Confirm, Reschedule and Cancel options
  • A second, friendlier reminder if there is no response
  • An SMS asking the patient to contact the clinic if there is still none
  • A reminders table so no patient is reminded twice

The work

Engineering challenges & solutions

The hardest problems sat at the edges: message payloads, matching IDs between systems, and making sure each patient action counted once.

  1. Template buttons got no response

    Template buttons sent a different payload from normal interactive replies, so taps were ignored.

    What we built

    The webhook handler was extended to process both button types and carry the appointment ID in the payload.

  2. Reschedules rejected by iMED

    iMED rejected reschedule requests with an APPOINTMENT_NOT_FOUND error.

    What we built

    IDs were traced between local and iMED records, and the lookup fixed so the correct patient number and appointment ID are used.

  3. Contradictory actions

    Patients could press Cancel after pressing Confirm.

    What we built

    State checks were added so only the first action on a reminder is accepted.

  4. Incomplete time lists

    Time lists showed only a sample of the available slots.

    What we built

    Sampling was replaced with the full slot list in one scrollable menu.

  5. Duplicate or mistimed reminders

    Reminders risked being sent twice or at the wrong time.

    What we built

    A reminders table records what was sent, with a protected endpoint called by a cron job every 15 minutes.

  6. Wrong language

    Some patients' phone codes did not match their nationality.

    What we built

    Language selection now uses nationality first and the phone prefix second.

Technology

Technology stack

Backend

  • Python
  • FastAPI

Messaging

  • WhatsApp Cloud API
  • Meta Graph API v23.0
  • Twilio SMS

Integration

  • GraphQL (iMED)
  • Webhooks

Data

  • SQL database

Scheduling

  • Linux cron

Hosting

  • Ubuntu server on AWS

Outcome

What the clinic now has

  • Reminders on a schedule

    Reminders and escalation run automatically, without front-desk effort.

  • Self-service for patients

    Patients confirm, cancel, reschedule and book on WhatsApp or SMS without calling.

  • Systems in sync

    Changes by patients and by staff are kept in sync with iMED.

  • A full history

    Staff can see the communication history for each appointment.

Want to automate appointments and reminders?

WhatsApp and SMS flows connected to your booking system, with a record of every conversation. Tell us what you're running.

Let's Engineer What's Next

Let's Build Something That Moves Business Forward

Have a complex challenge, ambitious idea or system that needs engineering? Let's discuss how we can make it happen.

Prefer email? info@codenomad.net

CodeNomad

Built to Scale. Designed to Work.