Send RCS Transactional Messages Through On-Demand Flow

Use API-triggered transactional messaging to send prioritized, personalized 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.

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. However, if your compliance requirements allow sending without consent, turn on Bypass Consent when you build the flow.

Note: 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 the dynamicfields object, 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, use the Quick Find box to find and 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 (for example, 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.
  5. Configure the sender and activate the Flow.
  6. Save and activate the Flow.

To invoke the Flow, you must authenticate using OAuth and then call the Flow action endpoint.

  1. From Setup, use the Quick Find box to search and 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.
FieldRequiredDescription
TelephoneNumberRequiredThe recipient’s phone number in E.164 format. TelephoneNumber is the only accepted name for this field. Variants such as MobileNumber cause the send to fail.
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 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.

Important: The recipient number field must be named TelephoneNumber. A different name, such as MobileNumber, isn’t recognized, and the message fails to send.