Use cases

Put an AI agent on WhatsApp

Put an AI agent on the WhatsApp number your customers already message. Webhook in, HTTP request out, and the model in between is entirely yours.

Last updated 2026-08-02

An AI agent that answers WhatsApp needs exactly two things: a way to hear incoming messages and a way to send replies. Both are ordinary HTTP, so whatever you have already built works without adapting it to a chat platform.

The whole loop

js
app.post('/webhooks/wasender', async (req, res) => {
  res.sendStatus(200);

  const incoming = req.body;
  if (!isInboundMessage(incoming)) return;

  const answer = await agent.run(incoming.text);

  await fetch('https://api.wasender.dev/messages/text', {
    method: 'POST',
    headers: {
      Authorization: `Bearer ${process.env.WASENDER_TOKEN}`,
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({ to: incoming.from, body: answer }),
  });
});

That is the integration. agent.run is a call to OpenAI or Claude, a LangChain chain, a workflow in n8n, or a function you wrote yourself. Nothing about it is WhatsApp specific.

Acknowledge the webhook with a 200 before you call the model. Agent calls routinely take several seconds, and a delivery that has not been acknowledged will be retried, which is how you end up answering the same customer twice.

Getting set up

  1. Create a channel in the dashboard and copy the token.
  2. Fetch the QR code from GET /users/login/image and scan it in WhatsApp under Settings, Linked devices, Link a device.
  3. Point the channel at your webhook with PATCH /settings, subscribing to messages.
  4. Send your number a message and watch it arrive.

Handling a conversation, not a message

A model answering one message at a time has no memory of the last one. Key a conversation store on the sender's chat id and pass the recent history into each call:

js
const history = await store.get(incoming.from);
const answer = await agent.run({ history, message: incoming.text });
await store.append(incoming.from, incoming.text, answer);

Two things worth adding early: a cap on how far back the history goes, since WhatsApp threads run for months and context windows do not, and a way for a customer to reach a human.

Making it feel like a person is there

Send a typing indicator while the model thinks. A three second pause with no signal reads as broken; the same pause with a typing indicator reads as someone composing a reply.

bash
curl -X PUT "https://api.wasender.dev/presences/61371989950" \
  -H "Authorization: Bearer $WASENDER_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"presence": "typing"}'

Your agent can also send images, documents, locations, contact cards and polls. An agent that answers "where are you based" with a map pin instead of an address is doing something a web chat widget cannot.

What this is good at

Customer service. Answer the same twenty questions forever, escalate the rest. Your agent already knows your product; this connects it to where customers ask.

Appointment scheduling. Check a calendar, offer times, confirm, and send a reminder the day before.

Order and delivery updates. Reply to "where is my order" with a real lookup instead of a tracking link nobody opens.

Lead qualification. Ask the three questions your sales team always asks, and hand over a warm conversation rather than a form submission.

Things that will bite you

A 2xx is not delivery. It means WhatsApp accepted the message. Confirm with GET /statuses/{MessageID} or the statuses webhook events if it matters.

Rate limits are protection, not upsell. They exist to keep WhatsApp's anti abuse systems away from your number. Back off on a 429 rather than retrying immediately.

Reconnects return 503. During a session reconnect the API answers 503. Retry with backoff and your agent stays up.

Do not let the agent send first contact messages. Replying to someone who messaged you is fine. Opening conversations with people who never opted in is the single most reliable way to get a number restricted.

Costs

A flat $4 a month per connected number, and the first one is free permanently. There is no per message fee, so an agent handling ten conversations and one handling ten thousand cost the same.

A note on which number to use

This drives WhatsApp through an unofficial client, the same mechanism WhatsApp Web uses. Meta does not sanction it, so use a dedicated number rather than your main business line. For regulated workloads, use Meta's official Cloud API instead.

Back to all articles

Your first WhatsApp number is free

No credit card. Free forever, not a trial.

Start free