Skip to main content
POST
Send a WhatsApp reply
Your own app can answer a WhatsApp number in place of the AI or your team. Botcadence posts each customer message and each delivery status to your app’s webhook, and your app replies with this endpoint while the customer’s 24-hour window is open. Outside that window, send an approved template with Send a WhatsApp template.

Setup

  1. In Channels, open the WhatsApp channel. Under Webhooks, add your app’s public HTTPS address (up to 2,048 characters) and a signing secret (up to 256), pick the events, and save. Spaces around both are trimmed. You can add up to 5 webhooks.
  2. To stop the AI and your team from answering, set Default reply mode to Your app replies. This mode needs a webhook that takes message.received. In this mode Botcadence does not read images with AI and does not bill them as media; your app gets the signed image link. Webhooks also work with any other reply mode; they only notify.
  3. Create a project API key with the whatsapp:create scope.

Events

message.received

Each customer message is posted as JSON:
  • occurred_at is when the customer sent the message, as WhatsApp reports it.
  • conversation.id is the chat; pass it as conversation_id when you reply.
  • message.type is text, image, video, audio or document. Each message.media item has type, urls, title and content_type. The links are signed and expire, so download them when the post arrives.
  • button_payload is set when the customer taps a template quick-reply button. It is the payload Meta sends for that button: Meta’s default unless an automation maps the button’s payload to a variable (for example button_payload_0) in its template settings.
  • button_id is set when the customer taps a reply button or picks a list row; for the reply buttons this API sends, it is the button title.
  • sender is the customer’s WhatsApp number, without +.

message.status

Each delivery status Meta reports for a message sent from the number, including your app’s replies:
  • status is sent, delivered, read or failed; error explains a failure.
  • message.id is the inbox message: agent, AI and API replies, and templates sent from the inbox. For your replies it is the message_id this API returns. It is null for messages that are not in the inbox (broadcasts, automation templates, and messages sent from the WhatsApp Business app); match those on provider_message_id.
  • A reply with an image and text goes out as two WhatsApp messages, so each part gets its own statuses: same message.id, different provider_message_id.

Delivery

Answer with any 2xx status within 15 seconds. A 5xx, a 429, a timeout, a network error or a failed DNS lookup is retried with the same event_id, also sent as the Idempotency-Key header, so ignore an event_id you have already handled. Retries back off, waiting up to 50 minutes between tries, for about 2 hours in total. Other statuses are not retried. Redirects are not followed, and a 3xx is not retried. An address that resolves to a private network is refused and not retried. Events can arrive out of order, so order them by occurred_at. When a delivery gives up, the webhook in the channel settings shows Last delivery failed with the time and the error.

Verify the signature

Each post carries X-Botcadence-Timestamp (Unix seconds) and X-Botcadence-Signature: sha256=<hex>. The signature is the HMAC-SHA256, keyed with your signing secret, of the timestamp, a ., and the raw request body:
Refuse a post whose signature does not match or whose timestamp is more than a few minutes old.

Authentication

Send the project API key as a Bearer token. See API authentication.
Required scope: whatsapp:create

Request body

string
required
The customer’s number in international format, for example +14155552671. It must have a live WhatsApp chat in the project.
string
The chat to reply in: conversation.id from the message.received event. It must be a live WhatsApp chat in this project with the to number. Without it, the reply goes to the latest live chat with that number.
string
Up to 4,096 characters. Required unless image_url is set, and always required with quick_replies, as 1 to 1,024 characters.
string
A public HTTPS image address. The image is sent first, then the text.
string[]
Up to three different button titles of 1 to 20 characters after trimming spaces, sent as reply buttons on the text. A tap arrives as an inbound message with button_id set to the title.

Example

Response

The reply shows in the conversation in your inbox.

Idempotent retries

Send an Idempotency-Key header (1 to 255 characters) to retry safely. A repeated key with the same body returns the first response without sending again.
  • A failure before the reply is stored frees the key for another try.
  • A failure after the reply is stored keeps the key as outcome_unknown, because the reply may have reached the customer. A replay with that key answers 409; check the conversation before you send again with a new key.

Errors