# 05 · AI agent and knowledge

**Purpose:** teach an AI agent about your business, try it safely, understand what it costs, and make sure it hands difficult chats to your team.

## Before you start

- A connected number (see [01 · Getting started](https://v3.wsapme.com/guides/getting-started.md)).
- AI credits. Each AI reply uses credits (see Part 6). A workspace gets free credits every month (every 28 days on per-number plans).

> The agent in this guide was **never switched on**, so it did not answer any customer. Screenshots use a demo workspace with Demo mode on; phone numbers shown on the settings page are hidden in the images.

**Watch first (4 min, Malay narration and captions):** [Set up your AI Agent](https://v3.wsapme.com/guide-media/video/05-ai-agent-setup-malay.mp4). A home bakery describes its business, adds knowledge and products, tests the agent in the Playground and finds Activity. The agent is not switched on in the video.

## Part 1 · The setup guide

1. In the sidebar, under **Automation**, click **AI Agent**. The first time, the **Set up your AI agent** guide opens (about 10 minutes, and every step saves on its own). Click **Skip to settings** if you prefer to go straight to the settings.
2. Step **1 · Your business**: choose the kind of business (for example **Online shop & retail**), type the **Business name** and **Describe your business in a few sentences**, then click **Save and continue**.

   ![The setup guide, step 1](https://v3.wsapme.com/guide-media/img/ai-agent/01-setup-wizard.webp)

3. The other steps are **2 · What the agent knows**, **3 · Products** (optional), **4 · Try it with 5 questions** (optional) and **5 · Go live**.

> Only step 1 was looked at in this guide. Steps 2 to 5 were not clicked through, because step 5 switches the agent on. All five steps are explained in [36 · AI agent: every setting explained](https://v3.wsapme.com/guides/ai-agent-settings-reference.md), Part 8.

## Part 2 · The settings

1. On the AI Agent page, click **Settings**. The tabs across the top are **Settings**, **Knowledge base**, **Products**, **Testimonials**, **Tools**, **Playground**, **Tests**, **Orders & bookings**, **Sales**, **Review**, **Quality**, **Activity**, **Credits** and **Usage**.
2. At the top, **AI agent is off** is the master switch. When you tick it, the agent answers new messages in 1:1 chats on the numbers you choose. Groups are never answered.

   ![The AI agent switch](https://v3.wsapme.com/guide-media/img/ai-agent/02-agent-off.webp)

3. Under **WhatsApp numbers**, tick the numbers it should answer. **Website chat** lets it answer your website visitors too.

   ![The numbers section](https://v3.wsapme.com/guide-media/img/ai-agent/03-numbers.webp)

4. Under **Language**, choose the **Reply language** (for example **Same as the customer (default)**, which also answers Manglish) and how it addresses customers in Malay. Use **Add a word** for your own product names and terms.

   ![The language section](https://v3.wsapme.com/guide-media/img/ai-agent/04-language.webp)

5. Under **Personality**, choose the **Tone** and the **AI model**. The line under the model tells you the price, for example "1 credit per reply, +1 per image". You can also write **Extra instructions**, such as "Always ask for the delivery area before quoting shipping." They take up to 16,000 characters, enough for a whole sales script; the line under the box counts them.

   ![The personality section](https://v3.wsapme.com/guide-media/img/ai-agent/05-personality-model.webp)

6. Under **When to reply**, choose **Any time, day and night**, **Only outside opening hours** or **Only during opening hours**, set the hours per day, the **Reply delay (seconds)** and **Max AI replies per customer per day**. After the maximum, the conversation goes to your team.

   ![The when to reply section](https://v3.wsapme.com/guide-media/img/ai-agent/06-when-to-reply.webp)

7. Click **Save settings** after any change. *Save and the master switch were not used in this guide.*

## Part 3 · Teach the agent: the knowledge base

The agent answers only from what you give it, and it will not make up answers that are not there.

1. Click **Knowledge base**. You can **Add entry**, **Upload .txt / .md**, **Import from website** or **Learn from past chats**.

   ![The empty knowledge base](https://v3.wsapme.com/guide-media/img/ai-agent/07-knowledge-empty.webp)

2. Click **Add entry**.
3. Type a **Title** (one topic per entry works best) and the **Content**, written the way you would explain it to a new staff member. Keep **The agent may use this entry** ticked.
4. Click **Save**.

   ![The new knowledge entry form](https://v3.wsapme.com/guide-media/img/ai-agent/08-add-entry.webp)

**What you should see:** the entry appears in the list, and the character count above it goes up.

![The saved entry](https://v3.wsapme.com/guide-media/img/ai-agent/09-knowledge-saved.webp)

Add your delivery areas, prices, payment and return policies the same way. You can also fill the **Products** tab.

An entry can also have one picture (its code, for example **K12**, is what AI steps and follow-ups use to send it). Your AI assistant (connector) can now add that picture from a picture link or a picture you attach in the chat; Wsapme keeps its own copy and the code stays the same.

## Part 4 · Try it in the Playground

The Playground lets you chat as a customer. Nothing is sent on WhatsApp.

1. Click **Playground**.
2. Type a question the way a customer would, for example `What time are you open on Monday?`, and press Enter.

   ![A question typed in the playground](https://v3.wsapme.com/guide-media/img/ai-agent/10-playground-question.webp)

3. Read the answer. Under it the page shows **Checked: supported by your information**, the model used and the cost ("1 credit"). If the answer is wrong, add or fix a knowledge entry, then ask again.

   ![The playground answer](https://v3.wsapme.com/guide-media/img/ai-agent/11-playground-answer.webp)

Use **Save as test question** to keep good questions in the **Tests** tab so you can check them again after changing the knowledge base.

## Part 5 · Hand over to your team

1. On **Settings**, scroll to **Handing over to your team**.
2. **Handoff keywords** are words that hand the chat to your team. A customer message with any of them (for example `human`, `agent`, `staff`) stops the agent in that chat.
3. Change **Message when handing over**, which is sent to the customer when they ask for a person.
4. Tick **Leave the team a note when handing over** to get a short internal note in the inbox (what the customer wants, what was collected, what is left to do). It uses a little AI credit.
5. **Resume AI after** sets how long the agent waits after your team replies or a chat is handed over, from 10 minutes to 7 days. If the customer is still waiting for an answer when that time is up, the agent replies to them.

   ![The handing over section](https://v3.wsapme.com/guide-media/img/ai-agent/13-handoff-settings.webp)

The agent also stops by itself when it cannot answer from your knowledge, or when someone in your team replies in that chat.

## Part 6 · Credits

1. Click **Credits**. **Available credits** is your balance. **Included with your plan** shows the free monthly credits and when they reset; unused credits do not carry over.
2. **Where your credits go** lists what used credits in the last 28 days: customer replies and the optional extras that run with them (such as **Answer check** or **Customer memory**), with the setting that turns each extra off. It also shows about how many credits one customer reply uses in total.
3. Use **Monthly AI budget** to cap how many credits AI may use each month. Owners get an email and a WhatsApp message at 80% and 100%.
4. To top up, choose a pack under **Buy credits** (for example **Starter pack**, 5,000 credits). *No pack was bought in this guide.*

   ![The credits page](https://v3.wsapme.com/guide-media/img/ai-agent/12-credits.webp)

## Part 7 · One number, several products

When one WhatsApp number sells more than one product (for example honey and coffee), each product can have its **own AI agent** on that number, with its own Instructions, knowledge, products, order form, pictures, testimonials and follow-ups. Your plan sets how many agents you can add (**AI Agent → Settings**, the agent list at the top).

**Who answers a chat.** Every number has one **main agent**: the agent that has the number ticked under **WhatsApp numbers**. The other agents on that number are **product agents**. A chat starts with the main agent and moves to a product agent when:

1. it came from a **link, ad or campaign** that names the agent (the **AI agent** field in the link dialog, or **Ads → AI agent per ad**);
2. the customer's message has one of the product agent's **Keywords that pick this agent**;
3. a workflow runs the step **Hand to AI agent**;
4. the main agent sees which product the customer wants and hands the chat over. The product agent answers straight away, reads the whole chat and does not greet again;
5. someone in your team picks another agent in the inbox: the **AI** button in the chat header → **AI agent: …**.

The chat keeps that agent until one of these changes it. Orders keep the agent that took them, and **Ads** and **Lead summary** can show one agent's chats (**All AI agents** filter).

**Set it up (worked example: Madu Kelulut and Kopi 3-in-1 on one number)**

1. Keep your existing agent as the main agent. In **What this agent sells** write `Madu kelulut asli, 1 kg`.
2. Click **Add agent**, name it `Kopi agent`, and fill in its own **About the business**, **Instructions**, products and order form for the coffee only.
3. Under **WhatsApp numbers**, the number shows **Main agent: Main agent**. Tick **Product agent here** under it.
4. In **What this agent sells** write `Kopi pracampuran 3-in-1, 20 sachet sekotak`, and in **Keywords that pick this agent** write `kopi, coffee, 3in1`.
5. Switch the coffee agent on and click **Save settings**.
6. For your coffee ads, open **Ads → Links → (your coffee link)** and choose **AI agent: Kopi agent**, or set it on the ad or campaign under **Ads → AI agent per ad**.

Now a customer who writes "Ada kopi?" or clicks the coffee link is answered by the coffee agent; "Madu ada lagi?" stays with the main agent; a customer who writes "Saya nak tanya pasal minuman pagi" gets one short question from the main agent, then the coffee agent answers once the product is clear.

> **Tip: 2 or 3 similar products.** When the products are sold the same way (one price list, one order form, one follow-up), one agent is simpler: put all the products in **Products** and give each its own section in **Instructions** ("## Madu", "## Kopi"). Use one agent per product when each product needs its own sales script, order form, pictures or follow-ups.

A number with one agent works exactly as before: nothing on this page changes it.

## Common problems

| Problem | What to do |
|---|---|
| Photo link refused when the AI assistant adds a photo | The link must open the picture itself (not a web page or a shop page), be public **https**, and be a **JPG, PNG or WebP up to 5 MB**. Open the link in a private browser window: you should see only the picture. Otherwise attach the picture in the chat and ask the assistant to upload it. |
| The agent does not answer | Check **AI agent is off** is ticked on, that the number is ticked under **WhatsApp numbers**, **When to reply** allows this time, and you still have credits. |
| The reply puts an empty line before and after a list | On purpose, for every workspace: when a reply has a list (two or more lines that start with 👉, ✅, a number or a dash), Wsapme adds an empty line above and below it so the question and the closing line stand apart on WhatsApp. Lines inside the list are not changed. |
| The wrong agent answered | Open the chat and click **AI** in the header: **AI agent: …** shows who answers and how it was picked (a link, an ad, a keyword, a workflow, a hand-over or a person). Choose the right agent there. Check the product agent's **Keywords that pick this agent** (a common word like "harga" picks it for everyone), the link's or ad's **AI agent**, and that **What this agent sells** is one clear line, so the main agent hands over correctly. A person's choice in the inbox always sticks. |
| Agent switched but the follow-up came from the old one | A follow-up goes out from the agent the chat has when it is due. When a chat moves to another agent, the old agent's planned follow-up moves too: the count starts again and the new agent follows up by its own **Follow-ups** settings. A follow-up that was already sent before the switch stays in the chat. If the new agent has follow-ups off, nothing is sent. |
| It gives a wrong or vague answer | Add or correct a knowledge entry. Ask the same question in the Playground to check. |
| It stopped answering one customer | A handoff keyword, a team reply, the daily limit or a **#bot off** sent in that chat paused it. After a team reply it takes over again after the **Resume AI after** time; after **#bot off** only when you turn it back on. To hand it back sooner, send **#bot on** in that chat, or open the chat in the inbox and click **Hand back to AI**. |
| "#bot on" doesn't work | **#bot on** and **#bot off** are chatbot keywords for the whole workspace: check **Inbox → Settings → Chatbot keywords**. Your own commands are in **AI Agent → Settings → Chat commands** (**Control the AI from the chat**). The whole message must be the keyword, sent in a chat with one person. See guide 25, Part 9. |
| "#bot off" stopped my flow | **#bot off** stops the chatbot in that chat: the AI and a flow running there stop, and no new flow starts until **#bot on**. The run says "The chatbot was stopped for this chat". |
| The "#bot on" message wasn't deleted | Deleting works on QR and Hybrid numbers only (official WhatsApp numbers can't delete messages), within about 2 days, and on a Hybrid number only while its QR connection is connected. |
| Credits run out fast | Choose a cheaper **AI model**, set a **Monthly AI budget**, or turn off optional features that use credits. **Credits → Where your credits go** shows which ones use the most and where to turn them off. |
| The agent quotes an old price or promo, or an example reply you no longer use | Keep **About the business** to who you are and what you sell. Put prices in **Products** or **Knowledge**, promotions in **Knowledge** and example replies in **Instructions**. The settings page shows a tip when it finds them there. |
| I want follow-ups on day 1, day 3 and day 7, not all close together | On **Settings → Follow-ups**, choose up to 4 **Follow-ups per quiet chat** and give each its own **send after** wait (30 minutes to 7 days, counted from the message before it). See Part 15 of [36 · AI agent: every setting explained](https://v3.wsapme.com/guides/ai-agent-settings-reference.md). |
| **Save settings** fails with a message about **Extra instructions** | They take up to 16,000 characters; the count under the box turns red above that. Shorten them, or move product facts and prices to **Products** or **Knowledge**. Instructions saved longer before never stop you saving your other settings: you only need to shorten them when you change them. |
| A customer got strange code instead of an answer, like `<｜DSML｜ invoke …>` | The AI model sometimes writes its internal tool code instead of a message. The agent now never sends it: it asks the model once more, and if the second answer is broken too it sends your hand-over message and your team takes over. **Activity** shows "broken answer (tool-call markup)" on that reply. |
| I want a poster sent right after the greeting, or my own follow-up wording | See Part 15 of [36 · AI agent: every setting explained](https://v3.wsapme.com/guides/ai-agent-settings-reference.md): name the picture's code (**Picture K12** on the knowledge entry) in **Extra instructions**, and write your own text under **Follow-ups**. |
| The AI did not answer a message with a code, for example "58721 is your Facebook confirmation code" or a TAC | On purpose. One-time codes (OTP, TAC, verification or confirmation codes) and notifications that say "do not reply" are written by a system, not a person, so the AI agent and workflow chatbots leave them alone and no credits are used. **AI → Activity** lists them as skipped: "A one-time code or automatic notification". A customer who writes a number with other words, such as "kod produk 1234" or "confirm order 1234", is still answered. |

## Related

- [02 · Team inbox](https://v3.wsapme.com/guides/team-inbox.md)
- [04 · Chatbot and workflows](https://v3.wsapme.com/guides/chatbot-workflows.md)
