Industry

How to Connect AI to the WhatsApp Business API: 3 Ways

Connect an AI agent to the WhatsApp Business API: build it on Meta's Cloud API, use a BSP, or use a platform with AI built in. Steps, costs and checks.

Nov 11, 2026

How to Connect AI to the WhatsApp Business API: 3 Ways
Blog/Industry/How to Connect AI to the WhatsApp Business API: 3 Ways

Last updated: November 2026

TL;DR

  • Connecting AI to the WhatsApp Business API is four jobs, not one: link the number, receive messages, send replies inside Meta's rules, and hand the chat to a person when the AI should stop.
  • There are three ways to do it: build it yourself on Meta's Cloud API, let a Business Solution Provider (BSP) run the connection, or use a platform with the AI agent, templates and inbox built in, such as Invent.
  • The 24-hour window is the rule that breaks most setups. Inside it, the AI can reply freely. Outside it, only a template Meta approved can go out.
  • One number can serve your whole team. The AI answers first, and AI routing sends the chat to the right person in a shared inbox.
  • Prove it with a small pilot: one number, one use case, and four tests before you widen it.

Your customers already write to you on WhatsApp. The question is who answers at 2 a.m., on a Sunday, or when 300 people ask "where is my order?" on the same day. An AI agent connected to the WhatsApp Business API can answer them in seconds, from your own policies and catalog.

Getting there sounds like one task. In practice it is four: linking a phone number, receiving customer messages, sending replies under Meta's rules, and deciding when a person takes over. Get those right and customers get fast, correct answers. Get them wrong and you see failed sends, double replies, or an AI that keeps talking when it should have stopped.

This guide covers the three ways to connect, what each one asks of your team, and the checks to run before you go live.

How an AI agent works on the WhatsApp Business API

The WhatsApp Business API (Meta now calls it the WhatsApp Business Platform, and the hosted version is the Cloud API) works like a two-way pipe. Messages come in through webhooks. Replies go out through API calls. The AI sits in the middle and decides what to say.

A few terms you will meet in every setup:

  • WhatsApp Business Account (WABA): the account that holds your numbers, templates and settings.
  • Webhook: the notice Meta sends to your system when a message arrives or its status changes (sent, delivered, read).
  • Message template: a message Meta approved in advance, needed to start or restart a conversation.
  • Customer service window: the 24 hours after a customer's last message, when you can reply freely.

The flow in plain words: a customer writes, Meta sends the message to your webhook, your system passes it to the AI, the AI drafts an answer from your content, and your system sends it back. When the AI is unsure, or the customer asks for a person, the chat goes to your team instead.

Three steps from left to right: a customer asks on WhatsApp "is my order #4821 shipping today?", Meta sends a webhook to the AI agent, which checks your data and finds the order ships at 4 pm, then the reply is sent inside the 24-hour window with a tracking link.

The 24-hour window: the rule you cannot break

Meta's customer service window is a 24-hour timer. It starts, and restarts, every time the customer sends you a message. While it is open, your AI can send normal replies with text, images, documents or buttons. Once it closes, only an approved template can reach the customer.

That rule shapes how your AI should behave:

  • Answer right away while the window is open. This is where an AI agent pays for itself.
  • Check the window before every send. If it closed, the AI cannot improvise a free-text message.
  • Use a template for anything later. A delivery update the next day, an appointment reminder or a payment link after 24 hours needs an approved template in the right category: marketing, utility or authentication.

Meta bills every message, by category and by the customer's country, and sends that bill directly. Since October 1, 2026, each WhatsApp number gets 1,000 free service messages a month: the replies you send inside an open window. From the 1,001st, those replies are charged too, and templates are always charged. Check Meta's current rate card before you plan volumes. Our WhatsApp templates guide covers approval and how to reopen the window.

Timeline of the WhatsApp 24-hour window. At 0h a customer asks for size 38 and the AI replies in seconds, within the 1,000 free service messages each number gets a month. The window stays open for 24 hours for any reply. After it closes, a next-day message must be an approved template, and Meta charges for it.

Way 1: build it yourself on Meta's Cloud API

This path fits teams with developers who want full control of every layer.

  1. Prepare your Meta assets. You need a verified Meta business portfolio and a phone number that can receive a verification code.
  2. Create the WABA and connect the number. Meta's Embedded Signup flow, or the developer dashboard, creates the account and registers the number on the Cloud API.
  3. Choose how the number moves. A new number is the simplest. A number already on the WhatsApp Business app either moves to the API (the app stops working on it) or uses coexistence, which keeps the app and the API on the same number.
  4. Set up the webhook. Publish a callback URL, pass Meta's verify-token check, and subscribe to message and status events.
  5. Protect the access token. Keep it in a secrets manager, never in front-end code.
  6. Build the AI step. Send each message to your model with your content, let it call functions (look up an order, book a slot), and send the final answer back through the Messages API.
  7. Handle the edge cases. Webhooks can arrive twice, so save each message ID and skip repeats. Retry failed sends. Watch the number's quality rating.

The upside is control. The cost is that your team owns uptime, retries, template management, the inbox your agents work in, and every change Meta makes to the API.

Way 2: let a Business Solution Provider connect it

A Business Solution Provider (BSP) is a company Meta approved to connect businesses to the API. The BSP hosts the webhooks, sends the messages and often manages templates. You trade some control for speed and support, but you usually still bring the AI yourself.

Ask these questions before you sign:

  • Where does the AI run? Is it built in, or do you connect your own model through their API?
  • How do they bill? Per message, per month, per seat, or a markup on Meta's fees?
  • What happens when a send fails? Ask how they retry webhooks and messages.
  • Who manages templates, and how fast are rejected templates fixed?
  • Can you leave? Ask how you move the number to another provider later.
  • Security: do they have a SOC 2 report, audit logs and an uptime commitment?

A good pilot scorecard for a BSP: time to first message, delivery rate, how many chats reach a person, and cost per conversation.

Way 3: use a platform with the AI agent built in

The third way skips the plumbing. The platform connects the number, runs the AI agent, manages templates and gives your team an inbox, all in one place.

In Invent, you connect the number through Meta's Embedded Signup inside the app. It works for a new number, a number moved from another provider, or a number that stays on the WhatsApp Business app through coexistence. Templates are created, sent for approval and tracked in the same place, so nobody keeps a spreadsheet of approvals.

The AI agent answers from your website, documents and policies. When it should stop, AI routing sends the chat to the right person in the shared inbox. The teammate sees the whole conversation, the reason for the handoff and what the AI remembers about the customer. The same inbox holds WhatsApp, Instagram, TikTok and web chat, so one team covers every channel.

This way suits operations teams that want accurate answers and clean handoffs without hiring engineers. If you need custom logic that no platform supports, Way 1 gives you more room.

One WhatsApp number, many people answering

A common question is whether one WhatsApp number can serve a whole team. On the API, it can. The WhatsApp Business app limits you to a few linked devices. The API has no device limit: every message reaches your system, and your inbox decides who answers.

That is where AI and people split the work:

  • The AI answers first, around the clock, from your content.
  • AI routing picks the right person when the chat needs judgment, a refund, a complaint or a sale that needs a human touch.
  • Your team replies from the same number, so the customer never sees a handover to a different contact.

With a platform, this works on day one. On your own build, you need an inbox, assignment rules and a way to stop the AI from replying once a person steps in.

Where the AI decision should happen

The AI should never post to WhatsApp directly. Your pipeline checks the window, picks the message type and sends. The AI only decides what to say, or which action to run, such as looking up an order, booking an appointment or reading a policy.

Keep three guardrails in place:

  • Answer only from your content. An AI limited to your documents and site knows when it does not know.
  • Confirm before money moves. Refunds, payments and bookings should ask the customer to confirm in the chat.
  • Hand off on clear triggers. Low confidence, sensitive topics, angry customers and policy decisions go to a person.

What your security team will ask

If WhatsApp carries customer data, your security review will cover the same list for any of the three ways:

  • SOC 2 Type II report for enterprise buyers
  • Single sign-on with your identity provider
  • Audit logs of who did what, and custom roles for who can see which chats
  • Spending controls, so a busy month cannot surprise the finance team
  • Clear answers on where chats are stored, for how long, and whether they train any model

What it costs: a worked example

WhatsApp costs come from two bills: Meta's fees per message, and the platform that runs your AI agent. Here is how the Meta side adds up for one store.

Say an online shop has one WhatsApp number. In a month, 3,000 customers write in, and the AI agent sends about two replies each, so 6,000 replies inside open windows. The shop also sends 500 order updates the next day, outside the window.

  • The first 1,000 replies are free. Each number gets 1,000 free service messages a month, and the count resets every month.
  • The other 5,000 replies are billed at Meta's service rate for each customer's country.
  • The 500 order updates are templates, billed at Meta's utility rate for each country.
  • Free entry point: when a customer writes from a Click to WhatsApp ad, most messages are free for 7 days.

Rates change by country and Meta updates them, so take the per-message prices from Meta's current rate card. On top of Meta's bill, you pay for the AI and the platform. Fewer, better replies cost less on both bills, which is one more reason to keep the AI's answers short and correct.

Common WhatsApp API errors and how to fix them

Most failed sends come back with an error code. These are the ones teams meet first, with Meta's fix for each:

  • 131047, more than 24 hours since the customer replied: the window closed. Send an approved template instead.
  • 132001, template does not exist: the template is not approved yet, or its name or language does not match. Check both in your template list.
  • 131026, message undeliverable: the number may not use WhatsApp, or the customer has not accepted the latest terms or updated the app.
  • 131049, not delivered to keep engagement healthy: Meta limits how many marketing messages one person gets. Wait at least 24 hours before you try again.
  • 131056, too many messages to the same person: you sent too many in a short time to one customer. Wait, then retry. Other customers are not affected.
  • 130429, rate limit hit: you are sending too fast overall. Slow down and retry.
  • 131042, payment method problem: fix the payment method on your WhatsApp Business Account in Meta.
  • 368, account restricted: the account broke a WhatsApp policy. Read Meta's policy enforcement notice before you send again.

In Invent, a failed message shows its error next to it in the chat, so your team sees what went wrong without reading logs. On your own build, log each code with the message ID and alert someone when failures rise.

Run a pilot before you roll out

Start with one WhatsApp number and one use case, such as order questions or appointment booking. Then run four tests in this order:

  1. First inbound message reaches your system once, not twice.
  2. First AI reply is correct and goes out inside the window.
  3. First handoff reaches the right person with the full conversation.
  4. First template send goes out after the window closes.

Track first response time, resolution time, CSAT, handoff rate and cost per conversation for two weeks. Read 50 conversations by hand and score the AI's answers and its handoff decisions. Know your rollback: pause the AI and route every chat to your team if something misbehaves.

On cost, a platform like Invent starts at $29 a month with $29 of usage on the Business plan. As you grow you pay as you go, with AI replies from $0.003 per message depending on the model. Meta's WhatsApp fees are a separate bill, sent directly by Meta. There is a free plan to try it.

Pick the way that fits your team

Choose Way 1 if you have engineers and want control of every layer. Choose Way 2 if you want a vendor to run the connection and you already have an AI. Choose Way 3 if you want the AI agent, templates and the team inbox in one place.

Comparison table of 3 ways to connect AI to WhatsApp. Build it yourself: your developers set it up, you build the AI agent and the team inbox, templates live in Meta's dashboard and your team maintains it. Business Solution Provider: the vendor sets it up, you bring your own AI agent, the team inbox depends on the vendor. Platform with AI built in: no code, AI agent built in, shared inbox, templates in the same app, the platform maintains it.

Whichever you pick, connect one number, run the pilot, read the numbers, then expand. For the no-code walkthrough, read how to build a WhatsApp AI chatbot without code.

FAQs

How do I connect an AI assistant to the WhatsApp Business API?

You connect your number to Meta's Cloud API, receive messages through a webhook, pass each message to the AI, and send its reply back inside the 24-hour window. A platform such as Invent does all four steps for you through Meta's Embedded Signup, with no code.

Which WhatsApp API platform has AI built in?

Invent connects the WhatsApp Business API with an AI agent, approved templates, AI routing and a shared inbox in one place. Most Business Solution Providers handle the connection only, so you add the AI yourself.

Can I keep the WhatsApp Business app on the same number?

Yes, with coexistence. The app and the API share one number, so you keep answering from your phone while the AI handles the rest. Without coexistence, moving a number to the API turns off the app on that number.

Can several agents answer from one WhatsApp number?

Yes, on the API. Every message reaches your system, and a shared inbox lets any number of teammates reply from the same number. The WhatsApp Business app limits you to a few linked devices.

Do WhatsApp message templates need approval?

Yes. Meta reviews every template before you can send it, usually within minutes to a day. Templates are required to start a conversation or to message a customer after the 24-hour window closes.

Why did my WhatsApp message fail after 24 hours?

The customer service window closed. After 24 hours without a message from the customer, only an approved template can go out. Send a template, and the window reopens when the customer replies.

What is a WhatsApp AI agent?

A WhatsApp AI agent is software that reads customer messages on WhatsApp and answers them from your business content, and can take actions such as booking or looking up an order. It hands the chat to a person when it should not answer alone.

How much does it cost to connect AI to WhatsApp?

You pay Meta per message, by category and country, with the first 1,000 service replies per number free each month, and you pay for the AI and the platform. Invent's Business plan is $29 a month with $29 of usage, then pay as you go, with AI replies from $0.003 per message depending on the model. Meta bills its fees separately.

Start Building Your Assistant For Free

No credit card required.