An AI sales agent in n8n that takes orders and scores leads on WhatsApp and Messenger

For an e-commerce brand in Bangladesh, I built an AI sales agent in n8n. It chats with customers on WhatsApp and Messenger in Bangla: it answers product questions from the shop's catalog, reads photos and voice notes, confirms orders into a Google Sheet and scores every lead. When someone from the team replies, the bot steps aside.

Published Made for a Bangladeshi e-commerce brand

Problem

What does a shop's chat have to handle?

An online shop lives in its chat inbox. Every day customers ask about products, send photos, confirm orders and expect a fast answer, while the team also has to ship the orders and follow up the people who are ready to buy.

  • Many short messages

    People do not write one tidy message. They send "hi", then the product, then the size, then "price?" in four separate lines. A bot that answers each line alone sends four replies, some of them wrong, because it has not seen the whole question yet.

  • Photos and voice notes

    A customer sends a screenshot of a product from an ad, or a voice note instead of typing the name. Plain text bots ignore both. The product has to be found in the shop's own catalog, or the customer gets no useful answer.

  • Orders typed into a chat

    A customer says "I will take it" inside the chat. The name, address, area, quantity and amount then have to be copied by hand into a sheet for shipping, and a missing detail means another round of messages.

  • Buyers and browsers look the same

    Chats pile up. Someone who has written ten messages and someone who asked one question sit in the same inbox, and the team cannot see who to follow up first.

  • Bot and team talk over each other

    A complaint, a sensitive question or a customer who asks for a call needs a person. If a team member steps into the chat while the bot keeps replying, the customer gets two answers, and the shop looks careless.

Solution

What did I build? One AI agent that answers like the shop on two channels.

I built one AI sales agent in n8n, as two workflows with the same steps: one for WhatsApp, one for Messenger. It answers in Bangla from the shop's own product catalog (RAG), confirms orders, saves them in a Google Sheet and scores every lead. On WhatsApp it also follows the shop's rules document.

  1. Reads all messages, replies once

    Each message goes into a buffer and the workflow waits 15 seconds. If a newer message arrives, the older run stops and only the newest run continues. When the customer stops typing, the agent reads every message together and sends one reply. Photos and voice notes join the same buffer.

  2. Understands photos and voice

    A vision model finds which product is in a photo and checks it against the catalog. If it is not one of the shop's products, the customer is told politely. Voice notes are turned into text first, then handled like typed messages.

  3. Confirms the order, fills the sheet

    The agent collects the order details in the chat and confirms them with the customer. A confirmed order is written to a Google Sheet row: name, address, area, quantity and amount, ready for the team to ship.

  4. Scores every lead

    Every customer is saved as a lead and scored by how many messages they have sent, so the team sees who is most interested and can follow up the warm chats first.

  5. Hands over to the team, then steps back

    Every bot reply is flagged for 30 seconds. A message from the shop's own account without that flag is a person, so the bot pauses for that customer. If the customer writes again and nobody answers within 10 minutes, the bot answers. On WhatsApp the AI can also alert the care team and say why.

The workflow

How does the agent work, step by step?

This is the real n8n workflow, node by node, from the moment a message arrives to the reply. Tap any node to see what it does, or press a path to watch one message travel through it.

sales-agent-whatsapp · 88 nodes
VIEW ONLY · drag to pan · Ctrl + scroll to zoom
Trace a path
  1. Tap a node to see what it does, or pick a path to watch one message travel through the real workflow.

Built to be safe

  • Answers from the shop's dataProduct facts come from the shop's catalog in a vector database. On WhatsApp the replies also follow the shop's own rules document.
  • One customer, one replyOnly the newest message in the buffer carries on. Older runs stop themselves, so a burst of messages never produces a burst of answers.
  • The bot steps back for peopleA reply from the team pauses the bot for that customer. After 10 minutes of silence from the team the workflow checks again: if a person already handled it, the bot stays out; if not, the bot answers.
  • It knows its own messagesEvery bot reply is flagged for 30 seconds, so the agent never mistakes its own message for a person on the team.
  • No guessingA photo of another brand's product, a sticker or a location gets a polite reply, not a made-up answer.

Tools used

Which tools does this n8n sales agent use?

  • n8nRuns both workflows, every step on one canvas
  • WasenderAPIConnects the shop's WhatsApp number to n8n
  • Messenger APIFacebook's Graph API, for the shop's Messenger inbox
  • OpenRouterThe chat model, the vision model that reads product photos, and speech-to-text for voice notes
  • OpenAI embeddingsTurn products and rules into vectors for search
  • Postgres + PGVectorMessage buffer, leads, chat memory and the vector database for RAG
  • RedisThe message buffer for Messenger
  • WooCommerceWhere the product catalog comes from
  • Google SheetsWhere confirmed orders are written for the team

FAQ

Questions business owners ask.

What can an AI sales agent do for an online shop on WhatsApp and Messenger?

It answers product questions from the shop's own catalog, reads photos and voice notes, confirms orders into a Google Sheet, scores every customer as a lead, and hands the chat to a person when the team steps in. It runs as two n8n workflows with the same steps: WhatsApp through WasenderAPI, Messenger through Facebook's Graph API.

How does the agent read several messages and send only one reply?

Each message is stored in a buffer and the workflow waits 15 seconds. When the wait ends it checks for a newer message. If one arrived, this run stops; only the run for the newest message loads the whole buffer, answers once and clears it. Photos and voice notes become text and join the same buffer.

How does the human handover work?

Every message the bot sends is flagged for 30 seconds. Any other message sent from the shop's own account is a person, so the bot pauses for that customer. If the customer writes again and nobody answers within 10 minutes, the workflow checks the chat once more: if a person replied, the bot stays out; if not, it answers. On WhatsApp the AI can also alert the care team and say why.

Why does the bot not mistake its own reply for a team member?

Because it marks its own messages. The shop's account sends both the bot's replies and the team's manual replies, so the bot sets a 30-second flag on each message it sends. A sent message without that flag can only be a person.

Can it take and confirm orders?

Yes. The agent collects the order in the chat and confirms it with the customer. A confirmed order is written to a Google Sheet row with name, address, area, quantity and amount, so the team can ship without copying anything by hand.

How does it score leads?

Every customer is saved as a lead. The score grows with how many messages they have sent, so the team can see who is most interested and follow up the warm chats first. The scoring rule can be changed to fit how your shop sells.

What happens when a customer sends a product photo?

A vision model looks at the photo, ignores ad text, and says which product it shows. That name is checked against the shop's catalog. If it matches, the agent answers about that product; if not, the customer is told politely that it is not one of the shop's products.

Can customers send voice notes?

Yes. A voice note is turned into text first, then treated like a typed message and added to the same buffer.

Where do the answers come from? Can the AI make things up?

From the shop's own data. The product catalog is loaded from WooCommerce into a vector database, and on WhatsApp the rules document is loaded the same way, through an upload form. The agent searches these before it answers (RAG). Unknown products, stickers and locations get a polite reply, not a guess.

Does it remember the conversation?

Yes. It keeps the last 20 messages of each chat, so a customer does not have to repeat themselves.

What language does it reply in?

Bangla, because this shop's customers write in Bangla. The instructions can be changed to English or another language.

Does it need the official WhatsApp Business API?

No. The shop's own WhatsApp number connects to n8n through WasenderAPI. Messenger uses Facebook's own API for the shop's page.

Can it work with Shopify instead of WooCommerce?

Yes. Only the step that loads the product catalog changes; the rest of the workflow stays the same.

Can this be built for my shop?

Yes. Tell me where your customers message you and what they ask most. After a short call you get a one-page plan and a fixed price.

Your turn

Too many chats for your team to answer?

Tell me what takes too long. After a short call you get a one-page plan and a fixed price.

How this page was made: written by me from the real build. The client's name is kept private.