Skip to main content

How to build a WhatsApp AI Agent in AiSensy

Automate 85% customer queries by building a WhatsApp AI agent inside AiSensy. Check the below doc for complete guide

Written by Shivam Aggarwal

Most WhatsApp chatbots work on fixed keywords. A customer types "refund" and gets a refund policy. That works for simple queries, but customers don't always talk in keywords. They say things like "I ordered something last week and haven't received it" or "Can I change my plan mid-month?"

AiSensy's AI Agent Builder is built for exactly these situations. It understands what your customer is actually asking, finds the right answer from your business knowledgebase (help center), and can even take real actions, like checking an order status, booking an appointment, or fetching a quote - all without writing a single line of code.

In this tutorial, we’ll walk you through how you can build your own AI Agent on WhatsApp using AiSensy.

By the end of this, you’ll have a fully functional AI Agent that can understand user queries, respond intelligently, and even take actions automatically.

Note: This is a big guide, so stock up on your coffee & snacks & let's begin!

How the WhatsApp AI Agent Builder works

Before we start building, it’s important to understand how the system works.

Every AI Agent on AiSensy runs on a combination of three core components:

  • Knowledge Base which learns from your business data like website links, documents, FAQs, etc.

  • Tool Calling which allows your AI Agent to take real actions like fetching data or triggering APIs

  • AI Orchestrator which defines how your AI Agent behaves, including its tone, voice, and custom instructions for handling conversations

AI Routing (optional) — This lives above all your flows, at the account level. If you have multiple flows, AI Routing reads incoming messages, figures out what the customer wants, and sends them to the right flow — without any keyword triggers. You only need this when you have more than one flow.

Don't worry. Setup for each of these has been explained in detail and you will learn how to set all these up very easily.

So, let's make your WhatsApp AI agent.

How to build a WhatsApp AI Agent: Step by Step

Step 1: Set Up Your Knowledge Base

1. Click on Flows in the left sidebar

Click the Flows icon in the left navigation rail. This opens the Flow Builder playground, your home for all chatbot flows and the new AI Agent capabilities.

On this page you'll see the Active Flows card (tracks how many flows are live and how many are AI-Enabled), the AI Messages card (where you purchase the AI Messages addon that fuels intelligent responses), and a + Create Flow button.

2. Click "+ Create Flow"

Click on + Create Flow to start a new flow.

4. Open the Knowledge Base tab

Once a flow is open, four tabs appear at the top:

BUILDER: the familiar drag-and-drop canvas where you design conversation flows.

KNOWLEDGE BASE: train this flow's AI on your business data.

TOOL CALLING: configure API integrations the AI can trigger.

AI ORCHESTRATOR: tell the AI how to behave with structured instructions.

Inside the flow editor, click the KNOWLEDGE BASE tab at the top.

5. Create a new Knowledge Base

Click + Knowledge Base in the top right. Give it a clear name that's easy to identify.

Something like "Product FAQs" or "Shipping & Returns" works well.

3. Add your content

Click the arrow to expand your Knowledge Base. You'll see three ways to add content:

  • Sync from a website: Paste your website URL and AiSensy automatically finds and crawls all the pages under it. Each page is indexed separately.

  • Create an article: Write content directly inside AiSensy. Great for FAQs or anything without a public URL.

  • Upload a document: Upload a PDF, Word doc, or product catalogue. AiSensy extracts the text and indexes it automatically.

4. Wait for indexing to complete

Once you add content, it needs to be processed before your agent can use it. Each source will show one of three statuses:

  • Processing: Your content is being indexed. It's not available yet. Just wait a moment.

  • Completed: Ready to go. Your agent can now answer from this content.

  • Failed: Something went wrong. Check the error message and try again

5. Enable the Knowledge Base

Use the toggle next to each KB to turn it on or off.

The pencil icon lets you rename it, the trash icon deletes it, and the arrow lets you add more sources to it anytime.

Step 2: Set up Tool Calling (optional but powerful)

Tool Calling is what turns your agent from a question-answering bot into one that can actually do things. With Tool Calling, your agent connects to your tools (CRMs, ecommerce platforms like shopify etc) and brings back live data, like order status, appointment slots, customer account details, or a live price from your system, then sends the result straight to the customer on WhatsApp.

IMPT NOTE: If your agent only needs to answer questions from the Knowledge Base, you can skip this step entirely.

1. Open the Tool Calling tab

Inside the flow editor, click the TOOL CALLING tab. Click + Add New Tool to get started.

Tool Calling empty state, "No tools added yet" with hammer-and-wrench icon, body text "Add tools to allow your AI to perform actions like searching databases or sending emails via API", and a centered + Add New Tool button

2. Name your tool and describe what it does

Give your tool a clear name, like "Check Order Status" or "Fetch Policy Details". Then fill in the Tool Description. This is important: the AI reads this description to decide when to call the tool. Write it in plain English, like: "Fetches the current status of a customer's order using their order ID."

2. Name your tool and add a description.png [ SCREENSHOT: Tool Calling expanded form, Tool name field with green lightning icon in header, ▶ Test / Save / Cancel buttons; Tool Description textarea; API Endpoint with GET dropdown and URL field; Headers table with Key/Value columns; Request Fields with Auto-detect button ]

3. Set up your API request

Under REQUEST CONFIGURATION, fill in your API details:

  • Method: GET, POST, PUT, or DELETE, whatever your API expects.

  • URL: Your API endpoint.

  • Headers: Any auth headers your API needs, like Authorization: Bearer {{token}}.

  • Request Body: For POST or PUT requests, add your JSON body here.

3. Configure the API Endpoint.png

4. Define the input parameters

Under REQUEST PARAMETER CONFIGURATION, add the inputs your API needs. For each one, fill in:

  • Parameter Name: The field name (e.g. order_id, customer_email).

  • Description: What this parameter is for, so the AI knows how to use it.

  • Data Type: String, number, boolean, etc.

  • Required: Toggle on if the API won't work without it.

4. Add Headers.png

5. Add Request Fields

Under REQUEST FIELDS, click 🪄 Auto-detect to let AiSensy auto-fill the fields from your endpoint, or click + Add Field to add them manually.

Specify each field's name and type. These are the values your tool sends to your API. The AI will automatically extract them from the conversation when the tool is called.

5. Add Request Fields.png

6. Map the API response to attributes

Under RESPONSE ATTRIBUTE MAPPING, click + Add Mapping to capture values from the API response and save them for use later in the flow. For example, map response.policy_number to a policy_number attribute to use it further down the conversation.

6. Map the API response to attributes.png

7. Configure the WhatsApp response

Under RESPONSE CONFIGURATION, choose how your agent replies after getting the API data:

  • Text Message: A plain text reply.

  • Text With Buttons: Text plus quick reply buttons.

  • Media With Buttons: An image or document with buttons.

  • List Message: A WhatsApp List for multiple options.

Use {{field}} syntax in the message body to pull in values from the API response.

The live WhatsApp preview on the right shows exactly how your message will look.

SCREENSHOT: Tool Calling Response Configuration, WhatsApp Message Type picker with four options (Text Message, Text With Buttons, Media With Buttons, List Message), Header / Body / Footer fields with Insert Variable buttons, and a WhatsApp message preview on the right

8. Test and Save

Click the ▶ Test button to validate your API call works. Then hit Save to activate the tool. Your agent will now call this API whenever a relevant query comes in.

Note: Tool Calling works with any REST API. If it works in Postman, it works with your AI Agent.

Step 3: Configure the AI Orchestrator

The AI Orchestrator is where your agent really comes to life. It reads each conversation, weighs up the available knowledge and tools, and picks the best action, whether that's pulling an answer from the KB, calling a tool, escalating to a human, or writing a response from scratch.

This is also where you define your agent's personality, scope, and rules. Think of it as your agent's briefing document.

1. Open the AI Orchestrator tab

Click the AI ORCHESTRATOR tab inside your flow editor. You'll land on the Agent Instructions screen.

2. Choose Sections or Raw mode

  • Sections mode gives you a structured, guided setup with labelled fields. Perfect if you're building for the first time.

  • Raw mode lets you write the full prompt yourself in one block. Use the / slash menu to insert your KB or tools directly into the prompt. Best for advanced users who want complete control.

For better customization, we recommend that you use the raw mode to insert your prompt and guide the agent behaviour.

3. Fill in "About your business"

Tell the agent what your business does, who your customers are, and what they typically reach out for. Be specific. The more context you give, the better your agent will perform.

Example: "You are the customer support assistant for AiSensy's WhatsApp Marketing Lite Plan. Customers reach out with questions about the plan, setup, QR Kit delivery, automations, broadcasting, API, KYC, and general usage. Your job is to help them get started and resolve their doubts quickly.

Bot Persona & Tone"

4. Fill in "Tone & personality"

How should your agent sound? Think about your brand voice.

Example: "Friendly, warm, and solution-oriented. Keep replies short and conversational — no long paragraphs. Use simple language, avoid technical jargon unless the customer uses it first. Acknowledge frustration before offering solutions. Always confirm whether the user is satisfied before ending the conversation."

5. Fill in "How the bot should work"

This is your step-by-step playbook for the agent: what it should do in different situations and which tools to call or how to react to complex questions.

Example: "1. For renewals, look up the user's existing policy first. 2. Always confirm vehicle details before quoting. 3. Use the integrated crm tool to fetch the latest price. 4. Never quote without the vehicle registration number."

6. Fill in "What to avoid"

Topics to refuse or hand off to a human.

Example: "Only handle motor insurance queries. Don't answer questions about health, life, or travel insurance. Escalate complex disputes to a human agent immediately."

7. Fill in "Anything else"

Extra rules, like pricing display formats, legal disclosures, escalation triggers, response length. These are basically the custom instructions for your WhatsApp AI agent, extra rules that ensure fine responses.

Example: "Always show prices in INR with GST included. If a claim amount exceeds ₹5 lakhs, escalate immediately."

8. Use Generate or Templates

Not sure what to write? Click Generate and AiSensy will auto-draft instructions based on your Knowledge base and tools. Or browse Templates for ready-made starting points built for common business types.

Pro Tip: Keep your instructions focused on your business domain. AiSensy already handles general conversational rules, formatting, and content safety. You don't need to cover those yourself.

9. Save

Hit Save. Your AI Orchestrator is now configured. Use the Undo button at any time if you want to roll back a change.

9. Save and go live.png

Step 4: Set Up AI Routing (Optional, Only Needed With Multiple Flows)

If you have multiple flows for different business use cases, like one for product queries, one for complaints, one for bookings. AI Routing is what automatically sends each customer to the right flow without them needing to type a specific keyword.

Example: A customer types "Hi, I'm looking for a 2BHK in Gurgaon." AI Routing reads that message, identifies the intent as Property Search, and routes the conversation to that flow, no keyword needed.

AI Routing lives at the Flow Builder index level, not inside individual flow editors. If you only have one flow, skip this step.

1. Open the AI Routing tab

Go to the Flow Builder index page and click the AI Routing tab. You'll see the AI Router toggle at the top.

2. Turn on the AI Router

Switch the toggle on to enable intent-based routing across all your flows.

3. Auto-generate your routing prompt/ Add your routing prompt manually

Click Auto-Generate from Flows. AiSensy drafts a routing prompt based on your active flows. You'll see five editable sections:

  • Role & Purpose: Defines what the AI Router does.

  • Available Flows: Auto-filled with your flow names, IDs, descriptions, and sample phrases that should trigger each one.

  • Routing Behaviour: How the AI structures routing decisions using confidence scores.

  • Confidence Guidelines: 0.95+ for exact matches, 0.85–0.94 for strong matches, 0.75–0.84 for plausible matches. Below 0.75, the router won't route.

  • Important Rules: Built-in guardrails like "never route mid-form-fill" and "one flow per response."

Note: You can draft all this manually as well.

4. Name your flows clearly

If you see a warning about unnamed flows, rename them from the Your Flows page. Vague names like "Flow 1" reduce routing accuracy.

The clearer your flow names and descriptions, the better AI Routing performs.

5. Save

Click Save Prompt to lock in your routing logic.

Step 5: Test your AI Agent

Before you go live with real customers, test your agent properly. A few minutes of testing can save you from a lot of awkward customer conversations later.

How testing works

Every flow comes with 500 free AI messages for testing on up to 3 designated Testing Numbers. In testing mode, your agent only responds to those numbers. Real customers won't see any AI responses until you explicitly go live.

  • If your WhatsApp API is already connected: Go to the Test Number tab on the Flow Builder index page and send messages directly on WhatsApp.

  • If you're not live yet: Use the preview mode inside the AiSensy flow builder to simulate conversations.

Test checklist

Go through these before going live:

  • Keyword trigger: Send the trigger keyword and confirm the flow starts correctly.

  • AI Routing: Type a natural question (no keywords) and verify the right flow is triggered.

  • Knowledge Base: Ask a few real customer questions and check that answers are accurate.

  • Tool Calling: Trigger a tool action and verify the API response appears in the correct WhatsApp format.

  • Escalation: Say "connect me to a human" and verify the handover appears in Live Chat.

  • Guardrails: Send an off-topic message and verify it's handled correctly, declined or redirected.

Going Live

Once you're satisfied with testing:

  1. Purchase an AI Messages addon from the Flow Builder index page or the Upgrade Plan dialog.

  2. Once active, remove the "Testing only" label from your flow.

  3. Go to Flow Builder index → AI Routing tab → Auto-Generate from Flows → Save.

Your agent will now respond to all incoming messages from real customers.

Pricing & AI Messages

AI Agent Builder runs on an AI Messages addon. Here's how it's structured:

Plans

  • Basic Flow Builder: Up to 5 keyword-based chatbots. No AI capabilities. Good for simple, scripted conversations.

  • AI Messages addon: Unlocks the full AI stack: Knowledge Base, Tool Calling, AI Orchestrator, and AI Routing.

Pack sizes (number of messages, not pricing)

  • 7k: 7,000 messages/month, for small businesses.

  • 15k: 15,000/month, for growing businesses.

  • 30k: 30,000/month, for medium businesses.

  • 50k: 50,000/month, for high-traffic businesses.

  • 100k: 100,000/month, for enterprises.

Note: This is the number of messages you get in each pack. For pricing, you can login to your dashboard & see the pricing based on your country/ region.

Billing

Monthly, Quarterly (discounted), or Yearly (best value). Activates immediately after payment. Login to your AiSensy dashboard.

For exact pricing, check your AiSensy dashboard.

How AI messages are counted

Every intelligent response, whether a KB answer, a tool call, or Orchestrator reasoning, counts as one AI message from your monthly quota. Usage resets at the start of each month.

Important: If you go over your quota, extra messages are billed as excess usage.

Your agent does NOT stop responding. Customers are never left hanging. Unused messages don't carry over to the next month.

Note: Remaining AI messages in the month get lapsed. They do not transfer to the next month.

Free testing allowance

500 free AI messages per flow for testing on up to 3 Testing Numbers. Test as much as you need before purchasing.

How Escalation to a Human Agent Works

No AI handles every situation perfectly, and sometimes a customer just needs a real person. AiSensy handles this automatically.

The agent escalates in four situations:

  1. Knowledge gap: The agent searched your KB but couldn't find a relevant answer.

  2. Customer request: The user says something like "connect me to a human" or "talk to an agent."

  3. Low confidence: The AI's confidence in its response falls below your configured threshold.

  4. Repeated failure: The agent has tried multiple times but hasn't been able to resolve the query.

What happens during escalation:

  1. The bot sends your configured escalation message (e.g. "Let me connect you with our team.")

  2. The AI stops responding to that user.

  3. The conversation moves to Requesting Chat in the live chat section from where the human agent can take over. Your team sees the full conversation history and can reply from there.

  4. If no agent responds within 24 hours, the chat auto-closes and the AI resumes handling new messages from that user.

You can also build explicit escalation paths using the Human Handover node inside any flow, useful when you want to escalate based on specific topics or user actions.

Frequently Asked Questions

What is WhatsApp AI Agent Builder?

AiSensy's next-generation chatbot system for WhatsApp. Unlike keyword chatbots that only respond to pre-set triggers, AI Agent Builder understands what customers actually mean, learns from your business content, and can take real API-driven actions, all without any coding.

Do I need coding skills?

Not at all. If you can type, you can build an AI Agent. AI Agent Builder is fully no-code. You set everything up through the drag-and-drop Flow Builder and a text-based Orchestrator instructions form.

How is it different from the classic Flow Builder?

The classic Flow Builder works on exact keyword matching and fixed conversation paths. AI Agent Builder adds natural language understanding, Knowledge Base retrieval, live API Tool Calling, and dynamic routing, so your agent handles open-ended conversations instead of just scripted ones.

Can I use both?

Yes. You can have some flows on the classic builder and others on AI Agent Builder within the same account. AI Routing works across both.

What happens if the AI can't answer?

It escalates to a human agent and stops responding to that user until your team replies or the chat auto-closes after 24 hours.

How do I add more KB content later?

Open the Knowledge Base tab inside your flow editor, expand the relevant KB, and click + Article, + URL, or + Document. You can add, edit, or remove content at any time.

Can I update KB content after going live?

Yes. Edit or delete any source at any time. AiSensy re-indexes automatically so your agent always uses the latest content.

What APIs can Tool Calling connect to?

Any REST API that accepts standard HTTP requests. If it works in Postman, it works with Tool Calling.

Is there a free trial?

Your Flow builder now comes with 500 free AI messages for testing on up to 3 Testing Numbers. Purchase an AI Messages addon only when you're ready to go live with real customers.

Can I have multiple Knowledge Bases per flow?

Yes. Create as many KBs as you need and toggle each on or off independently. Useful for enabling different content sets for different conversation types.

Does the AI know which KB to search?

Yes. The AI Orchestrator searches all active KBs simultaneously and combines results across semantic, keyword, and topic search to surface the most relevant answer.

What languages are supported?

Our WhatsApp AI agent currently only replies in english. However, it easily understands questions asked in multiple languages like Hindi, Tamil, Telugu etc.

How does AI Routing handle unrecognised intent?

If confidence falls below 0.75, the router doesn't route. The customer receives a fallback message, and you can configure what that says.

What counts as an AI message?

Any response involving intelligence, like a KB answer, a tool call, or Orchestrator reasoning, counts as one AI message from your quota.

Did this answer your question?