2-way messaging works on an RCS agent that is yours, launched for your brand. Messages sent to a shared Prelude agent are not forwarded. The agent must be a transactional, promotional or multi-use agent: an OTP agent cannot send free text, so it takes no part in 2-way messaging. Ask your Customer Success Manager to enable 2-way messaging on your agent and to register the callback URL that receives its messages.
How it works
1
User sends an RCS message
A user writes to your agent from a conversation your agent opened.
2
Prelude receives and forwards the message
Prelude stores the message and sends an
inbound.message.received webhook event to the callback URL registered for your agent. The event includes the message text, the sender’s phone number, your agent identifier, 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.4
User receives a reply
The user sees your reply as an RCS text from your agent.
Reply timing
RCS has no reply window: you can reply to an inbound message at any time, and the reply leaves from the agent that received it. Unlike WhatsApp, a reply sent more than 24 hours after the user’s latest message is not rejected.Reserved keywords
STOP, START and HELP are handled by Prelude and are not forwarded to your callback URL. A user who sent STOP is unsubscribed from your agent until they send START. A reply to an unsubscribed user is not sent: the message fails with the reasonunsubscribed.
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 plain RCS text from the agent that received the message. Required without
media.A file to send by link, with its
type (image, video, audio or document) and an https 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 an image, a video, an audio file or a PDF instead of text. Host the file at an https link that answers a GET request, such as a public or presigned S3 link, and send the link inmedia, with no text. Prelude checks the file’s type and size before it accepts the reply.
The format comes from the file’s
Content-Type, or from the link’s file extension when the server sends a generic type such as application/octet-stream.
A file reply takes no text: send the text as a reply of its own. RCS has no voice note: an audio file arrives as an audio file.
Receiving inbound messages
When a user sends a text to your agent, Prelude forwards it as aninbound.message.received webhook event to the callback URL registered for that agent.
Webhook event
The unique inbound message identifier (prefixed with
im_). Use this value in reply_to to send a reply.24 hours after the message. On RCS it is for information only: a reply sent after this time is still delivered.
Receiving files
When a user sends a photo, a video, an audio file or a voice note, or a document, the event hascontent.media, and type is image, video, audio or document:
content.media.size is the file size in bytes, when RCS gives it. A file over 4 MB cannot be downloaded through the API: check size before you call the download.
Download the file with the message_id:
Content-Type gives its type and Content-Disposition its file name. Send Accept: application/octet-stream, or the API answers 406. RCS has no caption and no voice note flag: a voice note arrives as an audio file.
RCS keeps a user’s file for a limited time, which is not the same for every network: download it soon after you receive the event.
Error handling
The following errors are specific to 2-way messaging:Limitations
- Texts and files are forwarded. A location a user shares is not.
- Replies are sent as plain RCS texts or files, not as rich cards.
- 2-way messaging is only available on your own RCS agent, not on shared Prelude agents, and not on OTP agents.