Add the #DF24 Developer Keynote to your agenda. Join us in-person on 9/18 at 2:30 p.m. PT or on Salesforce+ at 5 p.m. PT for the must-see session built just for developers.

Salesforce Data Cloud gives developers the ability to make predictions based on historical data. With Einstein Studio, you can create your own predictive AI models and bring in predictions from models in hyperscalers, such as Amazon SageMaker, Google Vertex AI, and Databricks. Data Cloud also provides easy ways to utilize the model outputs using tools already familiar to Salesforce administrators and developers.

This blog post describes the steps needed to use the output of the model to drive your business processes in Salesforce Flow.

Determining the use case

In a previous post, we created a predictive model for animal adoption. This model created a score that indicates the likelihood of adoption based on key variables like an animal’s age and breed.

In this post, we want to get the predictive score for animal records created or updated in Salesforce. If the predictive model indicates that the animal has a low chance of adoption, we want to proactively create a Slack post for a rescue center team to follow up.

Increasing the chance of adoption is a team effort. By sending a message to a specific Slack channel, multiple team members can look holistically at why the animal may be an adoption risk and take action.

Building the data model

In Salesforce, a custom object has been created to store a list of animals. This replicates how a rescue center might manage its current intake of animals.

The configuration of the Animal__c custom object in Salesforce

We have created one additional field here called Adoption_Score__c using the data type number as a placeholder that we can use later to store the output of the prediction.

Using the object created, existing animal records can then be imported.

A list of animals using sample data

Creating a record triggered flow

Since getting the prediction from our existing model depends on an animal record being created or updated, we’ll create a record-triggered flow.

Open Setup in Salesforce and click Flows. Then click New Flow.

How to create a flow

In the dialog that opens, select Start from Scratch, then click Next. Then select Record-Triggered Flow and click Create.

Selecting the flow type

Set the conditional requirements to trigger when any of the key animal attributes are changed.

Setting the entry conditions in Flow Builder

Finally, optimize the flow for Actions and Related Records and set the check box to add an asynchronous path.

Optimizing the flow and setting an asynchronous path

Getting a prediction from your AI model

In the asynchronous path, add an Action element. Then select Data Cloud in the actions panel.

Selecting the Data Cloud Action folder

Here, you’ll see all the actions available for Data Cloud. If you followed the previous post, you’ll see an AI action called Predicted Animal Adoption. Click the option to populate the Action element.

Selecting the Data Cloud AI model action

Next, populate the label, API name, and description.

Setting the attributes of the Data Cloud action

The AI prediction already knows the inputs needed for the model to provide an output. We just need to populate each input with a variable. In our case, we can use the triggering animal record values.

Specifying the input values for the AI model

Driving decisions based on the output from an AI prediction

We can drive the process flow based on the output of the AI prediction. In this case, we want to take action if the chance of adoption falls below 50%. This will allow internal teams to provide extra attention to a new animal intake to ensure that they maximize its chance of adoption.

Next, add a Decision element to the Flow canvas and add a label, API name, and description.

Setting the attributes of the decision element

In the decision outcome section under New Outcome, set the label to Yes and set a condition as shown in the image below.

Setting the Yes/No outcomes of the decision element

The resource is set to the value Outputs From Get Likelihood of Adoption > Prediction, which will look for predicted adoption rates of less than 50%.

For the default outcome, change the label to No.

Add actionable insights using formulas

The predictive model in the previous post indicated the top predictors or variables that might cause the biggest impact on animal adoption. This included the number of photos of the animal. To make the Slack post as helpful as possible, a formula can be used to look at the current number of photos used for the AI prediction. If it’s less than three, for example, we can indicate to the team receiving the Slack message that adding more photos might be an easy initial course of action (since we know from the AI model that more photos increase the chance of adoption).

Create a new resource of type Formula with the following values.

Include a text string to use in Slack if the number of photos is less than three.

Creating a new resource to drive actionable insights

Surface insights for collaboration

In this post, we’re using Slack to surface key insights. To set up Salesforce for Slack integrations, you can follow the documentation. This is a prerequisite to being able to use Slack actions in Flow Builder.

Create a new action in the Yes branch of the decision and select Slack in the action panel.

Selecting the Slack action folder

Next, select the Send Slack Message action.

Selecting the Slack message action

Here, we’ve populated the action with the required parameters.

Setting the Send Slack Message attributes

To format a message to send to the channel, we can use Slack markdown. To dynamically inject properties of the animal that triggered the flow, set up a formula. When entering the value for Slack Message, use a New Resource of type Text Template and specify the following markdown. Name the resource Animal at Risk Message.

Test the output

Save the flow and activate it. We can now test the flow by updating or creating a new animal record. To trigger the flow, we need an animal record with a low chance of adoption.

When we created a record using a high age and no photos, it triggered the Slack message. Note that it not only includes the details of the animal and the predicted adoption score, but also includes the suggested action to include more photos of the animal.

The final Slack output when an animal is at risk

Conclusion

Surfacing key insights to teams is key to driving value from your investments in AI. Data Cloud makes it easy to use your AI models in Flow Builder to drive actionable outcomes.

In this blog post, we used a predictive model that predicts the likelihood of animal adoption. This allowed us to identify those animals at risk of lengthy stays in a rescue center and create actionable escalations using Slack.

We also used the insights from the predictive model in Data Cloud to start driving suggested actions that can increase an animal’s chance of adoption to immediately improve their chance of finding their furever home.

Resources

About the author

Dave Norris is a Developer Advocate at Salesforce. He’s passionate about making technical subjects broadly accessible to a diverse audience. Dave has been with Salesforce for over a decade, has over 35 Salesforce and MuleSoft certifications, and became a Salesforce Certified Technical Architect in 2013.

Get the latest Salesforce Developer blog posts and podcast episodes via Slack or RSS.

Add to Slack Subscribe to RSS