What is a contextual reply?
A contextual reply is a WhatsApp message that answers a specific earlier message and shows it quoted in a small bubble above the new content — the API version of a user swiping to reply in their own chats. On the Cloud API a business sends one by adding a context object with message_id, the wamid of the message being answered, to an ordinary send request; everything else in the request (text, image, interactive and so on) stays the same.
It works in both directions. When a customer replies to one of your messages, the inbound messages webhook includes context.id, the wamid of the quoted message, and context.from, the business number that sent it, so your system knows exactly which question, offer or order they mean. The same context object also flags forwarded messages (forwarded, frequently_forwarded) and product enquiries from a catalogue (referred_product).
A contextual reply is threading, not acknowledgement or input. It differs from a reaction message, which pins an emoji to a message and cannot itself be sent as a contextual reply, and from an interactive reply, the button_reply or list_reply object a tap produces. The quote has limits: it is not drawn on template messages, on replies to messages that were deleted or moved to long-term storage (typically after 30 days unless local storage is enabled), or on some media replies to KaiOS users.
Key takeaways
- A contextual reply quotes an earlier message: add
context.message_idwith that message's wamid to any send request. - When a customer swipes to reply, the inbound webhook carries
context.id(the quoted wamid) andcontext.from. - No quote is shown on templates, or when the original was deleted or moved to long-term storage, typically after 30 days.
- Reactions cannot be sent as contextual replies; a reaction names its target in its own
message_idfield. - Route inbound replies on
context.idto know which question, offer or order the customer is answering.
Figure 1
Trace a quoted reply from the send to your router
curl -X POST "https://graph.facebook.com/v26.0/{PHONE_NUMBER_ID}/messages" \ -H "Authorization: Bearer {ACCESS_TOKEN}" \ -H "Content-Type: application/json" \ -d '{ "messaging_product": "whatsapp", "recipient_type": "individual", "to": "919812345678", "context": { "message_id": "wamid.HBgMOTE5ODEyMzQ1Njc4FQIAEhgUM0EwQjE2RDU2N0YzQjQ5MDk0QzQA" }, "type": "text", "text": { "body": "Yes, it ships to Siliguri in 3–4 days." } }'Step 3 of 3 · lines 11–12
Any normal content follows. Text, media and interactive messages can all carry context.
Send with context (cURL), step 3 of 3, lines 11–12: Any normal content follows. Text, media and interactive messages can all carry context.
A contextual reply in code
import requestsdef reply_in_context(to: str, quoted_wamid: str, body: str) -> str:resp = requests.post("https://graph.facebook.com/v26.0/{PHONE_NUMBER_ID}/messages",headers={"Authorization": "Bearer {ACCESS_TOKEN}"},json={"messaging_product": "whatsapp","recipient_type": "individual","to": to,"context": {"message_id": quoted_wamid},"type": "text","text": {"body": body},},timeout=10,)resp.raise_for_status()# Store the new wamid too: the customer may quote this message next.return resp.json()["messages"][0]["id"]
How does a contextual reply work?
Keep every wamid
Store the
messages[0].idreturned when you send, with what the message was for, and theidof each inbound message. Contextual replies refer to messages only by wamid.Quote when you reply
Add
"context": { "message_id": "wamid…" }to the send body. It works with text, media and interactive messages; on templates the quote is not drawn.Read context on inbound
If
messages[0].context.idexists, it is the message being answered. Look it up to recover the order, campaign or question it belongs to.Route on what was quoted
A "yes" quoting a delivery-slot offer goes to logistics; the same "yes" quoting a payment reminder goes to accounts. With no context, fall back to conversation state.
Handle unknown IDs calmly
The quoted wamid may belong to an old campaign you never stored, or to a forwarded message. Treat it as a normal message rather than an error.
Why it matters
Why does a contextual reply matter?
In a busy chat, "yes" means nothing without context. A customer who has received an order confirmation, a delivery update and a feedback request, then writes "cancel it", could mean any of them. Reading context.id tells a bot or agent which message the reply points at, and quoting a customer's question in your answer — especially when several questions arrived at once — keeps a long support thread readable for both sides.Example: Three questions, three quotes, one cart
A Kolkata saree retailer's agent gets three questions from one customer within a minute: is the blue Baluchari back in stock, does it ship to Siliguri, and can she pay on delivery. The agent answers each as a contextual reply quoting the matching question, so the customer can follow the thread. Two days later she swipes to reply "Book it" on the retailer's restock alert; the webhook's context.id points at that wamid, the bot finds the product the alert announced, and it opens a cart for the right saree instead of asking "which one?".
Common mistakes with a contextual reply
Not storing outbound wamids
Without the ID returned at send time you cannot map
context.idback to an order or campaign. Persist every wamid with a purpose label.Expecting a quote on templates
Templates sent with
contextdo not show the quote bubble. When re-engaging outside the window, restate the details in the template body instead.Quoting very old messages
Once the original has been deleted or moved to long-term storage, typically after 30 days, the reply arrives without a quote. Say what you are answering in the text as well.
Treating context as required
Most customers type without swiping to reply. Use
contextwhen it is present and conversation state when it is not.Confusing it with reactions and taps
A reaction is a
reactionmessage whose target is inreaction.message_id; a button tap arrives as aninteractiveorbuttonmessage whosecontext.idpoints at the message that had the button. Route each type on its own fields.
Best practices for a contextual reply
- Save each outbound wamid with a purpose such as
restock_alertorpayment_reminder, so a context lookup is one query. - When answering several questions at once, quote each one instead of writing a numbered wall of text.
- Show the quoted message to agents in the inbox; it saves a round of "which one do you mean?".
- Use
referred_productto open the right product when a customer asks about a catalogue item.
Contextual Reply FAQs
- How do I reply to a specific message with the WhatsApp Cloud API?
- Add a context object with message_id set to that message's wamid to your send request. The customer sees your message with the original quoted above it.
- How do I know which message a customer replied to?
- Read context.id in the inbound webhook. It holds the wamid of the quoted message and context.from the number that sent it; if there is no context, the customer did not quote anything.
- Why is the quoted message not showing above my reply?
- The original may be a template, deleted, or moved to long-term storage, which typically happens after 30 days. The reply is still delivered, just without the quote bubble.
- Is a contextual reply the same as a reaction?
- No. A contextual reply is a full new message that quotes an earlier one; a reaction pins an emoji to a message without adding a bubble, and reactions cannot be sent as contextual replies.
- Does a contextual reply cost extra?
- No. It is billed like any other message of its kind: a free-form reply in the window is a service message and a template is billed by its category; the context object adds no charge.