Skip to main content
Join the Agentforce Hackathon on Nov. 18-19 to compete for a $20,000 Grand Prize. Sign up now. Terms apply.

Set Up Visit Task Recommendations

Learning Objectives

After completing this unit, you’ll be able to:

  • Create a recommended flow of tasks for retail stores.
  • Set up visit task recommendations using Apex.

Create a Flow of Tasks for Retail Stores

During a store visit, Chantelle must complete tasks such as the following:

  • Ensure on-shelf availability and product price compliance.
  • Record inventory and presentation details.
  • Check product placement, branding, and expiration dates.
  • Interact with the store manager to capture feedback and complete surveys.
  • Track business mileage and expenses.

A field rep interacting with the store manager during a store visit

Fatima has set up Einstein Visit Recommendations to recommend store visits for Gustavo and his field reps. She now sets up visit task recommendations, which will help Gustavo identify the right tasks for field reps on his team, and the order in which they must be performed. 

The rules for setting up task recommendations can be based on an assessment task or a retail visit KPI (RVKPI).

To get rules-based task recommendations, Fatima can either create a flow or write an Apex class and add it to a flow. We’ll cover both the approaches.

Here’s how she creates a flow.

  1. From Setup, in the Quick Find box, enter Flows, and then select Flows.
  2. Click New Flow.
  3. Make sure Start from Scratch is selected, and click Next.
  4. Select Screen Flow, and click Create.
  5. Select either Freeform or Auto-Layout. Fatima selects Freeform.
  6. Design your flow according to your task recommendation strategy. From the Elements tab, drag the Screen element onto the canvas.
  7. In the Screen Properties section, enter the label and API name for the screen element. Fatima enters the following information.
    • Label: NTO Store Task
    • API Name: NTO_Store_Task
  1. Click Done.
  2. Connect the Start and Screen elements.
  3. Click Save.
  4. Enter the flow’s label and API name. Fatima enters the following information.
    • Flow Label: NTO Store Task Flow
    • Flow API Name: NTO_Store_Task_Flow
  1. Click Save.
  2. Click Activate.

To use flows for task recommendations, ensure that the name of your input and output variables match one of these strings when you create the flow.

  • Input variables
    • TargetIds: Stores the visits or visit recommendations for which task recommendations are requested.
  • Output variables
    • RecommendedTargetIDs: Stores the visits or visit recommendations for which there are task recommendations.
    • TemplateRecordIDs: Stores the retail visit KPIs or assessment tasks for task recommendations.
    • TaskRecommendationReasons: Stores the reasons for task recommendations.
    • ParentTaskIDs: Stores the assessment tasks for KPI-based task recommendations. For non-KPI based task recommendations, the value is null.

For information on a sample task recommendation flow, see Understand the Sample Task Recommendation Flow. The sample task recommendation flow demonstrates how you can boost your business with task recommendations. With the sample flow shipped out-of-the-box, you can test task recommendations for a single visit or recommendation.

Set Up Visit Task Recommendations Using Apex

Fatima teams up with the developer again to set up visit task 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. They activate the flow and then create an Apex class to select a list of visits or visit recommendations that Einstein must provide task recommendations for. For more information, see Set Up Einstein Visit Task 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.

For information on using an Apex class for filtering visit recommendations to get task recommendations, see Recommend Tasks Using Apex.

What’s Next?

Fatima has created rules-based visit and task recommendations for Gustavo and his team. Richard, the data science partner, informs her that she can also set up visit recommendations using an AI model. 

In the next unit, let’s join Fatima and Richard as they explore AI model-based visit recommendations.

Resources

Share your Trailhead feedback over on Salesforce Help.

We'd love to hear about your experience with Trailhead - you can now access the new feedback form anytime from the Salesforce Help site.

Learn More Continue to Share Feedback