Salesforce | Trigger Send Bulk SMS by Template Apex Action via Marketing Cloud Journey
You can trigger the Send Bulk SMS by Template Apex Action via Marketing Cloud Journey. Although the Journey Builder triggers the Flow one person at a time, Salesforce’s Flow engine automatically bulkifies the requests. If 100 people enter the journey step simultaneously, Salesforce will group them and call your MercuryBulkSMSAction.cls once with a list of 100 FlowInput records - ensuring you don’t hit governor limits.
Trigger Send Bulk SMS by Template Apex Action
As MercuryBulkSMSAction expects a List of Record IDs, your Flow needs to handle the conversion from the single Record ID (passed by Journey Builder) to a List. To do this:
- Create a New Flow and select Autolaunched Flow (No Trigger).
- Create Variables:
- recordID (Text, Available for input): Receives the Contact/Lead ID from Marketing Cloud.
- templateID (Text, Available for input): Receives the SMS Template ID.
- recordIDCollection (Text, Allow multiple values/Collection): To satisfy the Apex input requirement.
- Add Assignment element by adding recordID to recordIDCollection.
- Add Action element by searching for Send Bulk SMS by Template (the label for MercuryBulkSMSAction).
- Set Input values:
- Record IDs: {!recordIDCollection}
- SMS Template ID: {!templateId}
- Save and Activate the Flow.
In Marketing Cloud, you’ll also need to configure Journey Builder. To do this:
- Open your journey in Journey Builder.
- Drag the Salesforce Flow activity onto the canvas - this requires the Marketing Cloud Connect integration.
- Select the Flow you just created.
- Map the variables:
- Map the Salesforce Contact/Lead ID to the recordID flow variable.
- Pass the specific SMS Template ID string to the templateId flow variable.