Display a Prediction on a Record with a Screen Flow
Learning Objectives
After completing this unit, you’ll be able to:
- Create a screen flow that displays a prediction on a record page.
- View predictions and recommendations on a record page.
In this unit, you create a screen flow to run the lead conversion prediction, process it with the prompt template, and display the prediction on a lead record. Then, you create a new lead and run the flow on the new lead. And, you view predictions and recommendations on the record.
Create a Screen Flow
Screen flows are flows in Flow Builder that you can use to add information to a screen. For the lead conversion example, the information is the predicted conversion and recommendations and the screen is a lead record. Learn more about Screen Flows and Flow Builder.
Link Record ID to Your Flow
Continue to use the special developer org you've been using for previous units as you follow along with the steps outlined below.
- From the App Launcher, search for and select Flows.
- Click New to open Flow Builder.
- Click Screen, then click Screen Flow.
- Click
to open the Toolbox.
- Create a variable that stores the record ID.
- Click New Resource.
- For the Resource Type, select Variable.
- Name the resource:
recordId
. Leave the description blank.
- For the Data Type, select Text.
- Leave the default value blank.
- Select Available for input.
- Click Done.
- Click New Resource.
- Add a Get Records element that pulls lead records into the flow.
- Click the + icon in the Canvas.
- Search for and select Get Records.
- Name the element:
Get Lead Data.
- Make sure the API name is
Get_Lead_Data.
Leave the description blank.
- Make sure the Data Source field is Salesforce Object.
- For the Object, search for and select Lead.
- Under Filter Lead Records, leave ‘All Conditions Are Met (AND)’ in the Condition Requirements.
- Search for and select Lead ID as the field, Equals as the operator, and recordId as the value.
- Leave the default values in sort order and record storing.
- Click the + icon in the Canvas.
Now your flow can find the corresponding lead given a record ID. Next, bring in your predictive model.
Add Predictive Model to the Flow
- Add an Action element that pulls your predictive model into the flow.
- Click the + icon in the Canvas below Get Lead Data.
- Search for and select the Predicted Conversion action.
- Name the element:
Predict Conversion
.
- Make sure the API name is
Predict_Conversion
. Leave the description blank.
- Map each field to the corresponding field in the Lead from Get Lead Data.
- Click Lead from Get Lead Data.
- Search for and select the corresponding field. For example, select Annual Revenue for Annual Revenue. Repeat for each field.
- Click Lead from Get Lead Data.
- Turn on recommendations. Enter
3
for the number of recommendations.
- Turn on top predictors. Enter
3
for the number of top predictors.
- Click the + icon in the Canvas below Get Lead Data.
- Create a text template that stores the top recommendations from the model output.
- Under Toolbox, click New Resource.
- For the Resource Type, select Text Template.
- In the API Name field, name the resource:
JSONRecommendations
. Leave the description blank.
- Click the View as Rich Text dropdown and select View as Plain Text.
- Enter
{!Predict_Conversion.prescriptions}
in the Body.
- Click Done.
- Under Toolbox, click New Resource.
- Create a text template that stores the top predictors from the model output.
- Under Toolbox, click New Resource.
- For the Resource Type, select Text Template.
- In the API Name field, name the resource:
JSONPredictors
. Leave the description blank.
- Click the View as Rich Text dropdown and select View as Plain Text.
- Enter
{!Predict_Conversion.factors}
in the Body.
- Click Done.
- Under Toolbox, click New Resource.
Now your flow can input the lead into your predictive model and get the predicted conversion. Then, you stored the recommendations and predictors in text templates. Next, bring in your prompt template.
Add an Action Element That Pulls Your Prompt Template into the Flow
- Click the + icon in the Canvas below Predict Conversion.
- Search for and select the Explain Conversion and Give Recommendations action.
- Name the element:
Explain Conversion and Give Recommendations.
- Make sure the API name is
Explain_Conversion_and_Give_Recommendations
. Leave the description blank.
- For the Predicted Outcome, select Outputs from Predict Conversion, then click Prediction.
- For the Top Predictors, select JSONPredictors.
- For the Top Recommendations, select JSONRecommendations.
Display the Prediction on the Record Page
- Add a Screen element.
- Click the + icon in the Canvas below Explain Conversion and Give Recommendations.
- Search for and select Screen.
- Name the element:
Show Prediction
.
- Make sure the API name is
Show_Prediction
. Leave the description blank.
- In the Components tab on the left side of the screen, search for and select Display Text.
- In the API Name field, name the component:
Output_From_Prompt
.
- In the “Insert a resource…” field, click Outputs from Explain_Conversion_and_Give_Recommendations, then click promptResponse.
- Click Done.
- In the API Name field, name the component:
- Click the + icon in the Canvas below Explain Conversion and Give Recommendations.
- Click Save.
- Name the flow:
Lead Conversion Predictions and Recommendations
.
- Make sure the API name is
Lead_Conversion_Predictions_and_Recommendations
. Leave the description blank.
- Click Save.
- Click Activate.
Create a New Lead
Create a new lead to run the prediction on.
- From the App Launcher, search for and select Leads.
- Click New.
- Enter
Mary
in the First Name field.
- Enter
Lou
in the Last Name field.
- Enter
Mathtouch
in the Company field.
- Enter
Manager
in the Title field.
- For the Lead Source, select Web.
- For the Industry, select Agriculture.
- Enter
100000
in the Annual Revenue field.
- For the Positioned Product, select GC3000 Series.
- Enter
5
in the Discount Offered field.
- For the Lead Status, select Working - Contacted.
- For the No. of Employees, enter
100
.
- Click Save.
Add Flow to Lead Record Page
Add the flow to the lead record page in the Lightning App Builder. This will run the flow on every lead and display the prediction on each record page.
- Make sure you’re on Mary Lou’s record page.
- Click the gear icon, then click Edit Page. This opens the lead record page in the Lightning App Builder.
- From the Components tab, search for
Flow
. Drag the Flow component to the Related tab on the right side of the page. Make sure the Flow component is the first item in the Related tab.
- In the Flow field, search for and select Lead Conversion Predictions and Recommendations.
- Check the box for Pass record ID into this variable.
- Click Save.
- In the window, click Activate.
- Click Assign as Org Default.
- Leave Desktop selected and click Next.
- Click Save.
- Click the back button to exit the Lightning App Builder and go back to Mary’s record page. You should see the prediction on the right side of the screen.
Well done! Now predictions from your model are available on every lead record.
View Mary’s Prediction and Recommendations
Take a look at Mary’s prediction and recommendations. Your prediction might look slightly different.
Predictive Score (1)
- Mary has a 41.578% likelihood to convert.
Top Predictors (2)
- Mary’s top predictors are her lead source, discount, and title.
Recommendations (3)
- Your sales agent can adjust Mary’s discount to improve her conversion score.
Your sales agents can quickly see which leads are likely to convert, as well as get recommendations for how to maximize lead conversion directly on a record page.
Wrap Up
Predictive models in Model Builder provide more than just a prediction. They teach you how to adjust your course to get the best outcome. In this module, you learned how to turn your predictions into tangible results. You built a model that predicted lead conversion, processed the output with Prompt Builder, and displayed it on lead record pages with a screen flow. By providing actionable predictions to your sales agents, they can now adjust their strategies to improve conversion for every lead. You’ll see higher conversion rates, increased efficiency from your sales agents, and increased revenue. Now, it’s time for you to build and act on your predictive outputs from Model Builder to reap all the benefits!
Click the Check Challenge below to earn 500 Points button and complete this badge.