Skip to main content

Reply to a Message

Use the POST /message endpoint with the optional reply_to field to send a message as a reply to a previous message. The outgoing message is then threaded to that message in the conversation (the customer sees it quoted, just like replying in WhatsApp).

The reply_to field

FieldRequiredDescription
reply_typeyesKind of object being replied to. Use message to reply to a WhatsApp message.
reply_to_idyesThe platform message id of the message being replied to.
note

reply_to_id is the platform message id — not Zoko's message id.

For WhatsApp this is the wamid… value (the id assigned by WhatsApp), which you get from the incoming message on your webhook.

Do not pass the Zoko system message id / messageId (a UUID like 068a169a-f1fe-11ea-9b75-42010a67e00f) here — that is a different identifier and the reply will fail.

Reply to a message on WhatsApp

curl --location --request POST 'https://chat.zoko.io/v2/message' \
--header 'Content-Type: application/json' \
--header 'apikey: <apikey>' \
--data-raw '{
"channel": "whatsapp",
"recipient": "919876543210",
"type": "text",
"message": "Hi",
"reply_to": {
"reply_type": "message",
"reply_to_id": "wamid.HBgMOTE5ODc2NTQzMjEwFQIAEhgUM0EyMTc2MjEwQzc0RjNBOTdENjIA"
}
}'
import requests

url = "https://chat.zoko.io/v2/message"

payload = {
"channel": "whatsapp",
"recipient": "919876543210",
"type": "text",
"message": "Hi",
"reply_to": {
"reply_type": "message",
"reply_to_id": "wamid.HBgMOTE5ODc2NTQzMjEwFQIAEhgUM0EyMTc2MjEwQzc0RjNBOTdENjIA"
}
}
headers = {
"Content-Type": "application/json",
"apikey": "<apikey>"
}

response = requests.request("POST", url, json=payload, headers=headers)

print(response.text)
tip

reply_to works with regular message types (text, image, video, document, etc.) — just add the reply_to object to your normal send request. The recipient is still required. Template messages (template / richTemplate / buttonTemplate) do not support reply_to — the reply context is not attached, so they send un-threaded.