Set Up Visit Recommendations Using Next Best Action Strategy and Apex
Learning Objectives
After completing this unit, you’ll be able to:
- Set up a Next Best Action strategy by adding rules.
- Set up visit recommendations by using Apex.
Set Up a Next Best Action Strategy by Adding Rules
Fatima has set up a flow strategy. Let’s find out how she sets up an NBA strategy.
An NBA strategy can either be based on rules or AI. The reason behind the recommendation, as provided by Einstein, can be configured in the NBA strategy.
Einstein NBA strategies combine insights and business rules to create a stream of recommended actions for users. And sales managers can select the NBA strategy that best fits their business requirements, such as upselling a product, replenishing an out-of-stock product, or running a promotional campaign.
Here’s how Fatima configures an NBA strategy based on rules.
- From Setup, in the Quick Find box, enter
Next Best Action
, and select Next Best Action.
- Click New Strategy.
- Enter a name and API name for the strategy. Fatima enters the following information.
- Name:
NTO Store Strategy
- API Name:
NTO_Store_Strategy
- In the field Object Where Recommendations Display, select AI Visit Recommendation.
- Click Done.
- On the Next Best Action - Strategy Builder screen, drag the Generate element onto the canvas. We recommend you use the Generate element to load the data because it helps to avert the per-transaction limits.
- Enter a label and API name for the element. Fatima enters the following information.
- Label:
Generate Store Records for NTO
- API Name:
Generate_Store_Records_for_NTO
- In the Apex Action field, select an Apex action that generates the list of stores relevant to the strategy. Fatima selects Last Visit earlier than 30 days, which returns the list of stores that have not been visited for more than 30 days. For information on how to create the Apex action, see Recommend Visits Using Apex.
- In the Argument field, enter an argument value based on the selected Apex action. Fatima selects
30.09.2021
as the target date. She wants to generate records for stores that have not been visited for more than 30 days prior to this date.
- Click Done.
- Drag the Map element onto the canvas.
- Enter a label and API name for the element. Fatima enters the following information.
- Label:
Map NTO Store Records for Recommendations
- API Name:
Map_NTO_Store_Records_for_Recommendations
- In the Map Values to Fields section, enter the following values. Select the Type as Text for all the values.
- ActionReference:
NTO Store Flow
- StoreID:
ID
- Description:
Recommendations for NTO Store Visits
- Reasons:
High priority stores not visited for more than three months
- PredictionApiNames:
NTO Store Prediction
- TargetRecordID:
ObjectID
- Click Done.
- Drag the Map element after the Generate element.
- Click Save.
For information on creating a sample visit recommendation strategy, see Example Visit Recommendation Strategy.
Having set up the NBA strategy, Fatima creates a basic flow to run the strategy. You can use a flow to run multiple strategies.
An administrator can also define complex flows that run the strategy and automate the business process.
Set Up Visit Recommendations Using Apex
Apex code is usually required for visit recommendations that are too complex to implement using regular flows. Fatima gets in touch with a developer at Alpine Group to set up visit recommendations with Apex. Here’s an overview of how they do it.
They create a flow and add the Apex Class as an Action element. For more information, see Set Up Einstein Visit Recommendations Using Apex.
To use the Apex action in the flow, the developer annotates the appropriate method with @InvocableMethod. With the invocable action, they can scale the recommendation generation as per the business requirement.
Fatima filters the stores using the Apex class and gets visit recommendations accordingly. For more information on using an Apex class for filtering stores, see Recommend Visits for Specific Stores.
Now that Fatima has set up rules-based visit recommendations for Gustavo, it’s time for her to set up rules-based task recommendations. Let’s see how she does this in the next unit.
Resources