A flow engine that waits for people
WhatsApp AI sales platform · Node.js, TypeScript, Cloud Functions, Pub/Sub · 2022 to today
Problem
A visual Flow Builder lets non-engineers design conversations. Once published, each flow has to run as a stateful WhatsApp conversation, and people do not answer on a schedule. A flow must stop and wait for a reply, then continue, or give up and take a recovery path if the customer goes quiet.
What I built
- Most of the backend: publishing, versioning, execution, history, simulation and observability for flows.
- The pause and resume runtime. A wait component stops the flow and creates a timed task. If the customer replies, the task is deleted and the flow resumes. If not, the task fires and runs the recovery path.
- A hardening pass on delivery. Meta can send the same webhook twice, which inflated campaign counts. Fixed with transactional claims and a single metrics writer. Also kept template attribution working when Meta started sending identity events without a phone number.
- An LLM-based test lab. Scenarios (typical, edge, out-of-domain, stress) are derived from past conversations, run in a WhatsApp-aware simulator and scored automatically.
Result
Reworked the path from inbound message to customer and conversation lookup: removed repeated queries and batched what could be batched. Response time went from 10s+ to about 1s. I now also own campaign sending.
Trade-offs
Timed tasks are cheap and simple, but every task needs a clear owner and a clear delete path, or replies race with timers. I kept one place that decides whether a flow resumes, so a late timer and a late reply cannot both win.