Skip to main content
Prelude supports 2-way messaging over WhatsApp, so your application can receive inbound messages from users and send contextual replies. Replies are delivered as native WhatsApp quoted messages, preserving conversation threading.
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 a window_expired error. Each new inbound message from the same user resets the 24-hour window.
Replies outside the conversation window will be rejected. If you need to message the user after the window has closed, use a template-based message instead via the Send a message endpoint.

Sending a reply

To reply to an inbound message, use the dedicated Reply to an inbound message endpoint:
string
required
The recipient’s phone number in E.164 format. Must match the phone number that sent the original inbound message.
string
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.
object
An image, audio file, video or document to send by link: type and url. See Replying with a file.
string
required
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: add media 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.
The link must answer with the file’s Content-Type, such as audio/ogg or application/pdf: a generic type such as application/octet-stream is refused. It must still work when the reply is sent. Use a new link for each new file: WhatsApp keeps a fetched link for 10 minutes and sends the same file again for the same link.
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 an inbound.message.received webhook event.

Webhook event

string
The unique inbound message identifier (prefixed with im_). Use this value in context.reply_to to send a reply.
string
The channel the message was received on: whatsapp.
string
The sender’s phone number in E.164 format.
string
Your WhatsApp Business phone number that received the message.
string
The kind of message: text, button, image, audio, video or document.
string
The text content of the inbound message. For an image, a video or a document, the caption the user typed, or empty.
object
Set when the user sent an image, an audio file, a video or a document. Download the file with Download an inbound file.
string
The file’s MIME type, for example image/jpeg or audio/ogg; codecs=opus.
string
The file name the user sent, for a document.
boolean
True when the audio was recorded as a voice note.
RFC3339 date string
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 has content.media:
Download the file with the message_id:
The answer is the file itself: 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.