Skip to content
Brian Jiménez Landa
WhatsApp appointment bot and n8n automations, built in Apr 2026

A WhatsApp assistant that books dental appointments straight into Cal.com

I built a WhatsApp appointment assistant for a dental practice in Mexico. An AI agent in n8n checks open slots in Cal.com, then books, finds or cancels visits through a Node.js API I wrote. When the bot should not answer, it hands the chat to a person.

The problem

A dental practice in Mexico took appointment requests on WhatsApp by hand. Answering, checking the calendar, confirming and sending reminders took front-desk time. They also write times loosely, like "at 10" or "2:30 PM", while the calendar API works in UTC. And they tend to send several short messages in a row instead of one.

What I built

  • An AI agent in n8n that talks to patients on WhatsApp through Twilio. It works through separate tool sub-workflows: check open slots, book, find and cancel appointments, save the patient's details, and hand the chat to a person.
  • A Node.js and Express API with 27 endpoints on SQLite. Seven of them wrap Cal.com's v2 API: open slots, book, cancel, reschedule, list bookings, the next day's bookings and lookup by phone number.
  • Mexico City time handling in that API. A patient can write "10:00 AM" or "14:00" and the API converts it to UTC before it books. It finds a patient's bookings by phone number, normalized to the last 10 digits.
  • Chat sessions, agent memory, a conversation log, a patient register keyed by phone, and message deduplication in the same SQLite store. It took the place of Airtable in the flow.
  • A scheduled daily workflow that pulls the next day's bookings from Cal.com and sends each patient a WhatsApp reminder through Twilio.
  • A reworked version for bursts of messages. Each message lands in a PostgreSQL buffer, the workflow waits 6 seconds, and only the newest run merges the batch and answers once. It also caches the clinic's details and splits the work between an agent that calls the booking tools and a second agent that writes the reply.
  • On the same n8n server, flows for two other small businesses: one lists, reads and deletes Excel and PDF files on a services company's FTP server, and one runs a WhatsApp bot on Google Sheets.

How it works

I took the bot through five versions between January and April 2026. It started as fixed rules on Google Calendar. Next came an agent with retrieval over a Qdrant vector store, then an agent with Google Calendar and Sheets tools, then Cal.com behind my own API. The last version added the PostgreSQL buffer and the two chained agents. 24 n8n workflows belong to the bot across those versions.

The agent does not read open slots from its prompt. It calls a tool, the tool calls my API, and the API asks Cal.com. Each action the model can take is its own sub-workflow.

Cal.com works in UTC. The API converts Mexico City local time with a fixed UTC-6 offset, which holds because central Mexico dropped daylight saving time in 2022, and it sends America/Mexico_City to Cal.com when it asks for slots. It accepts 12-hour and 24-hour input, because patients use both.

Every message in the last version goes into a PostgreSQL table first. After a 6-second wait the run checks whether a newer message arrived, and only the last run in the burst merges the batch and replies. A cached copy of the clinic's details saves a lookup on each message. A worker agent calls the tools, and a responder agent turns its result into the WhatsApp reply.

It is self-hosted on a Linux server I run. n8n runs in Docker, PostgreSQL 16 containers on n8n's Docker network hold the agent memory and the message buffer, and the API runs under pm2.

Results

27
endpoints in the companion API, 7 of them wrapping Cal.com
5
versions of the bot between January and April 2026
24
n8n workflows built for the bot across those versions
6 s
buffer window that merges a burst of messages into one reply

Who else worked on it

Twilio, OpenAI and Cal.com are third-party services. Parts of the v3 agent workflow follow a public n8n template for Twilio and Cal.com; I replaced its Airtable storage with my own API. No patient data or client screens are shown here.

Full stack

n8n (self-hosted, Docker), n8n AI Agent with tool sub-workflows, OpenAI chat models, Twilio (WhatsApp), Cal.com API v2, Node.js, Express 4, better-sqlite3 (SQLite, WAL), PostgreSQL 16, Docker, pm2, Ubuntu Linux, FTP + Excel/PDF parsing (other flows), Google Sheets (other flows), Earlier versions: Google Calendar, Qdrant