WhatsApp Chatbot Development With an AI Agent Node
How to design a WhatsApp chatbot that combines predictable flow nodes with an AI agent node for open questions, including state handling, exit conditions and CRM writes.
WhatsApp chatbot development has split into two camps. One builds rigid menu bots ("Reply 1 for pricing") that frustrate anyone with a real question. The other plugs a language model straight into the inbox and hopes it behaves. Neither works well for a business that needs both reliability and natural conversation.
On Antoc, a real-estate CRM used by 100+ firms, we built a visual WhatsApp flow builder where an AI agent is one node among many. Fixed steps stay fixed, and the AI only takes over where conversation is genuinely open-ended. This post explains how to design that kind of hybrid bot.
TL;DR
Model the chatbot as a flow of nodes triggered by events. Use deterministic nodes for messages, delays, conditions and CRM updates. Add an AI agent node with a narrow goal, scoped context, a few tools and explicit exit conditions. Store per-contact flow state, and always provide a human handoff.
key takeaways
- The best approach to WhatsApp chatbot development is hybrid: fixed nodes for predictable steps and an AI agent node only where conversation is open-ended.
- An AI node needs a narrow goal, scoped knowledge, a small set of tools and explicit exit conditions back into the flow.
- Flow state must be stored per contact so delays, reminders and replies resume in the right place.
- Business users should be able to edit flows visually without touching the AI configuration underneath.
The building blocks of a flow
A flow is a directed graph. It starts at a trigger and moves through nodes based on events and conditions. These are the node types I consider essential:
| Node type | Purpose | Example |
|---|---|---|
| Trigger | Starts the flow | Incoming message, new lead, reminder, pipeline stage change |
| Send message | Sends text, media or a template | Project brochure, greeting |
| Wait / delay | Pauses for time or a reply | Wait 2 days, wait for reply up to 24h |
| Condition | Branches on data | Lead source is Meta ads, budget above a value |
| Buttons / list | Structured choices | "Book visit", "Talk to sales", "More details" |
| CRM action | Updates the record | Change stage, assign owner, add tag |
| AI agent | Handles open conversation | Answer questions, collect details |
| Handoff | Routes to a human | Assign and pause automation |
Triggers matter most because they decide when automation runs. A "new lead" trigger fires when a lead lands from any source. A "pipeline stage" trigger fires when sales moves a lead to, say, site visit done, which is a natural moment for a feedback message.
Drips are just flows with delays
A Day 0, Day 2, Day 7 nurture sequence is a chain of send and wait nodes, with a condition before each send that checks whether the lead has replied or progressed. If a salesperson has already moved the lead forward, the drip should stop rather than send an out-of-date nudge.
Designing the AI agent node
The AI node is where most teams overreach. A good one is configured like a tightly scoped employee, not a general assistant.
Here is the checklist I use for every AI node:
- Goal: one sentence, such as "Answer questions about this project and find out the buyer's budget and preferred configuration."
- Context: only what it needs, like the project's details, pricing ranges the business is happy to share, and the lead's name and source.
- Tools: a small set, for example
save_qualification,book_site_visit,request_human. - Exit conditions: goal achieved, handoff requested, a set number of turns reached, or no reply within a time limit.
- Fallback: what the flow does next on each exit path.
- Tone and language: follow the customer's language mix and keep replies short, because WhatsApp is a chat app, not email.
The exit conditions are what make the hybrid work. When the AI node finishes, the flow moves to the next node, which might be a CRM action, a delay or a handoff. The AI never wanders off and owns the conversation forever.
Respect WhatsApp's rules inside the AI node
The AI node can send free-form replies only within the 24-hour customer service window. If the customer goes quiet and the window closes, the flow must fall back to an approved template. I enforce this in the send layer so the model cannot accidentally break the rule. Meta's messaging documentation covers the details.
State, concurrency and handoff
Every contact in a flow has state: current node, variables collected so far, when the next wait expires, and whether automation is paused. I store this per contact per flow, and a scheduler resumes waiting flows when delays expire.
A few rules prevent chaos:
- One active flow per contact per trigger type, so a contact does not receive two greetings from overlapping flows.
- Replies route to the waiting node, not to a fresh flow start.
- Human takeover pauses automation for that contact until the agent closes or releases the conversation.
- Idempotent sends, so a retry never sends the same message twice.
How I built this in practice
In Antoc, the flow builder supports triggers on incoming messages, new leads, reminders and pipeline stage changes, with Day 0/2/7 nurture drips as a standard pattern and an AI agent node for open conversation. Flows run on top of the lead-capture layer, so a lead from a Meta ad or a property portal passes through duplicate detection and auto-assignment before any message goes out.
The backend is Node/Express with MongoDB, with Socket.IO updating the shared inbox in real time when the bot or a human replies. The AI node uses the same model integrations as the rest of Antoc's AI features. A separate project, an Instagram DM automation tool on the official Instagram API, used the same idea of visual flows built with reactflow plus a Gemini step, which confirmed that the hybrid pattern carries across channels. Details are in the Antoc case study, and the real-estate industry page shows how this fits a property sales process.
Common mistakes
- Building a pure menu bot that cannot handle any question outside the buttons.
- Giving the AI node the entire knowledge base and no clear goal.
- No exit conditions, so the AI keeps the conversation forever and the flow never continues.
- Letting drips continue after a salesperson has already moved the lead forward.
- Overlapping flows that send a contact multiple greetings at once.
- No pause on human takeover, so the bot replies over a live salesperson.
keep reading
FAQ
Should my WhatsApp chatbot be fully AI or rule-based?+
For most businesses, neither alone. Rule-based flows are predictable for greetings, menus, reminders and drips, while an AI agent handles free-form questions. A hybrid gives control where it matters and flexibility where customers ask unexpected things.
What does an AI agent node do in a WhatsApp flow?+
It hands the conversation to a language model with a specific goal, context and tools, such as answering project questions or collecting qualification details. When the goal is met or a handoff condition triggers, the node exits and the flow continues.
How much does WhatsApp chatbot development cost?+
A simple flow-based bot on top of an existing WhatsApp integration can take a couple of weeks. A full visual flow builder with triggers, delays, AI nodes and CRM integration is a larger product feature that usually takes a few months.
Can the chatbot hand over to a human agent?+
Yes, and it should. A handoff node or AI tool assigns the conversation to a team member, pauses automation for that contact and notifies the assignee, so the customer never gets bot replies while talking to a person.
Devang Gandhi
AI & full stack developer at Passdn, building CRMs, SaaS, AI agents and Flutter apps for clients in the US, UK, Australia, UAE and India. More about me