Skip to main content

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.

  1. From Setup, in the Quick Find box, enter Next Best Action, and select Next Best Action.
  2. Click New Strategy.
    The New Strategy window showing the details to create a Next Best Action strategy
  3. Enter a name and API name for the strategy. Fatima enters the following information.
    • Name: NTO Store Strategy
    • API Name: NTO_Store_Strategy
  1. In the field Object Where Recommendations Display, select AI Visit Recommendation.
  2. Click Done.
  3. 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.
    The New Generate window showing the details to create a Generate element
  4. 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
  1. 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.
  2. 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.
  3. Click Done.
  4. Drag the Map element onto the canvas.
  5. 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
  1. 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: ObjectIDThe New Map window showing the details to create a Map element
  1. Click Done.
  2. Drag the Map element after the Generate element.
  3. Click Save.

For information on creating a sample visit recommendation strategy, see Example Visit Recommendation Strategy.

Note

If you want Einstein to provide visit recommendations for specific stores, use the Filter element.

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

Salesforce 도움말에서 Trailhead 피드백을 공유하세요.

Trailhead에 관한 여러분의 의견에 귀 기울이겠습니다. 이제 Salesforce 도움말 사이트에서 언제든지 새로운 피드백 양식을 작성할 수 있습니다.

자세히 알아보기 의견 공유하기