Send RCS Transactional Messages Through On-Demand Flow

Use API-triggered transactional messaging to send prioritized, personalized RCS messages, such as one-time passwords (OTPs) or order confirmations, from Marketing Cloud Next. By using REST API to invoke an on-demand flow, you can securely pass dynamic data at send time and deliver time-sensitive service communications exactly when they’re needed.

To send RCS messages from your application without building a flow, use Direct Send APIs. See Send RCS Transactional Messages Through Direct Send API.

Before you begin, make sure that you have:

  • Permissions to create Apex classes, CMS RCS content, flows, and external client apps
  • Ability to authenticate and invoke REST APIs
  • A data source for personalization, such as an Apex class or a data graph from Data 360
  • An RCS communication subscription. Transactional RCS messages require recipient consent to meet compliance requirements. If you manage consent in another Salesforce system or an external system, you can turn on Bypass Consent when you build the flow to skip the internal consent check. You’re still responsible for managing consent.

Using a data graph as the personalization data source can increase the latency of your requests.

How you personalize determines which fields you send in the request: Apex-class personalization uses an object that’s named after the flow’s Apex resource, such as customInput, and Unified Individual personalization uses the top-level IndividualID field. See Request Parameters.

To pass real-time personalization values into the RCS message at send time, define a data source that the flow and RCS message can reference.

In this example, an Apex class defines the input structure for personalization fields, such as first name and OTP code.

  1. From Setup, in the Quick Find box, enter Apex Classes, and then select Apex Classes.
  2. Click New.
  3. Create an Apex class that defines the input variables required for the transactional message.
  4. Save the class.

The Apex class exposes variables that are later mapped in the flow and populated through the REST API request.

Example Apex class:

Create transactional RCS content as CMS content and configure it with the correct data source.

  1. Create the RCS message:
    1. Go to Marketing App > Content.
    2. Click Add CMS Content and select RCS Message.
    3. Select the message purpose and message type.
  2. Connect the data source:
    1. For the RCS message, add a new data source and select Apex Data Provider.
    2. Choose the Apex class that you created.
  3. Design the RCS message body:
    1. Insert merge fields, such as firstName or otpCode, from the Apex Data Provider.
    2. Save and publish the message.

CMS channels represent publishing endpoints such as RCS messages. Publish transactional RCS messages before you use them in a flow.

The REST API calls the on-demand flow, which defines the send logic.

  1. Create the flow:
    1. Go to the Flow tab and click New.
    2. Select On-Demand Flow (launched by REST API).
  2. Add the Apex resource:
    1. In the Toolbox, click New Resource.
    2. Set Resource Type to Variable.
    3. Set Data Type to Apex-Defined.
    4. Select your personalization class as the Apex Class.
    5. Turn on Available for Input. Save the API Name of this resource. You use it as a field name in the REST API request body. For example, if you name this resource customInput, your request body includes a customInput field, as shown in Step 4.
  3. Add Send RCS Message as the first flow element and select the RCS Agent.
  4. Select the published transactional RCS message. If you manage consent outside of Marketing Cloud Next, you can turn on Bypass Consent here.
  5. Configure the sender.
  6. Save and activate the flow.

To invoke the flow, authenticate with OAuth, and then call the flow action endpoint.

  1. From Setup, in the Quick Find box, enter External Client App, and then select External Client App Manager.
  2. Click New External Client App.
  3. Enter a name for the app and a contact email address.
  4. Enable OAuth Settings.
  5. Enter a callback URL.
  6. Add these OAuth scopes:
    • Full access (full)
    • Manage user data via APIs (api)
  7. Save your changes.
  8. After you save the app, open Manage Consumer Details and record the consumer key and consumer secret.

Send a POST request to the flow action endpoint on your org’s My Domain host. Replace FLOW_API_NAME with the API name of your on-demand flow.

FieldRequiredDescription
TelephoneNumberRequiredThe recipient’s phone number in E.164 format.
ProcessingPriorityRequiredThe send priority. Use REAL_TIME for time-sensitive messages such as OTPs. Use NORMAL when the message isn’t urgent.
IndividualID (top level)ConditionalRequired only when you personalize using a Unified Individual. If you personalize with an Apex class, omit this field.
customInputConditionalRequired only if you set up personalization for the message. Omit it if your message has no personalization. When used, this field name isn’t fixed. It’s the API Name that you gave the Apex resource in the flow (Step 3). If you named that resource something else, use that name here instead. In this example, the resource is named customInput.

This request sends the RCS message to one recipient with Apex-class personalization.

Name the recipient number field TelephoneNumber. A different name, such as MobileNumber, isn’t recognized, and the message fails to send.

If isSuccess is false, the errors array describes why the flow didn’t run.