WhatsApp reply buttons via API: payload and limits
Send interactive reply buttons through the CRPRO Hub: payload, the 3-button and 20-character limits, id design, and reading button_reply in the webhook.
Reply buttons let a customer answer with one tap instead of typing: confirm or cancel, pick a time, choose between two options. They are an interactive message with up to three buttons, and the answer comes back as an ordinary inbound message that carries the id you chose. This tutorial sends them through the CRPRO Hub, lists the limits that the Hub validates and shows how to read the tap.
What does a reply buttons payload look like?
Short answer: type interactive, with an interactive object of type button that has a body and an action holding one to three reply buttons, each with an id and a title.
curl -X POST https://crprohub.com/api/v1/channels/CHANNEL_UUID/messages \
-H "Authorization: Bearer hub_pk_EXAMPLE_NOT_REAL" \
-H "Idempotency-Key: confirm-slot-1042" \
-H "Content-Type: application/json" \
-d '{
"to": "5521999999999",
"type": "interactive",
"interactive": {
"type": "button",
"header": { "type": "text", "text": "Delivery slot" },
"body": { "text": "Tomorrow between 2 pm and 4 pm works for your delivery?" },
"footer": { "text": "Order 1042" },
"action": {
"buttons": [
{ "type": "reply", "reply": { "id": "slot_ok_1042", "title": "Yes, confirm" } },
{ "type": "reply", "reply": { "id": "slot_change_1042", "title": "Change time" } }
]
}
}
}'The header and footer are optional. The response is the usual 202 with a message_id. Authentication and the first request are covered in the quickstart.
Which limits does the Hub enforce on buttons?
Short answer: at most 3 buttons, titles up to 20 characters, ids up to 256 characters, a body of up to 1,024 characters and a text header or footer of up to 60 characters.
| Element | Limit | Source |
|---|---|---|
| Buttons | 1 to 3 | Hub schema and Meta |
| Button title | 1 to 20 characters, unique across the message | Hub schema (length), Meta (uniqueness) |
| Button id | 1 to 256 characters | Hub schema and Meta |
| Body text | 1 to 1,024 characters | Hub schema and Meta |
| Header | Optional, text only in the Hub, up to 60 characters | Hub schema |
| Footer | Optional, up to 60 characters | Hub schema and Meta |
Meta's reply buttons reference allows image, video and document headers as well. The Hub's schema accepts only a text header for interactive messages, so a media header is refused with 400 INVALID_MESSAGE. If you want a picture above the choices, send the image first and the buttons straight after it. Meta also requires unique button titles; the Hub validates the length, and a duplicate title is something Meta can reject after acceptance, so keep titles distinct in your own code.
How should button ids be designed?
Short answer: as stable, machine-readable keys that identify the action and the object, such as slot_ok_1042. Never rely on the title for logic.
The id is the contract between the message and your handler. The title is a label the customer reads and that you may reword, translate or shorten. Encoding the action and the object in the id lets a handler act without a database lookup for simple cases: slot_ok_1042 says confirm slot for order 1042. Keep ids within the 256-character limit, avoid personal data in them, and validate on receipt that the action is actually pending, because a customer can tap an old button days later.
const ID_PATTERN = /^(slot_ok|slot_change)_(\d+)$/
function buildSlotButtons(orderId) {
return [
{ type: 'reply', reply: { id: `slot_ok_${orderId}`, title: 'Yes, confirm' } },
{ type: 'reply', reply: { id: `slot_change_${orderId}`, title: 'Change time' } },
]
}
function parseButtonId(id) {
const m = ID_PATTERN.exec(id)
return m ? { action: m[1], orderId: m[2] } : null
}How does the customer's tap reach the application?
Short answer: as a message.received event of type interactive. The choice is in content.interactive, as a button_reply with the id and title. There is no separate callback for taps.
Meta's inbound payload for a tap carries interactive.type button_reply with button_reply.id and button_reply.title, plus a context object whose id is the interactive message that contained the button. The Hub's normalized event exposes this in data.content.interactive, and the plain text field is empty for a tap, so a handler that reads only text misses the answer. Use the id for decisions. Subscription, signature checks and payload modes are described in the webhooks reference.
function readTap(event) {
const i = event.data.content?.interactive
if (i?.type === 'button_reply') {
return { id: i.button_reply.id, title: i.button_reply.title }
}
return null
}
app.post('/webhooks/crprohub', async (req, res) => {
const event = req.body
res.sendStatus(200) // acknowledge first
const tap = readTap(event)
const parsed = tap && parseButtonId(tap.id)
if (parsed?.action === 'slot_ok') await confirmSlot(parsed.orderId)
})The example acknowledges the webhook before doing the work. A production handler would verify the signature first and push the event to a queue, as the webhooks reference explains.
How can the tap handler be tested?
Short answer: save one real inbound event as a fixture, then feed it to the handler in a unit test. No phone is needed after the first capture.
Send the buttons to a test number, tap one and copy the body your endpoint received from the deliveries list described in the webhooks reference. That body is the truth about field names for your channel. Put it in a fixtures folder, and write tests for the three cases that matter: a valid known id, an id your code does not recognise and a message that is not a tap at all. The unknown id test is the important one, because a button sent by an older version of your application can come back after you changed the id format.
import test from 'node:test'
import assert from 'node:assert/strict'
test('ignores an unknown button id', () => {
assert.equal(parseButtonId('something_else_1'), null)
})
test('parses a confirm id', () => {
assert.deepEqual(parseButtonId('slot_ok_1042'), { action: 'slot_ok', orderId: '1042' })
})Pair this with an idempotent handler. If the same tap event is delivered twice, confirming a slot twice must be harmless. Deduplicate on the event id before acting, and make the confirmation itself safe to repeat.
What usually goes wrong with reply buttons?
Short answer: oversize titles, more than three buttons, a media header and a free-form send outside the 24-hour window.
- Four buttons: the schema allows at most three. Use a list for longer menus.
- A 21-character title: refused locally with 400 INVALID_MESSAGE, which is better than a later Meta failure.
- Media in the header: not accepted by the Hub; send media as a separate message.
- Duplicate ids or titles: keep each unique within the message.
- Closed window: interactive messages are free-form, so outside the 24-hour window they fail after acceptance and a template is required.
Remember that the customer may ignore the buttons and type. Your handler should accept a free-text answer on the same turn rather than assume that every reply is a tap.
How should button labels and prompts be written?
Short answer: short verbs in the customer's language, mutually exclusive options and a body that asks one clear question.
With 20 characters per label, every word counts. Labels that start with a verb, such as Confirm or Change time, read as actions. Options should not overlap: if two labels could both describe the customer's intent, the tap tells you nothing. The body should contain the question and the context needed to answer it, such as the date or the order number, so the buttons make sense even if the customer scrolls back to them later in the day. Avoid emoji-only labels, which are hard to interpret in logs and for accessibility tools.
- Start labels with a verb and keep them under 20 characters.
- Make the options mutually exclusive.
- Include the subject in the body, for example the order number.
- Add an escape option when the choices may not fit.
- Review labels with a native speaker for each language you support.
How should a button flow be rolled out safely?
Short answer: ship it behind a switch, try it with a test number, watch the failed statuses and keep a typed-text fallback.
Interactive messages behave well on current clients, but you control only your side. Start with internal numbers, confirm that every tap lands on the intended action and check the statuses for failures that point to payload problems, such as a rejected button count or title. Keep the fallback path alive: if a customer types an answer, the same decision should be reachable. Only after a few days of clean results is it worth widening the audience. A switch that returns the flow to plain text takes minutes to flip and removes the pressure if something unexpected appears.
- Use a feature switch for the button flow.
- Start with test numbers and internal staff.
- Review failed statuses and their error codes.
- Keep a text path for every decision.
- Log the id of each tap for later analysis.
Frequently asked questions
How many reply buttons can one message have?
Between one and three. For more than three options use an interactive list, which allows up to ten rows.
Does the Hub accept an image header on a button message?
No. Meta allows document, image, text and video headers, but the Hub's schema accepts only a text header for interactive messages. Send the image as its own message before the buttons.
Should logic match on the button title or the id?
The id. Titles are labels that can change or be translated. The tap arrives with both, and the id is the stable identifier you defined.
What happens if the customer taps an old button?
The tap still arrives as a normal inbound event. Your handler must check whether the action is still pending and ignore or answer politely when it is not.
Fontes
Documentação oficial da Meta, conferida em 31 de outubro de 2026.