Trigger Flows from Data Cloud
Learning Objectives
After completing this unit, you’ll be able to:
- Create a flow that’s triggered by a change to DMO data.
- Create a flow that’s triggered by a change to a calculated insight’s results.
Record-triggered flows can be triggered by a change to Salesforce data. Likewise, Data Cloud-triggered flows can be triggered by changes in a data model object (DMO) or calculated insight object (CIO). In other words, you can trigger a flow when the data in a DMO changes, or when a calculated insight’s results change.
Trigger a Flow from a DMO Data Change
Let’s build a flow that’s triggered by changes in DMO data.
Coral Cloud Resort stores its guest loyalty program information in an external database, and streams it into Data Cloud as the External Guest Loyalty object. The hospitality team has started a new concierge program to reach out to guests when they reach the loyalty program’s new Diamond level. Create a flow that sends an email to a guest when the guest reaches the Diamond loyalty level.
- From Setup, enter
Flows
in the Quick Find box and then click Flows.
- Click New Flow.
- Make sure Start from Scratch is selected, and click Next.
- Select Data Cloud-Triggered Flow and click Create.
- In the Start element’s configuration panel:
- For Data Space, select default.
- For Object, select External_Guest_Loyalty__c_Home.
- For Trigger the Flow When, select A record is updated.
- For Condition Requirements, select All Conditions Are Met (AND).
- For Field, select Loyalty_Level_c__c.
- For Operator, select Equals.
- For Value, enter
Diamond
.
- For When to Run the Flow for Updated Records, select Only when a record is updated to meet the condition requirements.
- For Data Space, select default.
Collect Data
Create a Get Records element to get information from the guest’s Contact record. With that data, you can write the body of the email.
- Add a Get Records element.
- For Label, enter
Get Contact
.
- For API Name, enter
Get_Contact
.
- For Data Source, select Salesforce Object.
- For Object, select Contact.
- For Condition Requirements, select All Conditions Are Met (AND).
- For Field, select External_Id__c.
- For Operator, select Equals.
- For Value, select $Record > Guest_ID_c__c.
- Leave the other fields as default.
- For Label, enter
- Create a Text Template resource.
- For Resource Type, select Text Template.
- For API Name, enter
EmailBody
.
- Change the View as Rich Text setting to View as Plain Text.
- For Body, enter this text:
Congratulations {!Get_Contact.Name}, you're our newest guest to reach our esteemed Diamond level! Your dedicated concierge will contact you this week to discuss the benefits of your Diamond membership.
- Click Done.
- For Resource Type, select Text Template.
Send the Email
Lastly, create an action that sends the email to the guest.
- After the Get Contact element, add an Action element.
- In the Search field, enter
email
, then select Send Email.
- For Label, enter
Send Email to Guest
.
- For API Name, enter
Send_Email_to_Guest
.
- Enable the Body field, and select EmailBody.
- Enable the Log Email on Send field, and select True.
- Enable the Recipient ID field, and select Contact from Get Contact > Contact ID.
- Enable the Subject field, and enter
Welcome to Diamond level!
- In the Search field, enter
- Save the flow.
- For Flow Label, enter
New Diamond Level Guest
.
- For Flow Label, enter
- Click Activate.
This is obviously a very basic email and probably shouldn’t be sent to an actual customer. Use merge fields, email templates, and rich text to create more professional emails for your customers.
Trigger a Flow from a CIO Data Change
Now let’s build a flow that’s triggered by changes in a calculated insight’s results.
Coral Cloud Resort recently created an ecommerce site for guests to quickly purchase additional experiences from their rooms, but a lot of guests have been leaving selected experiences unpurchased, abandoning the shopping cart.
Because this is a growing problem, the ecommerce team keeps track of each time a guest leaves a cart abandoned for 24 hours, storing each incident in an external database. That database is available in Data Cloud as the External Abandoned Cart object.
A case should be assigned to the hospitality team when a guest does this three times within a span of two weeks, so the hospitality team can follow-up directly. You’ve already created the Number of Abandoned Carts calculated insight to track the number of times a guest abandons a cart. Now create a flow that’s triggered when the NumberOfAbandons value in that calculated insight is 3 or more.
- Create a Data Cloud-Triggered flow.
- In the Start element’s configuration panel:
- For Data Space, select default.
- For Object, select Number of Abandoned Carts.
- For Trigger the Flow When, select A record is updated.
- For Condition Requirements, select All Conditions Are Met (AND).
- For Field, select NumberOfAbandons__c.
- For Operator, select Greater Than or Equal.
- For Value, enter
3
.
- For When to Run the Flow for Updated Records, select Only when a record is updated to meet the condition requirements.
- For Data Space, select default.
Get Records
Add some Get Records elements to retrieve the guest’s Contact record, the information from their most recent Abandoned Cart record, and the ID of the Hospitality Upsells queue.
- Add a Get Records element.
- For Label, enter
Get Contact
.
- For API Name, enter
Get_Contact
.
- For Data Source, select Salesforce Object.
- For Object, select Contact.
- For Condition Requirements, select All Conditions Are Met (AND).
- For Field, select External_Id__c.
- For Operator, select Equals.
- For Value, select $Record > CartGuestID__c.
- Leave the other fields as default.
- For Label, enter
- After the Get Contact element, add another Get Records element.
- For Label, enter
Get External Abandoned Cart
.
- For API Name, enter
Get_External_Abandoned_Cart
.
- For Data Source, select Data Cloud Object.
- For Data Space, select default.
- For Object, select External_Abandoned_Cart__c_Home.
- For Condition Requirements, select All Conditions Are Met (AND).
- For Field, select Guest_ID_c__c.
- For Operator, select Equals.
- For Value, select $Record > CartGuestID__c.
- For Sort Order, select Descending.
- For Sort By, CreatedDate__c.
These Sort Records field values ensure that the flow saves the most recently created External Abandoned Cart record.
- Leave the other fields as default.
- For Label, enter
- After the Get External Abandoned Cart record, add one more Get Records element.
- For Label, enter
Get Queue
.
- For API Name, enter
Get_Queue
.
- For Data Source, select Salesforce Object.
- For Object, select Group.
Make sure you select the Group object whose API Name is “Group”, not “CollaborationGroup”.
- For Condition Requirements, select All Conditions Are Met (AND).
- For Field, select DeveloperName.
- For Operator, select Equals.
- For Value, enter
Hospitality_Upsells
.
- Leave the other fields as default.
- For Label, enter
Create a Case
The case needs important details about the most recent abandoned cart, so create a text template that collects those details. Finally, add an element that uses the info collected earlier in the flow to create a case.
- Add a text template.
- For API Name, enter
CaseDescriptionTemplate
.
- Change the View as Rich Text setting to View as Plain Text.
- For Body, enter the following text:
This guest has abandoned their add-ons shopping cart {!$Record.NumberOfAbandons__c} times in the past two weeks. Please reach out and attempt to close the sale. Most recent abandoned cart: {!Get_External_Abandoned_Cart.CreatedDate__c} - ${!Get_External_Abandoned_Cart.Cart_Value_c__c} Products in cart: {!Get_External_Abandoned_Cart.Product_List_c__c}
- Click Done.
- For API Name, enter
- After the Get Queue element, add a Create Records element.
- For Label, enter
Create Case
.
- For API Name, enter
Create_Case
.
- For How to set record field values, select Manually.
- For Object, select Case.
- Set Field Values:
- Field: Contact ID, Value: Contact from Get Contact > Contact ID
- Field: Description, Value: CaseDescriptionTemplate
- Field: Owner ID, Value: Group from Get Queue > Group ID
- Field: Priority, Value: High
- Field: Status, Value: New
- Field: Subject, Value:
Abandoned Cart Follow-Up - {!Get_Contact.External_Id__c}
This value sets the case’s subject asAbandoned Cart Follow-Up
followed by the contact’s External Id field.
- Field: Contact ID, Value: Contact from Get Contact > Contact ID
- For Label, enter
- Save the flow.
- For Flow Label, enter
Create Case After 3 Abandoned Carts
.
- For Flow Label, enter
- Click Activate.
Now when the Number of Abandoned Carts calculated insight recalculates its values, the flow runs. On the calculated insight’s page, you can click Publish Now to run the calculations, or Schedule to run the calculation at a set interval of time. You can do the same for any calculated insight in your Data Cloud installation.