Skip to main content
Back to Devlog

Automation // READY

WhatsApp Automation for Real Clients

WhatsApp automation sounds simple until you deploy it for a real business. The demo works perfectly: user sends 'hi,' bot responds with a menu, user picks an option, bot confirms. Real conversations are nothing like that.

A patient at a dental clinic writes: 'oi, quero saber se o doutor atende amanhã pq minha filha tá com dor de dente desde ontem e não consegui dormir.' That's not a clean intent. It's a booking request, an urgency signal, a child patient indicator, and an implicit expectation that someone will respond with empathy — all in one message.

Building ClinicaSync IA taught me that WhatsApp bots need three layers: a conversational layer (understanding messy human text), a business logic layer (checking calendars, validating insurance, routing to specialists), and an empathy layer (acknowledging urgency, adjusting tone, knowing when to escalate to a human).

The technical architecture uses the WhatsApp Business API with webhook endpoints built in Node.js. Incoming messages hit a classification endpoint that uses OpenAI's API to extract intent and entities. But here's what most tutorials skip: you need a state machine per conversation. A patient might start booking, get interrupted, come back two hours later, and expect the bot to remember where they left off.

I store conversation state in a lightweight key-value store keyed by phone number, with a TTL of 24 hours. Each state has a defined set of valid transitions: GREETING → INTENT_CAPTURE → ENTITY_EXTRACTION → AVAILABILITY_CHECK → CONFIRMATION → BOOKED. If a message doesn't match any valid transition, the system asks a clarifying question instead of guessing.

The 1-hour pre-appointment reminder was the feature with the highest impact. Before automation, the clinic had a 30% no-show rate. After adding automated WhatsApp reminders — 'Olá Maria! Sua consulta com Dr. Silva é amanhã às 14h. Confirma? Responda SIM ou REAGENDAR' — the no-show rate dropped to under 5%. That's the kind of metric that sells the next project.

The same architecture powers BarberFlow Pro (barbershop scheduling), JusTriagem IA (legal intake), and OmniAtende CRM (multi-agent sales inbox). The core engine is reusable — what changes between implementations is the domain vocabulary, the entity types, and the business rules. A barbershop needs 'barber name' and 'service type.' A law firm needs 'case category' and 'document checklist.' The conversation flow is structurally identical.

One hard lesson: never auto-reply to a message that contains emotional distress without a human review flag. A patient writing about severe pain should not get a cheerful 'Escolha um horário!' response. We added sentiment analysis as a pre-filter — if the message scores high on urgency or negative sentiment, it routes directly to a human operator with the full conversation context.

The business model for WhatsApp automation is straightforward: charge a setup fee for the initial configuration plus a monthly fee for hosting, maintenance, and message volume. Clients see ROI within the first month because the cost of one no-show appointment typically exceeds the entire monthly subscription.

Building notes by Lucas Martins, founding developer at LookADev.

Read more notes