# 04 · Chatbot and workflows

**Purpose:** build a chatbot that answers customers on WhatsApp by itself, test it safely, and switch it on when you are happy.

## Before you start

- A connected number (see [01 · Getting started](https://v3.wsapme.com/guides/getting-started.md)).
- Know that **a chat runs one flow at a time**, and a reply from your team stops the flow in that chat.

> The screenshots use a demo workspace with Demo mode on. In this guide the flows were built and tested but **never published**, so no customer received anything.

## Two ways to build

| | **Simple sequence** | **Canvas flow** |
|---|---|---|
| What it is | Messages one after another (text, photos, videos, AI messages, testimonials) with a short "typing…" pause between them | A visual map with branches: menus, questions, conditions, tags and hand-over to your team |
| Good for | A welcome message or a short series | Menus, qualifying leads, order status, bookings |
| Branches | No | Yes |

1. In the sidebar, under **Automation**, click **Workflows**. (Workflows that already exist are listed with **On** or **Draft**.)
2. Click **New workflow**.

   ![The Workflows list with New workflow highlighted](https://v3.wsapme.com/guide-media/img/chatbot-workflows/01-workflows-list.webp)

3. Pick a starting point. **Simple sequence** is at the top. Below it, under **Or a canvas flow with branches**, choose a ready-made template (**Welcome menu**, **Lead qualification**, **Order status**, **Appointment booking**) or **Blank workflow**.

   ![The New workflow choices](https://v3.wsapme.com/guide-media/img/chatbot-workflows/02-new-workflow-choices.webp)

You can change all the texts and the trigger afterwards. A new workflow starts as a **Draft** and does nothing until you switch it on.

## Part 1 · Set when it starts (the trigger)

After you pick a template you see the message **Workflow created. Check the trigger, then switch it on.**

1. On the workflow page, check the **Name**.
2. In **Starts when**, choose what starts the flow. The options include **Message contains a keyword**, **First message from a new contact**, **Any message (when no other flow matches)**, **Started by hand**, **A lead is created**, **A tag is added to a contact**, **A sales page form is submitted**, **Someone replies to a broadcast**, **Came from an ad or link** and more.
3. Optional: tick the **WhatsApp numbers** it should run on (none ticked means all numbers), and set **Don't start again for the same contact within (minutes)**.
4. Click **Save** under the trigger.

   ![The trigger section with Starts when and Switch on highlighted](https://v3.wsapme.com/guide-media/img/chatbot-workflows/03-workflow-trigger.webp)

On the right, **Steps** lists what the flow does in order. Click **Edit steps** to open the canvas.

## Part 2 · The canvas

**Watch first (4 min, Malay narration and captions):** [Build a canvas flow](https://v3.wsapme.com/guide-media/video/04-workflow-flow-malay.mp4). A welcome menu with three choices: send prices and add a tag, send delivery details, or hand the chat to the team, then a test in the simulator. Nothing is published or sent.

1. The toolbar has **Add step**, **Not published** (shows whether the flow is live), undo and redo arrows, **Sequence**, **Arrange**, **Stats**, **Test**, **Save draft** and **Publish**.
2. Select a step to edit it in the panel on the right. Drag from a dot on a step's edge to another step to connect them. Each answer can lead somewhere else. Select a connection or step and press **Delete** to remove it.

   ![The canvas toolbar](https://v3.wsapme.com/guide-media/img/chatbot-workflows/04-canvas-toolbar.webp)

3. Click **Add step** to see all the step types: **Send message**, **WhatsApp template**, **Menu**, **Ask a question**, **Condition**, **Detect intent**, **A/B split**, **Tags**, **Assign**, **Move lead**, **Start a follow-up**, **HTTP request**, **Wait**, **Wait until**, **AI reply**, **AI write**, **Matching testimonial**, **Hand to team**, **Go to another workflow** and **End**.

   ![The Add step menu](https://v3.wsapme.com/guide-media/img/chatbot-workflows/05-add-step-menu.webp)

   **Matching testimonial** sends real customer testimonials from **AI Agent → Testimonials** (the photo with its quote) and from your live sales pages. Match them to an answer, the contact's tags, a contact field or one testimonial topic, and choose how many to send (up to 3). A customer never gets the same testimonial twice, from a workflow or from the AI agent. When nothing fits, the step takes its **No match** path.

### Videos: every step type with an example

Five short videos with Malay narration and captions. Each one builds a draft flow for a made-up business, explains when to use each step, and tests it in the simulator. Nothing is published or sent.

**Watch first (4 min, Malay narration and captions):** [Ask and decide](https://v3.wsapme.com/guide-media/video/04-workflow-actions-ask-branch-malay.mp4). **Ask a question** saves the answer, **Detect intent** sends prices and delivery questions down their own paths, and **Condition** checks the saved answer (more than 5 cakes goes to the team).

**Watch first (3 min, Malay narration and captions):** [Organise leads automatically](https://v3.wsapme.com/guide-media/video/04-workflow-actions-organise-malay.mp4). A lead from an ad gets **Tags**, **Move lead** to a pipeline stage, **Assign** to the next team member, **Start a follow-up**, and **Hand to team** when the follow-up cannot start.

**Watch first (4 min, Malay narration and captions):** [Timing, A/B tests and linking workflows](https://v3.wsapme.com/guide-media/video/04-workflow-actions-timing-malay.mp4). **Wait until** Saturday 10 AM, an **A/B split** of two promo messages, **Wait** for a reply, **Go to another workflow** and **End**.

**Watch first (4 min, Malay narration and captions):** [AI and content steps](https://v3.wsapme.com/guide-media/video/04-workflow-actions-ai-content-malay.mp4). **AI reply** with its hand-over exit, **Matching testimonial**, **AI write** with a fallback message, and a **WhatsApp template** for official numbers. The simulator skips the AI steps, so no credits are used.

**Watch first (3 min, Malay narration and captions):** [Connect to other systems](https://v3.wsapme.com/guide-media/video/04-workflow-actions-http-malay.mp4). **Ask a question** for an order number, an **HTTP request** that saves the order status from the reply, and what happens when the request fails. The simulator does not call the address.

## Part 3 · Wait for a reply

1. Click **Add step**, then **Wait**.
2. Under **This step**, choose **Waits for a reply** (the other choice, **Pauses for a set time**, waits from 1 second to 30 days and then goes on; with **Seconds** it can show "typing…" meanwhile). Any message from the lead before the time is up counts as a reply.
3. Set **Wait up to** (a number and a unit such as **Hours**).
4. Optional: **Save the reply as** a name (default `reply`) to use later as `{{reply}}`.
5. Under **If the lead does not reply in time**, choose **Carry on in the canvas**, **Start another workflow** or **Enrol in a follow-up**. The step has two outputs: **Replied** and **No reply**.

   ![The Wait step set to Waits for a reply](https://v3.wsapme.com/guide-media/img/chatbot-workflows/06-wait-for-reply.webp)

## Part 4 · Detect intent

**Detect intent** lets the AI read what the customer wrote and pick what they meant, for example *Pricing* or *Booking*.

1. Click **Add step**, then **Detect intent**.
2. Under **Intents (2 of 8)**, name each intent (for example `Pricing`) and describe it in a sentence. Add example sentences in any language, including Malay or mixed. Click **Add intent** for more (2 to 8).
3. Leave **What to read** as **The customer's latest message**, or change it.
4. Set how sure the AI must be (default 0.70). Below that, the flow takes **None of these**.
5. Under **Where it leads**, connect each intent to the next step.

   ![The Detect intent step](https://v3.wsapme.com/guide-media/img/chatbot-workflows/07-detect-intent.webp)

> Each Detect intent run uses **1 AI credit**. It was not run for this guide. If AI is not set up or has no credits, the flow takes **None of these**.

## Part 5 · Test with the simulator

**Watch first (28 s, no sound):** [Test a chatbot in the simulator](https://v3.wsapme.com/guide-media/video/04-test-chatbot-simulator.mp4).

The simulator is safe: nothing is sent or saved. Tags, assignments and contact changes are only shown, and AI steps are skipped. It uses your steps on screen, including changes you have not saved.

1. In the canvas, click **Test**.
2. Optional: type a **Test contact's name**, choose the **Number type** (**WhatsApp app number (numbered menus)** or **Official number (buttons and lists)**), a **First message** and **Contact's tags**.
3. Click **Start test chat**.

   ![The Test chat form](https://v3.wsapme.com/guide-media/img/chatbot-workflows/08-test-form.webp)

4. The bot's first message appears, and the step it is on is highlighted in the canvas (leave **Show steps** ticked). Type a reply in **Reply as the customer** and press Enter.

   ![The test chat started](https://v3.wsapme.com/guide-media/img/chatbot-workflows/09-test-chat-started.webp)

5. Reply with a number, for example `1`. The flow follows that answer.

   ![The test chat after answering 1](https://v3.wsapme.com/guide-media/img/chatbot-workflows/10-test-chat-answer.webp)

6. Click **Restart** to try again.

## Part 6 · A Simple sequence

**Watch first (3 min, Malay narration and captions):** [Build a Simple sequence](https://v3.wsapme.com/guide-media/video/04-workflow-sequence-malay.mp4). A keyword trigger, a text, a price-list photo and a last message with typing pauses, then a test in Preview. Nothing is published or sent.

1. In **Workflows**, click **New workflow** and choose **Simple sequence**. You land on a page named **New sequence** (a draft). The trigger starts as **Message contains "hello"**; click the **Trigger & number** bar to change it.
2. Click **Add message**.

   ![An empty sequence](https://v3.wsapme.com/guide-media/img/chatbot-workflows/11-simple-sequence.webp)

3. Choose **Text** (or another type) and write the message. Use **Insert:** buttons for `{{first_name}}`, `{{name}}`, `{{phone}}` or `{{email}}`. Click **Add message** again for the next one.

   ![A message added to the sequence](https://v3.wsapme.com/guide-media/img/chatbot-workflows/12-simple-add-message.webp)

4. Click **Preview** to test it, **Save draft** to keep it, **Open in canvas** to turn it into a canvas flow.

## Part 7 · Publish

When the test looks right, click **Publish** in the canvas or on the sequence page, or **Switch on** on the workflow page. The workflow then runs on real customer chats.

> **Not executed for this guide:** **Publish** and **Switch on**. Check your trigger and numbers carefully first, since a published flow replies to real customers.

## Part 8 · Start a flow with a keyword you send

*Written from the product, not captured on screen.*
<!-- not captured -->

*Written from the product, not captured: sending in the demo workspace would message real chats.*

A keyword flow can also start when **you** send the keyword in a customer's chat, for example to send your price list or a booking form without typing it all. You send it from your phone (QR or Hybrid number) or from the Wsapme Inbox (any number), and the flow runs for that customer.

1. In **Starts when**, choose **Message contains a keyword**.
2. In **Who sends the keyword**, choose **You** (only your own messages start it) or **Either** (the customer's too). **Customer** is the usual keyword trigger.
3. Type the **Keywords**, one per line, and choose the **Match**: **Contains the word**, **Is exactly**, **Starts with** or **Matches a pattern (advanced)**. Any of the keywords starts the flow and capital letters don't matter. Leave **Ignore punctuation and extra spaces** ticked so "pricelist!" also works. Tip: use a word customers don't write, such as `#pricelist`.
4. Optional: tick **Delete your keyword message for everyone after it starts the flow**. Only your own message is deleted, never a customer's. It works on QR and Hybrid numbers within 2 days; the customer may briefly see the keyword, then sees "This message was deleted". Official WhatsApp numbers can't delete messages, so there the box is greyed out and the keyword stays in the chat.
5. Click **Save**, then switch the workflow on.
6. Open a customer's chat (one person, not a group) and send the keyword from your phone or the Inbox. The flow starts for that customer.

Sending the keyword yourself starts the flow even if your team is handling the chat, and replaces any flow already running there. In the run's steps you see "Your keyword, sent from your phone" (or from the Wsapme Inbox). Messages sent by workflows, broadcasts, follow-ups, the AI or the API never count as your keyword.

## Files from an AI assistant

An AI assistant connected to Wsapme (guide 07, Part 5) can make a workflow whose **Send a message** step has a picture, video or document, from a link or a file you attach in the chat. Wsapme keeps its own copy, the same as **Upload** in the step, so you see the file in the editor and the simulator.

## Common problems

| Problem | What to do |
|---|---|
| File link refused when the AI assistant adds a file | The link must open the file itself (not a web page, a Google Drive or WhatsApp page), be public **https**, and be an allowed file: **pictures JPG, PNG or WebP up to 5 MB**; **videos MP4 or 3GP, audio and documents (PDF, Word, Excel, PowerPoint, TXT, CSV, ZIP) up to 16 MB**. Open the link in a private browser window: the file should open or download at once. Otherwise attach the file in the chat and ask the assistant to upload it. An uploaded file must be used within 7 days. |
| A message sent by a flow shows a placeholder as written, such as `{{device.name}}` or `{{payload.name}}` (often in flows imported from Wsapme v2) | Wsapme only fills its own placeholders: `{{first_name}}`, `{{name}}`, `{{phone}}`, `{{device_name}}` (your number's name), custom fields and answers. `{{device.name}}` now works as `{{device_name}}`; other placeholders with a dot are left out of the message, and **Publish** or switching the flow on asks you to remove or replace them. |
| An **Any message** flow (or a keyword or new contact flow) is active but doesn't answer one chat | That chat is with your team: the AI agent handed it over ("AI handed over"), or someone paused the AI there, and flows don't start in a chat your team is handling until the pause ends (up to 12 hours by default). Open the chat in Inbox and click **Hand back to AI**, or type `#bot on` (or `#bot reset` to test from the start) in the chat, then send a message again. A keyword you send yourself still starts a flow. |
| The flow does not start | Check it is switched on (not **Draft**), that **Starts when** matches the message, and that the number is ticked or none are. Another flow may already be running in that chat. |
| A step says "Not connected: nothing leads to this step" | Drag from the previous step's dot to the new step. |
| The test chat shows no AI answer | AI steps are skipped in the simulator on purpose. |
| The flow stopped after your team replied | A reply from your team stops the flow in that chat. |
| I sent the keyword but nothing started | Check **Who sends the keyword** is **You** or **Either**, that it was a chat with one person (not a group), that the number is ticked (or none are), and that the workflow is switched on. Keywords in a message from a broadcast, follow-up, the AI or the API never start a flow. |
| The keyword message wasn't deleted | Official WhatsApp numbers can't delete messages, and WhatsApp only deletes messages for about 2 days. On a Hybrid number, its QR connection must be connected. The run's steps say why ("The keyword message could not be deleted: …"). |
| My keyword didn't start the flow, it handed the chat to the team instead | When the keyword can't do anything (for example the flow has no steps), it counts as an ordinary reply from your team, which stops the flow running in that chat. |
| My link shows no preview | A link in a **Send message** step shows a preview unless **Show link preview** is unticked. No preview means the page has no title or picture for previews, the switch is off, or the website blocks bots like Wsapme's preview reader. The message is still sent. |

## Related

- [02 · Team inbox](https://v3.wsapme.com/guides/team-inbox.md)
- [05 · AI agent and knowledge](https://v3.wsapme.com/guides/ai-agent-and-knowledge.md)
