WhatsApp Business API for AI Agents: Templates, Buttons and the 24-Hour Window
How to put an AI agent on WhatsApp: the 24-hour customer service window, when you need approved templates, interactive buttons and list menus, and how WhatsApp threads into the same conversations as SMS and iMessage.

Putting an AI agent on WhatsApp is mostly easy. You connect a WhatsApp Business Account, inbound messages hit your webhook, and your agent replies. The part that trips people up is one rule from Meta: the 24-hour customer service window. This post explains that rule, when your agent needs approved templates, how to use buttons and list menus so customers tap instead of type, and how WhatsApp fits into the same conversation model as SMS and iMessage on AgentPhone. WhatsApp is in beta and switched on for every AgentPhone account.
Connecting WhatsApp
In the AgentPhone dashboard, open WhatsApp and click Connect WhatsApp. That runs Meta's Embedded Signup in a popup, where you create or pick a WhatsApp Business Account (WABA) and choose a phone number. If the number is already on WhatsApp with another app or provider, talk to support about migration first. Deleting an existing WhatsApp account is not a normal setup step.
Then check the connection:
curl https://api.agentphone.ai/integrations/whatsapp/status \-H "Authorization: Bearer $AGENTPHONE_API_KEY"
{"connected": true,"enabled": true,"connections": [{"connection_id": "example_id","waba_id": "123456789012345","connected_at": "2026-07-31T02:31:44Z","numbers": [{ "id": "example_id", "phone_number": "+12125550199", "agent_id": "example_id" }]}]}
The 24-hour window
This rule comes from Meta, and it shapes every WhatsApp agent:
- You can send a free-form message to someone only if they messaged you in the last 24 hours.
- The window opens on each inbound message and closes 24 hours after the most recent one.
- Outside the window, the only thing you can send is an approved template. Free-form sends are rejected (AgentPhone returns a
422).
There is no workaround, and adding numbers does not help. The good news is you never have to guess. GET /v1/conversations/{id} tells you where you stand:
{"capabilities": {"canSendMessages": true,"whatsappWindowExpiresAt": "2026-08-21T01:21:59Z"}}
When the window closes, canSendMessages turns false and sendDisabledReason explains why, so your agent can switch to a template instead of failing a send.
For an AI agent this has a practical effect. Inbound-led flows (support, booking, Q&A) just work, because the customer opens the window. Proactive flows (reminders, follow-ups a day later) need templates.
Sending inside the window
Inside the window, your agent sends with the same POST /v1/messages endpoint used for every channel, with channel: "whatsapp". There is no automatic fallback to or from WhatsApp, so you pick it explicitly.
Reply buttons
Up to 3 buttons, 20 characters each. Great for confirmations:
{"number_id": "YOUR_NUMBER_ID","to_number": "+14155550123","channel": "whatsapp","body": "Your appointment is Friday at 3pm. What would you like to do?","buttons": ["Confirm", "Reschedule", "Cancel"]}
Add media_urls and the image, video or document becomes a header above the text, in the same bubble as the buttons.
List menus
When there are more than three choices, use a list: up to 10 rows, 24 characters each.
{"number_id": "YOUR_NUMBER_ID","to_number": "+14155550123","channel": "whatsapp","body": "How can I help?","list": { "button": "Choose", "options": ["Book a table", "Order status", "Talk to a human"] }}
Link buttons, quote replies and reactions
- Link button: one tappable link on an ordinary message, with no template review.
- Quote reply: set
reply_to_message_idand your message shows the customer's message quoted above it. Useful when someone sends five questions and you answer the third. Meta will not quote messages older than 30 days. - Reactions:
POST /v1/messages/{message_id}/reactionswith a reaction such aslove.
Templates: the only way outside the window
Templates are pre-approved message bodies. They are how your agent opens a conversation or follows up after 24 hours. You create them with POST /integrations/whatsapp/{connection_id}/templates, list them with a GET on the same path, and delete them when you are done.
Meta reviews each template. UTILITY templates usually clear in minutes, MARKETING can take longer, and Meta may recategorize based on content. Any component with a variable needs an example or it is rejected. You can also start from Meta's library with library_template_name instead of writing components yourself.
Once a template is APPROVED, send it like this:
{"number_id": "YOUR_NUMBER_ID","to_number": "+14155550123","channel": "whatsapp","template": { "name": "order_shipped", "language": "en_US", "variables": ["1234"] }}
Templates with named variables ({{first_name}}) take an object instead: "variables": { "first_name": "Pablo" }. The shape must match how the template was written or Meta rejects the send.
Receiving: taps and replies carry context
Button and list taps arrive at your webhook as ordinary inbound messages, where message is the label the customer tapped. Each tap also carries replyTo, pointing at the message that offered the choice. That matters when you send several similar messages. If you send five product cards that each have a Buy button, the label alone cannot tell you which one they meant, but replyTo.messageId can.
Like every channel on AgentPhone, WhatsApp messages arrive as agent.message events with recentHistory attached, in the same conversation model as SMS, iMessage and voice. Your agent does not need a separate WhatsApp integration, only channel: "whatsapp" when it replies.
Pricing
AgentPhone adds nothing on top of WhatsApp: $0 per message. Meta bills conversation fees directly to your WhatsApp Business Account.
Quick reference
| Rule | Limit |
|---|---|
| Free-form messages | Only within 24 hours of the customer's last message |
| Outside the window | Approved templates only |
| Reply buttons | 3 max, 20 characters each |
| List rows | 10 max, 24 characters each |
| Quote replies | Parent message under 30 days old |
| Group chats | Not supported through the API |
FAQ
Can an AI agent use the WhatsApp Business API? Yes. Connect your WhatsApp Business Account to AgentPhone and your agent receives messages by webhook and replies with POST /v1/messages.
Why did my WhatsApp message fail with 422? Most likely the 24-hour window closed. Send an approved template instead, and check canSendMessages before sending.
How long does template approval take? Utility templates usually clear in minutes. Marketing templates can take longer.
Does AgentPhone charge for WhatsApp messages? No. AgentPhone charges $0 per message, and Meta bills your WABA directly.
Is WhatsApp available on my account? Yes. It is in beta and on for every account. Send feedback to founders@agentphone.to.
See the WhatsApp docs guide for every field and template option.


