CORTEXFLOW · FREE FOREVER

Chatbots

WhatsApp Business Support & Sales Chatbot

↓ Download workflow JSON

Import in n8n: Workflows → ⋯ → Import from file, then add your credentials. Free download with a free account.

How it works

  1. WhatsApp Trigger — fires on every incoming WhatsApp message via the WhatsApp Business Cloud API webhook.
  2. AI Agent — reads the message and drafts a reply as a support and sales assistant. If the customer asks for a human or a pricing call, it appends a [HANDOFF] flag to its reply.
  3. OpenAI Chat Model — gpt-4o-mini powers the agent’s replies (cheap and fast; swap for any model).
  4. Window Buffer Memory — keyed by the sender’s phone number, so each customer gets their own conversation history.
  5. IF Handoff Needed — checks the agent’s reply for the [HANDOFF] flag and routes the conversation accordingly.
  6. Format Handoff Summary — on the handoff path, packages the customer’s phone number, their last message, and the agent’s summary into one clean object.
  7. WhatsApp Agent Alert — on the handoff path, messages your agent’s number so a human can take over the chat.
  8. Slack Team Notify — on the handoff path, posts the handoff summary to your team channel so nothing gets missed.
  9. Send Agent Reply — on the normal path, sends the AI’s reply straight back to the customer on WhatsApp.

Set up steps

You’ll need:

  • n8n (self-hosted or cloud) with webhook access
  • A Meta developer account with a WhatsApp Business Cloud API app — create one at developers.facebook.com, go to My Apps, create a Business-type app, add the WhatsApp product, then copy your Phone Number ID and access token from WhatsApp → API Setup
  • An OpenAI account — get an API key at platform.openai.com → API keys
  • A Slack workspace for the team handoff alerts
  1. Download the workflow JSON using the download button on this page.
  2. In n8n, go to Workflows → ⋯ → Import from file and select the JSON.
  3. Create your WhatsApp credential — in n8n go to Credentials → New → WhatsApp API, paste the access token from your Meta app, and save. Then open WhatsApp Trigger and both WhatsApp send nodes and select this credential. In the two send nodes, also set your Phone Number ID as the sender.
  4. Create your OpenAI credential — in n8n go to Credentials → New → OpenAI, paste your API key, and save. Then open the OpenAI Chat Model node and select your credential.
  5. Create your Slack credential — in n8n go to Credentials → New → Slack, connect via OAuth, and save. Then open Slack Team Notify, select your credential, and set the channel name.
  6. Set your agent number — open WhatsApp Agent Alert and replace YOUR_AGENT_PHONE_NUMBER with the phone number (country code included, no +) that should receive handoff requests.
  7. Activate the workflow (toggle, top-right), then message your WhatsApp Business number to test it.

Note: WhatsApp lets you reply freely inside the 24-hour customer-service window. Business-initiated messages outside that window need an approved message template.

Customize it

  • Change when handoffs happen — edit the system message in AI Agent to change the rules for raising the [HANDOFF] flag (for example, hand off on refund requests or orders above a value).
  • Qualify buyers harder — extend the system prompt with your pricing, plans, and the exact questions every buyer must answer.
  • Tune the memory — raise or lower Context Window Length in Window Buffer Memory to remember more or less of each conversation.
  • Add a human-approval pause — insert a Wait node on the handoff path before the alert goes out, so a supervisor can review flagged chats first.

Workflow nodes

This workflow is built from 9 nodes. Here's what each one does:

#NodeTypeWhat it does
1 WhatsApp Trigger WhatsApp Trigger Starts the workflow when a WhatsApp message arrives.
2 AI Agent AI Agent The AI brain — reasons over the task and calls tools to get it done.
3 OpenAI Chat Model OpenAI Chat Model The language model powering the AI agent.
4 Window Buffer Memory Window Buffer Memory Gives the agent short-term chat memory across messages.
5 IF Handoff Needed IF Splits the flow into branches based on a condition.
6 Format Handoff Summary Set Holds editable configuration values — fill in your own settings here before activating.
7 WhatsApp Agent Alert WhatsApp Sends WhatsApp messages through the Meta Cloud API.
8 Slack Team Notify Slack Posts messages or reads data in Slack.
9 Send Agent Reply WhatsApp Sends WhatsApp messages through the Meta Cloud API.

Setup instructions

1. Add your credentials

In n8n go to Credentials → New, create each credential below, then open the named node and select it:

NodeCredential to add
WhatsApp Trigger WhatsApp Cloud API
OpenAI Chat Model OpenAI API
WhatsApp Agent Alert WhatsApp Cloud API
Slack Team Notify Slack OAuth2
Send Agent Reply WhatsApp Cloud API

How this workflow starts

  • WhatsApp Trigger: Fires automatically on its event — activate the workflow and connect the service.

Use cases

Customers message businesses on WhatsApp the way they message friends: they expect a reply in minutes, not the next business day. This template gives a small business an always-on front desk on its WhatsApp Business number. Every incoming message fires the trigger through the WhatsApp Business Cloud API webhook. An AI Agent drafts a reply with gpt-4o-mini. Window Buffer Memory, keyed by the sender's phone number, keeps each customer's thread continuous. The clever part is the handoff. When a human is needed, the agent appends a HANDOFF flag to its reply. On the handoff path, Format Handoff Summary packages the phone number, last message, and summary; WhatsApp Agent Alert pings the agent's number and Slack Team Notify posts to the team channel. It is built for shops, agencies, and services that get real questions on WhatsApp and cannot afford to miss the ones that need a human.

The boutique clothing store answering size and return questions

A boutique owner gets the same WhatsApp questions all day: do you have this in medium, what is your exchange policy, is the blue kurta back in stock. The AI handles these from the product knowledge in its system prompt. The moment someone writes I want a refund for my order, the agent raises the HANDOFF flag instead of improvising policy, and the owner gets the WhatsApp alert with the phone number, the last message, and the summary, and takes over the chat personally.

  • Variation: edit the system message so the HANDOFF flag also triggers on complaints containing words like damaged or wrong item, keeping every sensitive case human.

The real-estate brokerage qualifying buyers before site visits

A three-agent brokerage gets dozens of WhatsApp enquiries per listing, and agents waste weekends on viewings with unqualified buyers. The agent bot does the first pass: it asks about budget, preferred location, and timeline. When the buyer is qualified and asks to see the property, the HANDOFF flag fires, and the agent's phone gets the alert with the full qualification summary, budget stated, timeline, last message, so the callback starts warm instead of cold.

  • Variation: extend the system prompt with the brokerage's pricing and the exact qualifying questions every buyer must answer, so the handoff summary is consistent enough to sort leads by.

The D2C supplement brand handling repeat-order questions

A supplement brand's WhatsApp is full of repeat customers asking when their subscription renews, how to pause it, or whether the new flavor is in stock. The AI answers these from the FAQ knowledge in its prompt. Anything that smells like a complaint, a side effect, a damaged parcel, triggers the handoff: the alert goes to the founder's number and the summary posts to the team Slack, because those conversations need a human within the hour, not a bot's best guess.

  • Variation: tune the Context Window Length in the memory node up if customers tend to have long multi-day threads, so the bot does not forget last week's context mid-conversation.

The two-person travel agency fielding itinerary questions

A husband-and-wife travel agency gets WhatsApp enquiries with real complexity: 5 days in Kerala, two kids, vegetarian food, under 60k. The AI handles the back-and-forth beautifully, asking the clarifying questions and sketching options from the agency's knowledge. When the conversation turns to a custom quote, the HANDOFF flag fires and both partners get the picture: the WhatsApp alert on the phone and the summary in the team Slack.

  • Variation: set the handoff rule in the system message to trigger on trip value above a threshold, so small standard packages stay automated and only high-value custom trips pull in a partner.

The restaurant taking bulk and catering enquiries

A popular restaurant gets WhatsApp messages ranging from table for four tonight to catering for a 200-person wedding. The AI handles the routine end: timings, location, menu questions, and small-table interest, all answered instantly at any hour. The moment the enquiry mentions an event, a bulk order, or a custom menu, the HANDOFF flag fires, Format Handoff Summary packages the details, and the manager gets the WhatsApp alert to take over. The restaurant never loses a wedding booking to a seen-but-unanswered message again.

  • Variation: insert a Wait node on the handoff path before the alert goes out, so a supervisor can review flagged chats first during busy service hours.

← All templates