Receive RCS messages
When a recipient replies to your RCS agent, or taps one of its suggested replies, SignalWire receives the message and logs it. To handle inbound messages in your own application, assign the agent to a Resource, the same way you assign a phone number for inbound SMS.
Assign the agent to a Resource
An agent can be assigned once its status is in_review, launching, or launched. A pending
agent doesn’t appear in the list, so wait until SignalWire has provisioned it for testing. Each agent
can be assigned to one Resource at a time: to move it, remove its address from the current Resource
first.
Open the Resource’s addresses
In your SignalWire Dashboard, open the Resource that should handle the messages, go to its addresses, and select Add. RCS agents can be assigned to a messaging SWML Script, a SWML Webhook used for messaging, or a Relay Application.
Removing the address from the Resource stops the agent’s inbound messages from reaching it.
Inbound messages
An inbound RCS message has kind: rcs and direction: inbound. Its from is the recipient’s phone
number and its to is your agent’s ID. Text replies arrive in the message body, and media the
recipient sends arrives as a media URL.
Your application receives text, tapped suggested replies, and media. Anything else the recipient
sends, such as a location shared in response to a request_location suggestion, isn’t delivered to
your application and doesn’t appear in your message logs.
To reply, either use the SWML reply method in the Resource’s script, or
send a message with your agent’s ID as from and the
recipient’s number as to.
Reply with SWML
When the agent is assigned to a SWML Script or SWML Webhook, the script runs for each inbound RCS
message, as it does for SMS in
Reply to incoming messages via SWML,
and its reply method answers over RCS. By default,
the reply goes to the person who sent the message, from the agent that received it.
In the script, %{message.type} is rcs, %{message.to} and %{message.agent_id} are your
agent’s ID, and %{message.from} is the sender’s phone number.
reply accepts the same shapes as for SMS (a string, an object, or an inline switch), with these
differences:
- Set
bodyfor plain text orcontentfor rich content, never both.contenttakes the same content types as the Messaging API. mediais not supported. Send media with acontentof typemediainstead.fromis optional. Set it to the ID of another RCS agent in the same Project to reply from that agent.tomust be a US phone number, like any RCS send.
When a reply can’t be queued, the script stops and the inbound message is marked failed, with the
reason in its error_code and error_message. Find it in your message logs. The
reply fails with one of these codes:
Track delivery
RCS messages move through the same states as SMS, listed in
How messaging works, and
can also reach read when the recipient opens the message. SignalWire doesn’t fall back to SMS when
an RCS message ends failed or undelivered: to reach that recipient another way, send a new message
from one of your phone numbers.
To follow a message as its state changes, set status_callback when you
send it, or status_url on a SWML reply. The
callback is the same one SMS sends, described in
Track delivery via REST.
For a rich message, its body holds your content as a JSON string.
Inbound and outbound RCS messages appear in the Dashboard under Logs → Messaging, and in
GET /api/messaging/logs, with kind: rcs.