A quick-reply tap reaches your webhook as a messages event, with your payload in message.quick_reply.payload and the button title in message.text. A tap on a postback button arrives as a messaging_postbacks event with the payload in postback.payload. So do the Get Started button and persistent menu items. Subscribe your Page to both fields, or one kind of tap never reaches your server. All four message types below are sent with a POST to https://graph.facebook.com/v26.0/me/messages and a Page access token.
Limits for each message type
These are the limits Meta prints on each page, all accessed 2026-11-04: quick replies, button template, generic template, media template, postback button and URL button.
| Element | Limit | Tap arrives as |
|---|---|---|
| Quick replies | 13 per message; title 20 characters; payload 1,000 characters; image_url at least 24 x 24 px |
messages |
| Button template | text up to 640 characters; 1 to 3 buttons |
messaging_postbacks (postback buttons) |
| Generic template | Up to 10 elements; title and subtitle 80 characters each; 3 buttons per element |
messaging_postbacks (postback buttons) |
| Media template | 1 element, image or video only; 3 buttons | messaging_postbacks (postback buttons) |
| Postback button | title 20 characters; payload 1,000 characters |
messaging_postbacks |
| URL button | title 20 characters |
Opens the URL; not a messaging_postbacks trigger |
Each template send returns recipient_id and message_id. The token, Page subscription and first text message are covered in the Messenger Send API setup.
Send quick replies
The user taps a quick reply instead of typing. The tap removes the buttons and posts the title into the thread as the user’s message. Meta’s best-practice note says “Quick replies disappear after the next message”, so put lasting actions in a persistent menu instead.
This is Meta’s sample with the placeholder payloads given values and the image URLs moved to HTTPS.
curl -X POST -H "Content-Type: application/json" -d '{
"recipient": { "id": "PSID" },
"messaging_type": "RESPONSE",
"message": {
"text": "Pick a color:",
"quick_replies": [
{ "content_type": "text", "title": "Red", "payload": "PICK_RED", "image_url": "https://example.com/img/red.png" },
{ "content_type": "text", "title": "Green", "payload": "PICK_GREEN", "image_url": "https://example.com/img/green.png" }
]
}
}' "https://graph.facebook.com/v26.0/me/messages?access_token=PAGE_ACCESS_TOKEN"
A text quick reply needs title and payload. payload may be an empty string when you set image_url, and image_url is required when title is empty. The message must also carry text or an attachment. Larger images “are automatically cropped and resized.”
Two other content types ask for contact data: { "content_type": "user_phone_number" } and { "content_type": "user_email" }. Messenger pre-fills them from the person’s profile and hides the button when the profile lacks the value. The value comes back in both quick_reply.payload and text. Meta adds that choosing it “transmits the information once and does not constitute permission to access the information in the future.”
Send a button template
The button template is a text of up to 640 characters with one to three buttons under it. This body joins Meta’s web_url sample from the button template page with the postback button from the postback button page, with the postback title and payload renamed.
curl -X POST -H "Content-Type: application/json" -d '{
"recipient": { "id": "PSID" },
"message": {
"attachment": {
"type": "template",
"payload": {
"template_type": "button",
"text": "What do you want to do next?",
"buttons": [
{ "type": "web_url", "url": "https://www.messenger.com", "title": "Visit Messenger" },
{ "type": "postback", "title": "Talk to us", "payload": "TALK_TO_US" }
]
}
}
}
}' "https://graph.facebook.com/v26.0/me/messages?access_token=PAGE_ACCESS_TOKEN"
Meta’s buttons overview lists six types: web_url, postback, phone_number, account_link, account_unlink and game_play. A URL button opens in the Messenger webview. webview_height_ratio takes compact, tall or full, and defaults to full. With messenger_extensions set to true, the URL must use HTTPS and its domain must be in the Messenger Profile whitelisted_domains. webview_share_button: "hide" removes the share button for pages that show private data.
Send a generic template carousel
A generic template is a card with an image, a title, a subtitle and up to three buttons. Put up to 10 cards in elements and Messenger shows them as a horizontal carousel. Meta’s sample runs as published.
curl -X POST -H "Content-Type: application/json" -d '{
"recipient": { "id": "PSID" },
"message": {
"attachment": {
"type": "template",
"payload": {
"template_type": "generic",
"elements": [
{
"title": "Welcome!",
"image_url": "https://raw.githubusercontent.com/fbsamples/original-coast-clothing/main/public/styles/male-work.jpg",
"subtitle": "We have the right hat for everyone.",
"default_action": {
"type": "web_url",
"url": "https://www.originalcoastclothing.com/",
"webview_height_ratio": "tall"
},
"buttons": [
{ "type": "web_url", "url": "https://www.originalcoastclothing.com/", "title": "View Website" },
{ "type": "postback", "title": "Start Chatting", "payload": "DEVELOPER_DEFINED_PAYLOAD" }
]
}
]
}
}
}
}' "https://graph.facebook.com/v26.0/me/messages?access_token=PAGE_ACCESS_TOKEN"
Every element needs at least one property besides title. default_action takes the URL button fields except title and opens when the person taps the card itself. “Messenger scales or crops photos in the generic template that are not 1.91:1”, so crop your images to that ratio before you send. GIFs show but don’t animate. Set sharable: true on the payload to show the native share button.
Meta also advises putting the most important card first, since people don’t always scroll to the end. Meta’s page gives no maximum image size or file format for the cards.
Send a media template
The media template sends one image or one video with up to three buttons. Audio is not supported. Meta’s page says “The media template does not allow any external URL, only Facebook URLs.” It accepts four URL shapes: business.facebook.com/PAGE_NAME/videos/ID, www.facebook.com/USERNAME/videos/ID/, business.facebook.com/PAGE_NAME/photos/ID and www.facebook.com/photo.php?fbid=ID. For any other file, upload it first and send the attachment_id.
The Attachment Upload API (accessed 2026-11-04) fetches the file from your URL and returns {"attachment_id": "..."}. Meta’s sample uses v2.10 and an HTTP URL. Both are updated here.
curl -X POST "https://graph.facebook.com/v26.0/me/message_attachments?access_token=PAGE_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"message": {
"attachment": {
"type": "image",
"payload": { "url": "https://example.com/image.jpg", "is_reusable": true }
}
}
}'
Then send the template with that ID. Use "media_type": "video" for a video.
curl -X POST -H "Content-Type: application/json" -d '{
"recipient": { "id": "PSID" },
"message": {
"attachment": {
"type": "template",
"payload": {
"template_type": "media",
"elements": [ { "media_type": "image", "attachment_id": "ATTACHMENT_ID" } ]
}
}
}
}' "https://graph.facebook.com/v26.0/me/messages?access_token=PAGE_ACCESS_TOKEN"
attachment_id and url exclude each other, and attachment IDs don’t work for media from Facebook URLs. “Attachment IDs expire after 90 days”, so re-upload anything you keep sending. The upload accepts up to 8 MB for images and 25 MB for other files, after encoding. Meta’s fetch times out after 75 seconds for video and 10 seconds for other files, so host the file somewhere fast.
Route quick replies and postbacks in one webhook
Both events share the entry[].messaging[] envelope, so one loop can tell them apart. A postback key means a button, Get Started or menu tap. A message with a quick_reply key means a quick-reply tap. A message with only text is typed input (quick replies, messaging_postbacks, webhooks, accessed 2026-11-04).
The router below runs on Python 3.9 or later with the standard library. Its two test bodies are Meta’s samples. The quick-reply one comes from the quick replies page, and the postback one from the webhooks page, with its angle-bracket placeholders written as plain strings.
import json
QUICK_REPLY_SAMPLE = """{"object": "page", "entry": [{"id": "PAGE_ID", "time": 1502905976963, "messaging": [
{"sender": {"id": "1254459154682919"}, "recipient": {"id": "682498171943165"}, "timestamp": 1502905976377,
"message": {"quick_reply": {"payload": "DEVELOPER_DEFINED_PAYLOAD_FOR_PICKING_GREEN"},
"mid": "m_AG5Hz2Uq7tuwNEhXfYYKj8mJEM_QPpz5jdCK48PnKAjSdjfipqxqMvK8ma6AC8fplwlqLP_5cgXIbu7I3rBN0P",
"text": "Green"}}]}]}"""
POSTBACK_SAMPLE = """{"object": "page", "entry": [{"id": "PAGE_ID", "time": 1458692752478, "messaging": [
{"sender": {"id": "PSID"}, "recipient": {"id": "PAGE_ID"}, "timestamp": 1458692752478,
"postback": {"title": "BUTTON_TITLE", "payload": "DEVELOPER_DEFINED_PAYLOAD"}}]}]}"""
seen_mids = set() # in memory for the demo; use a database table in production
def classify(event):
if "postback" in event:
postback = event["postback"]
return "postback", postback.get("payload"), postback.get("title")
message = event.get("message") or {}
if "quick_reply" in message:
return "quick_reply", message["quick_reply"].get("payload"), message.get("text")
if "text" in message:
return "text", None, message["text"]
return "other", None, None
def route(body):
events = [e for entry in body.get("entry", []) for e in entry.get("messaging", [])]
events.sort(key=lambda e: e.get("timestamp", 0)) # Meta may deliver out of order
results = []
for event in events:
mid = (event.get("message") or event.get("postback") or {}).get("mid")
if mid in seen_mids:
continue # a retried delivery
if mid:
seen_mids.add(mid)
kind, payload, title = classify(event)
results.append((event["sender"]["id"], kind, payload, title))
return results
if __name__ == "__main__":
for sample in (QUICK_REPLY_SAMPLE, POSTBACK_SAMPLE):
print(route(json.loads(sample)))
It prints one tuple per event: sender PSID, kind, payload and title. Dispatch on kind first and on payload second. A quick reply and a postback button with the same payload string are still different events.
Meta’s webhook page sets the rules around this code. Your endpoint “must return a 200 OK response” in 5 seconds or less. Failed deliveries are retried, which is why the router skips a mid it has already seen. Events can arrive out of order, hence the sort on timestamp.
After an hour of failures Meta unsubscribes the app. Check X-Hub-Signature-256 on the raw body before you parse it, as described in webhook signature verification, since Messenger signs with the same App Secret HMAC. For a dedupe table that survives restarts, see idempotent webhook handling.
postback.payload “is only included in the webhook notification sent to the app that sent the message to the person.” If several apps share a Page, the app that sent the template is the only one that sees the payload. A postback.referral object appears only when the conversation began from an m.me link, a Click to Messenger ad, a Messenger QR code or the welcome screen.
Z-API Omni team