Skip to main content

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.
Note

We highly recommend that you have a good level of knowledge of flows and Data Cloud before you work on this badge. To learn about flows, complete the Build Flows with Flow Builder trail. To learn about Data Cloud, complete the Unlock Your Data with Data Cloud trailmix.

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.

  1. From Setup, enter Flows in the Quick Find box and then click Flows.
  2. Click New Flow.
  3. Make sure Start from Scratch is selected, and click Next.
  4. Select Data Cloud-Triggered Flow and click Create.
  5. 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.

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.

  1. 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.
  2. 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.

Send the Email

Lastly, create an action that sends the email to the guest.

  1. 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!
  2. Save the flow.
    • For Flow Label, enter New Diamond Level Guest.
  3. Click Activate.

The New Diamond Level Guest flow corresponding to the preceding steps.

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.

Note

Because your Data Cloud Playground doesn’t have data in all of its objects, some of this badge’s exercises and hands-on challenges fail if you run them. Don’t worry, you don’t need to run any of the flows in these exercises or challenges to complete them! Feel free to add your own data and test the flows with that data.

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.

  1. Create a Data Cloud-Triggered flow.
  2. 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.

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.

  1. 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.
  2. 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.
  3. 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.

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.

  1. 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.
  2. 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: ContactId, Value: Contact from Get_Contact > Id
      • Field: Description, Value: CaseDescriptionTemplate
      • Field: OwnerId, Value: Group from Get_Queue > 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 as Abandoned Cart Follow-Up followed by the contact’s External Id field.
  3. Save the flow.
    • For Flow Label, enter Create Case After 3 Abandoned Carts.
  4. Click Activate.

The Create Case After 3 Abandoned Carts flow corresponding to the preceding steps.

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.

Note

To trigger a flow from other types of insights, such as streaming insights, see Data Actions in Data Cloud.

Resources

Salesforce ヘルプで Trailhead のフィードバックを共有してください。

Trailhead についての感想をお聞かせください。[Salesforce ヘルプ] サイトから新しいフィードバックフォームにいつでもアクセスできるようになりました。

詳細はこちら フィードバックの共有に進む