2-way messaging requires a connected WhatsApp Business Account (WABA). See the WhatsApp BSP guide for onboarding instructions.
How it works
1
User sends a WhatsApp message
A user sends a text message to your WhatsApp Business number.
2
Prelude receives and forwards the message
Prelude ingests the inbound message and sends a webhook event (
inbound.message.received) to your configured callback URL. The event includes the message content, sender phone number, and a message ID you can use to reply.3
You send a reply
Your application calls the Reply to an inbound message endpoint with the
to, text, and reply_to fields to send a reply within the 24-hour conversation window.4
User receives a reply
The user sees your reply as a native WhatsApp message.
Conversation window
WhatsApp enforces a 24-hour conversation window. You can only reply to an inbound message within 24 hours of when the user last messaged you. After the window expires, the API returns awindow_expired error.
Each new inbound message from the same user resets the 24-hour window.
Sending a reply
To reply to an inbound message, use the dedicated Reply to an inbound message endpoint:The recipient’s phone number in E.164 format. Must match the phone number that sent the original inbound message.
The reply message body, sent as a free-form WhatsApp text. Required without
media. With an image, a video or a document, it is the caption.An image, audio file, video or document to send by link:
type and url. See Replying with a file.The inbound message ID (prefixed with
im_) to reply to. This ID is provided in the inbound.message.received webhook event.The
to field must match the phone number that sent the original inbound message. A phone_number_mismatch error is returned otherwise.SDK examples
Replying with a file
A reply can send a file by link, in the same call: addmedia with its type and an https url, such as a public or presigned S3 link. Prelude checks the link (type, size, first bytes), and WhatsApp fetches the file when it sends the reply.
An OGG file with OPUS audio is sent as a voice note; the other audio formats arrive as an audio file.
A video must use H.264 video and AAC audio. A video in another codec is not delivered, and the reply fails.
WhatsApp templates cannot carry audio, so a voice note is always a reply within the 24-hour window. To start a conversation with one, send a template with a quick reply button: the user’s tap opens the window, and your voice note answers it.
Receiving inbound messages
To receive inbound WhatsApp messages, configure a webhook callback URL with your Customer Success Manager. When a user sends a message to your WhatsApp Business number, Prelude forwards it as aninbound.message.received webhook event.
Webhook event
The unique inbound message identifier (prefixed with
im_). Use this value in context.reply_to to send a reply.The text content of the inbound message. For an image, a video or a document, the caption the user typed, or empty.
Set when the user sent an image, an audio file, a video or a document. Download the file with Download an inbound file.
The timestamp when the 24-hour conversation window expires. Replies must be sent before this time.
Receiving files
When a user sends an image, an audio file or a voice note, a video, or a document, the event hascontent.media:
message_id:
Content-Type gives its type and Content-Disposition its file name. Send Accept: application/octet-stream, or the API answers 406. Stickers and locations are not forwarded yet.
WhatsApp keeps a user’s file for 7 days: download it within that time. Files over 4 MB cannot be downloaded through the API yet.
Error handling
The following errors are specific to 2-way messaging:Limitations
- Texts, button taps, images, audio files and voice notes, videos and documents are forwarded. Stickers and locations are not. Outbound template messages can carry media in their header. See WhatsApp Media.
- Replies are sent as free-form text, an image, an audio file, a video or a document, not as WhatsApp templates.
- On WhatsApp, 2-way messaging is only available via your connected WABA. For RCS, see RCS 2-Way Messaging.
- The conversation window is 24 hours from the latest inbound message and cannot be extended.