Skip to content

Glossary drawing · Bots, flows & AI

AI Agent

Also called: LLM agent · Agentic AI · AI customer service agent · Autonomous agent

Note 1 —An LLM-driven system that plans and takes actions through tools over several steps — checking an order, booking a slot — instead of only answering.

Term
AI Agent
Abbreviation
—
Category
Bots, flows & AI
Level
Practitioner
Reviewed
Sheet no.
GLO-AUT-929
Drawn by
InfiQ Glossary

Drawing 1 · Interactive

Walk an AI agent through a return request

8 / 8
  • Message received to Plan: load context
  • Plan to Call tool: needs data
  • Call tool to Read result: result
  • Read result to Plan: next step
  • Read result to Ask to confirm: write needed
  • Ask to confirm to Call tool: taps Yes
  • Ask to confirm to Reply sent: taps No
  • Read result to Reply sent: task done
  • Plan to Reply sent: answer directly
  • Plan to Hand off: limit or request
  • Call tool to Hand off: repeated failure
  1. Message received
  2. Plan
  3. Call tool
  4. Read result
  5. Ask to confirm
  6. Call tool
  7. Read result
  8. Reply sent

Step 8 of 8 · end of walk

Reply sent

The final answer goes out via POST /{PHONE_NUMBER_ID}/messages and is logged with its wamid.

Arrived from Read result via task done.

Can move to

Nothing — this is a final state.

The agent loop as states: plan, call a tool, read the result, confirm, act and reply. Switch walks to see a customer who declines and one who asks for a person.

Happy path, step 8 of 8: Reply sent (via task done). The final answer goes out via POST /{PHONE_NUMBER_ID}/messages and is logged with its wamid.

What is an AI agent?

An AI agent is software built around a large language model (LLM) that does not just answer a message but works towards a goal: it decides what to do next, calls tools such as an order lookup or a booking API, reads the results and repeats until the task is done or it needs a person. On WhatsApp, an AI agent can take "I want to return the shoes I got yesterday" all the way to a booked pickup, rather than replying with a link to the returns page.

The core is a loop. Your code sends the model the conversation, a system prompt and a list of tool definitions; the model replies either with text for the customer or with a structured tool call — tool calling, also called function calling — such as get_order(order_id). Your code executes the call, returns the result and asks the model again. The model never touches your systems directly: every action passes through code you control, which is where authorisation, confirmations and limits live.

That makes an AI agent different from a scripted chatbot, which follows a fixed menu or decision tree, and from a plain LLM bot that only generates answers from documents. It also differs from Meta Business Agent, Meta's own hosted agent announced in June 2026, which is configured with a business's information, FAQs, website and catalogue (and can be linked to its APIs) rather than built, and is billed by Meta per token. A custom agent runs on your infrastructure with the model of your choice, calls your APIs and sends replies through the WhatsApp Cloud API like any other message.

Platform policy draws a line too: since 15 January 2026 the WhatsApp Business Solution Terms bar general-purpose AI assistants as a core product, while AI that serves a business's own customers is unaffected. An agent scoped to your orders, bookings and support questions — with AI guardrails and a path to a human — sits on the right side of that line.

Key takeaways

  • An AI agent is an LLM system that plans, calls tools and acts over several steps to finish a task, not just answer a question.
  • The model only proposes tool calls; your code executes them, which is where permissions, caps and confirmations belong.
  • Write actions such as refunds or bookings should run only after the customer confirms, ideally with a reply-button tap.
  • Since 15 January 2026 general-purpose AI assistants are barred as a core product on WhatsApp; customer-service agents are unaffected.
  • Meta Business Agent is Meta's hosted agent; a custom AI agent runs on your systems and replies through the Cloud API.

Design intent

Why does an AI agent matter?

Most WhatsApp support demand is not a question but a task: reschedule, cancel, return, change an address. Bots that only answer push customers to a website or a human for the last step; an agent can finish it in the chat, at any hour, with the customer confirming each action. For developers the hard part shifts from writing dialogue trees to designing safe tools — what the agent may read, what it may change, and when it must stop and hand over.

Operating sequence

How does an AI agent work?

  1. Receive and load context

    A messages webhook arrives. Your service loads the conversation state, the customer's identity (wa_id or business-scoped user ID) and recent history, then builds the model request: system prompt, trimmed history and the tool list.

  2. Let the model plan

    The model either answers directly or emits one or more tool calls with JSON arguments matching the schemas you defined, for example get_order with {"order_id": "BLR-55102"}.

  3. Execute tools in your code

    Validate the arguments, check this customer may act on that record, run the call with a timeout and return a compact result to the model. Read-only tools can run freely; tools that move money or change data need extra gates.

  4. Confirm before acting

    For refunds, cancellations or bookings the agent asks the customer to confirm with reply buttons. Your code — not the model — checks that the confirming tap arrived before running the write tool.

  5. Reply or hand off

    The final answer goes out through POST /{PHONE_NUMBER_ID}/messages. If a step limit is reached, a tool keeps failing, the topic is sensitive or the customer asks for a person, the agent hands off to a human with a summary.

  6. Log and evaluate

    Store every model turn and tool call with the triggering wamid, so you can replay conversations, measure task completion and run regression evaluations before changing a prompt or model.

Implementation

An AI agent in code

// The model plans; your code acts. Works with any tool-calling model client.
const tools = [
{
name: "get_order",
description: "Look up an order placed by this customer.",
parameters: {
type: "object",
properties: { order_id: { type: "string" } },
required: ["order_id"],
},
},
{
name: "create_return",
description: "Book a return pickup. Only after the customer confirms.",
parameters: {
type: "object",
properties: { order_id: { type: "string" }, reason: { type: "string" } },
required: ["order_id", "reason"],
},
},
];
const MAX_STEPS = 6;
export async function runAgent(customer, history) {
const messages = [{ role: "system", content: SYSTEM_PROMPT }, ...history];
for (let step = 0; step < MAX_STEPS; step++) {
const out = await llm.chat({ messages, tools });
if (!out.toolCalls?.length) return { reply: out.text }; // final answer
messages.push(out.message);
for (const call of out.toolCalls) {
// Authorise against the verified customer; gate write tools on a confirmed tap.
const result = await executeTool(call, customer);
messages.push({ role: "tool", toolCallId: call.id, content: JSON.stringify(result) });
}
}
return { handoff: true, reason: "step limit reached" };
}

A bounded loop: the model proposes tool calls, your code authorises and runs them, and a step cap forces a handoff instead of an endless loop.

Example: Rescheduling a blood test in Hyderabad

A patient replies "Can I move my blood test to Sunday?" to a booking-confirmation template from a diagnostics lab. The agent calls get_booking for the patient's number, then list_slots for that centre on Sunday, and offers three slots as reply buttons. The patient taps 8:30 am; the agent calls reschedule_booking, which the lab's API accepts, and sends the new confirmation with fasting instructions from the knowledge base. A request to change the test itself is outside the agent's tools, so it hands that part to the front desk with a two-line summary.

Failure modes

Common mistakes with an AI agent

  • Letting the model act without confirmation

    A misread "cancel" can cancel the wrong order. Split tools into read and write, and require a confirmed button tap — verified in code, not by the model — before any write that moves money or changes a booking.

  • Trusting tool arguments

    The model can be talked into passing someone else's order ID. Authorise every call against the customer's verified WhatsApp identity and treat customer text as untrusted input that may contain prompt injection.

  • No step or time limit

    Agents can loop, calling the same tool again and again while the customer waits. Cap model calls per message, set tool timeouts and hand off when either limit is hit.

  • Slow replies with no feedback

    Several model and tool round trips can take many seconds. Mark the message as read, send a short holding reply for long tasks and keep tool responses small and fast.

  • Shipping prompt changes untested

    A small prompt edit can change which tool the model picks. Keep a set of recorded conversations and run evaluations before every prompt or model change.

Specifications

An AI agent: key facts and limits

Core loop
Plan → call tool → read result → repeat → reply
Where actions run
Your code, never inside the model
Step limit
Set one (for example 5–8 model calls per message), then hand off
Reply channel
POST /{PHONE_NUMBER_ID}/messages, like any message
Free-form replies
Only inside the 24-hour customer service window
Policy
General-purpose AI assistants barred as a core product since 15 Jan 2026
Meta Business Agent
Meta-hosted; billed per token (USD 2.00 per 1M) since 1 Aug 2026

Recommended practice

Best practices for an AI agent

  • Give each tool one job, a clear description and a strict JSON schema.
  • Return only the fields the model needs from each tool — it saves tokens and reduces confusion.
  • Use reply buttons for confirmations and choices; taps are unambiguous where free text is not.
  • Make "talk to a person" a tool the agent can always call.
  • Log each tool call with the wamid of the message that triggered it.

AI Agent FAQs

What is the difference between an AI agent and a chatbot?+
A chatbot converses; an AI agent also acts. A scripted chatbot follows a fixed flow and a plain LLM bot answers from documents, while an agent plans steps and calls your APIs to complete a task such as a refund or a booking.
Is an AI agent the same as Meta Business Agent?+
No. Meta Business Agent is Meta's hosted agent, announced in June 2026: you configure it with your business information, FAQs, website and catalogue, and Meta bills it per token. A custom AI agent is software you build, with your own model, that calls your systems and replies through the Cloud API.
Are AI agents allowed on WhatsApp?+
Yes, for your own customer service and business tasks. Since 15 January 2026 the WhatsApp Business Solution Terms bar general-purpose AI assistants as a core product, but AI that serves a business's customers is unaffected, and a clear path to a human is still expected.
Which model should a WhatsApp AI agent use?+
Any model with reliable tool calling that handles your customers' languages. Test on recorded conversations in English, Hindi, Hinglish and your regional languages, and weigh latency and per-token cost as heavily as accuracy.
How does an AI agent hand off to a human?+
Through a tool or rule that moves the conversation to your inbox with a summary. Trigger it on explicit requests, repeated tool failures, low confidence, sensitive topics and step limits, and silence the agent while the human owns the chat.

See InfiQ pricing

Put AI Agent to work

InfiQ is an official Meta Business Partner. Start a 7-day free trial — no card needed — and see this running on your own number.