Tips and Tricks for Generating Recommendations from Accounts and Other SObjects

Suppose you want to recommend Accounts using Einstein NBA. You can build a list of Accounts and filter it, and then map the accounts to the recommendation format that the NBA Recommendation component understands. Users can then click to Accept or Reject those recommendations. Suppose you then want to generate a report to determine which Account recommendations were most frequently approved. Is this possible?

You can Load regular records (Account, Contact) into Strategy Builder but you must map them to recommendations

Consider the strategy below:

The Inspector shows that two accounts are being output from the strategy. Yet when we point a Next Best Action component at this strategy, we don’t see them:

The problem here is that the NBA component expects to receive data structured as Recommendation objects, not Account objects. So you need to generate corresponding recommendations with the Map element:

Let’s configure Map as follows:

We’re able to save and the Inspector shows two recommendations being output, but still nothing shows up:

To isolate the issue, I’m going to add some ‘plain’ recommendations to the strategy and see if those succesfully come through. You can see here that the strategy is output two recommendations generated from accounts and a bunch of ‘plain’ recommendations

When we look at the page, we see the plain recommendations but not the account-derived recommendations. That tells us something’s wrong with our mapping:

Now, next I’m going to use a useful little trick to further isolate the issue. Note that in the above image, Maximum Recommedations Displayed is set to 4. Watch what happens when I change it to 3:

Before continuing, you might want to take a moment and try to figure out what this tells us….

….well, the fact that only 1 of the plain recommendations shows when Maximum Recommendations Displayed is reduced to 3 suggests strongly that our 2 Account-derived Recommendations are successfully be delivered to the Next Best Action component, but it’s somehow failing to render them properly.

It turns out that the component is pretty finnicky about the fields of data that are provided to it. When you derive recommendations by mapping from SObjects, you really need to make sure all the fields that are required are properly there. (Of course, the right thing to do would be to provide some user-friendly validation, but so far Salesforce hasn’t been able to resource that).

Among the required fields: you MUST have an ActionReference that has as its value the literal name of an activated Screen Flow.

Note how the ActionReference shows up in Map with the label ‘Action’:

Once we have this, our Account-derived recommendations show up:

Note that, counter to usual practice, Description is a required field because it forms the core of the recommendation body. Not providing a Description as part of your Mapping will lead to strange unexpected behavior.

When you generate a report of recommendation reactions, the account-derived recommendations show up among the plain recommendations, and the Account Id is available in the report’s Recommendation Source Id field:

More information on Mapping

NBA Home

Solution: Extending ‘Limit Reoffers’ Capability

This request came in:

I have a customer trying to implement limiting re-offers, but wants to have differing time periods based on whether a user accepts or rejects the offer.  Specifically, a recommendation should appear after 6 months if the recommendation is rejected, and 4 months if the offer is accepted. 

This canbe done with two branches and a Limit Reoffers on each branch. A third branch would be used to represent recommendations that have neither been approved or rejected. All three branches would initially load the same set of recommendations.

Later in the strategy, you would use a Branch Select to decide which branch to allow through.

On each branch, your goal would be to filter the original set down. One branch would want to filter it to Only the Recs That This User Most Recently Rejected. The second branch would want to filter to Only the Recs That This User Most Recently Accepted. The third branch would be Only the Recs That Have Neither Been Approved or Rejected By This User.

Since the built-in Limit Reoffers doesn’t support the variability this customer needs, they would have to store their own information on User Accepts or Rejects so the filters have something to work with.

In order to do that, you’d need to store records that reflect whether a particular recommendation was accepted or rejected by a particular user. You’d create a custom object called something like ‘RecommendationUserResponse’. In the downstream flows, you’d create or update a RecommendationUserResponse record. It would have three fields: a Recommendation Id, a User Id, and a Response value of either ‘Accepted’ or ‘Rejected’.

To apply the filter logic, you would use the Enhance element and an invocable action. The Enhance element would call the action. The action would iterate through the provide recommendations and query for RecommendationUserResponses with a matching Recommendation Id and User Id. It would then use the Response field to determine whether to filter each recommendation out.

How to Only Expose The NBA Component to Users with Unlimited Requests

Suppose you want to display recommendations only for users that are licensed to make unlimited requests. You can do that in App Builder:

Here, we make use of the Standard Permission ‘User Has Unlimited Next Best Action Strategy Executions’:

Sales Use Case Examples for Next Best Action

These are good examples of how you can use Next Best Action to empower sales teams!

Advanced NBA: Using Apex Actions to Empower Team Manager to Set Team Priorities via Next Best Action Recommendations

Building a Scheduled Alert Generator with Next Best Action and Flow

Creating NBA Recommendations from Salesforce Records

Sometimes you want to generate recommendations from records. For example, you might want to recommend a set of Accounts that should be worked on, or a set of Leads that should be processed. You can load records of any type using the Load Element. Here, for example, a set of Asset records are loaded in:

If this isn’t the exact set you want to recommend, you can proceed to use the Filter and Sort elements to filter down the initial load.

Once you have the final set of records, you need to convert them to Recommendations. This is necessary because of the expectations of the consumers of your strategy. The consumer is usually the out-of-the-box Next Best Action component:

…but may also be a REST or Apex query.

All of these downstream consumers expect recommendation data structures with the following key fields:

  • a Name
  • an Accept Label
  • a Reject Label
  • an ActionReference, which should be the name of the flow that should be run when the user selects Accept or Reject
  • a Description

Note that the only required fields are ActionReference and Description. The Description field, which is not normally a required field in Salesforce, is shown above in the image as ‘0% Refinancing….’. The recommendation in the image above doesn’t actually have a Name showing but it needs that Description.

It’s also essential that the flow you point you be a Screen Flow and be Active.

Using the Map Element to Convert Records into Recommendations

You have to use the Map element to assemble recommendation objects that correspond to the records that your want to recommend. Let’s look at that. In our example above, we use Load Element to load Asset records. They do not have fields like AcceptLabel or ActionReference. They do, however, have a Name field and a Description field, like most Salesforce object types.

Here’s an example of an Asset record with a Name and a Description:

Note that this org has 5 different products with the AssetName ‘DellGrey’ but only the one above has a Description.

Let’s build a minimal Map element:

Things to note:

  1. the name of the flow is in quotes. Anything that’s not in quotes is assumed to be a field.
  2. the meaning of the second mapping is: for each record being passed into this Map element, take the value of its Description field and copy that into the Description field of a corresponding Recommendation.
  3. If a source field is empty, the record will be filtered out by the Map element.

That means that, because only one of the 5 assets loaded by the Load element has a Description value, we expect to see only a single recommendation generated by the Map element when we click the Test button, and that’s what indeed happens:

At this point you might reasonably say ‘why the hell did Opportunity just show up’? The simple reason is that I didn’t build this demo and am too lazy to clean it up. A more useful explanation: All NBA strategies must run against a context record. Think of this as often being the record page where the recommendations will show up. This particular strategy uses Opportunity as a context record, and in order to run Test Strategy, we need to provide an actual opportunity. If you go up to the Load Records example at the top of the page, you’ll see that the Load criteria ignore the Opportunity ID. This is therefore not very realistic. More likely, a real strategy would either incorporate the id of the context record into that initial query or be used in a Filter element or Branch Select element.

Why does the Accept button say “DellGrey”. That’s a bug that we can work around by adding a static value to our Mapping:

…which leads to:

You can use formulas to modify field data as part of the mapping and can incorporate fields from the context records. For more information see:

How To: Use the Map Element in the Strategy Builder

Pilot other considerations and requirements: Einstein Next Best Action on Flow(Blog 3 of 4 series)

If you haven’t already, check out these blogs for an Overview of the pilot and a detailed tutorial!

How do I get access to this pilot feature?

PILOT REQUIREMENT:

General Requirements

  • Reach out to your AE to get nominated for the pilot, we will turn on the pilot perm on your Sandbox and you are ready to roll!
  • Feature is available in Essentials, Professional, Enterprise, Performance, Unlimited, and Developer Editions. 

OTHER CONSIDERATIONS FOR PILOT

  1. Accessing Recommendation fields in the invoked flow 

Create an optional input variable named inputRecommendation in the invoked flow of data type ‘Record’ and Object type ‘Recommendation’ and mark it as Available for input as shown. 

Now this variable holds details of the selected recommendations on the invoked flow that the admin can choose to display a more descriptive text on the screenflow invoked or save for custom reporting purposes. Example below where the category field(custom field) of the inputRecommendation is referenced in the invoked screenflow.

  1. Automatic Variables

When you open the new recommendation strategy process type, 2 variables will be automatically created in the Manager tab under resources . 

1.recordId: This is the variable that will have the value of the contextRecordId. (This is only pilot experience. In beta and beyond, this will be upgraded to support $Record variable that will hold context record

2. outputRecommendations: This is the collection variable that the user has to assign the final recommendation collection to so that the runtime component can display these recommendations (In beta and beyond an output/end node will automatically have access to the final recommendations but the admin will still have the ability to reassign it) 

  1. Versioning/ Activate or Deactivate a Recommendation Strategy: Versioning is a new platform capability that will be available to NBA users on this pilot. You can have multiple versions of a recommendation strategy, but only one version of each flow can be active at a time. You can activate or deactivate a flow right in Flow Builder or from the flow’s detail page in Setup.
  1. Perms:
To create or manage recommendationsModify All Data or Manage Next Best Action Strategies
To open, edit, or create a flow in Flow Builder:Manage Flow
To create and save Lightning pages in the Lightning App Builder:Customize Application
To view Lightning pages in the Lightning App Builder:View Setup and Configuration
To run a recommendation strategy on a Lightning record page:Run FlowsORFlow User field enabled on the user detail page
To create, edit and delete custom report types:Manage Custom Report Types
To view recommendation metrics data:Modify All Data or Manage Next Best Action Strategies

Check out the other blogs in the series for

Summer ’21 Pilot Preview: Einstein Next Best Action on Flow! (Blog 1 of 4 series)
Pilot Tutorial -Einstein Next Best Action on Flow(Blog 2 of 4 series)

Pilot FAQs-Einstein Next Best Action on Flow (Blog 4 of 4 series)

Happy Next Best Actioning!!

Pilot Tutorial -Einstein Next Best Action on Flow(Blog 2 of 4 series)

Bonus: You also get to check out the brand new Sort collection processor element on Flow!

This tutorial will help you create your first Recommendation Strategy on Flow! This is a pilot feature, so contact your Account Executive to get nominated for the pilot. Also if you haven’t already, check out this blog for an overview on the product. As an added bonus, this tutorial also helps you check out the brand new Sort collection processor element on Flow!

You can also download this pdf to follow along:

NBA-on-Flow-Pilot-4

WHAT’S NBA ON FLOW? 

You can now create Next Best Action Strategies using the powerful Flow Builder and leverage the power of Salesforce’s mature Automation Platform .

NBA customers will now have a brand new way of creating recommendation strategies on flow builder that is packed with powerful platform features such as Templates, Versioning, Packaging 2.0 support, Sub Strategies, Debugging enhancements and also will be home to low code AI driven Recommendation, OOTB Reporting and analytics , OOTB Integration with Bots, Enhanced Display component with Mobile support and many other cutting edge decisioning builder elements. Planned GA in Spring ‘22 (Safe Harbor applies) 

WHAT WILL BE AVAILABLE AS PILOT IN SUMMER ‘21 

Try the following pilot tutorial out by creating a sample flow as follows. The use case is to show recommendations on a Case object. For a customer whose CSAT is greater than 50 show Cross-sell and Upsell offers (stored as recommendation records) and for a customer whose CSAT is lower than 50 show some Promotional offers. For every customer irrespective of CSAT, show any other recommendations. Also check out the demo video that explains all the features.

Let’s try and build the following flow and see some recommendations .

  1. Use Flow Builder to Create a new Recommendation Strategy
    1. Open Flow Builder: From Setup, enter Flows in the Quick Find box, select Flows, and then click New Flow.
    2. Select Recommendation Strategy on the, which is a new process type Recommendation Strategy, and click Create.

2. Create Recommendations :cRecommendations are created the same way as they are with the use of Strategy builder. Recommendations are standard Salesforce records, similar to accounts and contacts, that are processed by strategies and associated with flows (Make sure the flows associated with recommendations are Activated).Read ‘Create Recommendations’ from the documentation here.

3. Load Recommendations using GetRecords :

Use the GetRecords element to load Recommendation records that are evaluated in the strategy when the strategy executes. In the Beta version, you will be able to load records of any object and use a Map element to convert them into Recommendations.

Use the Decision element to conditionally evaluate the flow based on conditions such as in the example shown below: If CSAT is lower than 50, load promotional offers to retain the customer. 

4. Sort recommendations( upto 3 levels deep)

With the Collection Sortnew element, you can reorder the recommendations using Recommendation fields up to 3 levels deep. Choose whether you want to sort in an ascending or descending order, and decide how many recommendations to allow through.

5. Save the flow and Activate it. 

6. Display the resulting recommendations using the Next Best Action component on record pages

After creating a Recommendation strategy in Flow Builder, choose a page to display your recommendations and run your strategy. You can use a Lightning record page or an app’s Home page by following the steps below. 

Lightning Page (Lightning App Builder)

  • In Lightning App Builder, create, edit, or clone a record page.
  • Drag Einstein Next Best Action from the component list to the location on the page where you want to display it.
  • In the property editor,Choose an action strategy and the number of recommendations you want the component to display.
  • Other properties, remain the same as mentioned in Einstein Next Best Action component documentation. 

7. Accept/reject a recommendation and launch a flow from the runtime component. The screen flow associated with the recommendation can be launched on Accept /reject as specified in the configuration.

8. Report on accept/reject recommendations from the runtime component

As with Strategy Builder, custom reports can be easily created to report on and track recommendation data and strategy metrics. You can see the monthly total recommendations that a Salesforce org’s strategies served. And you can analyze which recommendations are accepted and rejected, who responds to them, and more. 

For the NBA on Flow pilot, the one primary difference is that the the primary objects to report on are Recommendation Response (As opposed to Recommendation Reactions) and Recommendation Strategy Metrics (Same as previous – for monthly metrics) 

Refer documentation on 

  • Creating Reports on Recommendation Response metrics
  • Creating Reports on Monthly Strategy metrics

9. And finally .. you can also enable Recommendation Strategy process type to be invoked by the Flow Action endpoint.

  • In addition to being able to display recommendations on the Home page or Lightning record page, a recommendation strategy can also be executed via a call to the Flow Action endpoint. 
  • Display recommendations on a custom component or call the recommendation strategy from a scheduled flow by making a call to the API and retrieving recommendations.

The following example illustrates strategy execution via REST API

Thanks for following along this tutorial! Hope you had fun creating your first Recommendation Strategy on Flow! Wondering what more is coming up in subsequent releases?

With Beta/GA (Safe Harbor applies) you will have access to other collection processor and decisioning elements that is currently available in Strategy Builder such as Filter , Map , Branch Selector and Limit Reoffer elements in the new Recommendation Strategy process type in Flow. 

 In addition to having functional parity with Strategy builder, several other features such as OOTB low code AI recommendations, Scheduled/ Triggered Recommendations , Reporting enhancements, Display component enhancements, OOTB integration with Bots, Support for Mobile display and much more! Check out the blog for an in depth roadmap.

Check out these other blogs in the series for more information

Summer ’21 Pilot Preview: Einstein Next Best Action on Flow! (Blog 1 of 4 series)

Pilot other considerations and requirements: Einstein Next Best Action on Flow(Blog 3 of 4 series)
Pilot FAQs-Einstein Next Best Action on Flow (Blog 4 of 4 series)

Happy Next Best Actioning!!

Summer ’21 Pilot Preview: Einstein Next Best Action on Flow! (Blog 1 of 4 series)

With the Summer ‘21 Pilot we invite you to try out a brand new way to create Next Best Action Strategies using the Flow Builder  that is packed with powerful platform features and many other cutting edge decisioning builder elements. 

Planned GA in Spring ‘22 (Safe Harbor applies) Talk to your AE to get nominated for the Pilot and try it out! 

This sounds exciting!! How do I try it out?? 

Since it’s a closed sandbox pilot, reach out to your AE and you can get nominated. Your AE will be able to share the following resources: Also available as blogs right here!

  1. A detailed PDF with step by step instructions on how to get a Steelthread working with the new Recommendation Strategy Process type
  2. A demo video to take you through the steps.
  3. A list of FAQs

Don’t have an AE ? Do not fret. We will be out with the Beta version soon!! Until then, if you haven’t already get your hands dirty with the Strategy builder and try out building an NBA! Check out the Next Best Action Section of Unofficialsf to learn more.

Need a little more convincing to try out the pilot ?

Check out what’s coming up in Beta/GA in the next few releases with NBA on Flow!!! 

Happy Next Best Actioning!!

Check out the other 3 posts in the series for a tutorial demo video , FAQs and more

Pilot Tutorial -Einstein Next Best Action on Flow(Blog 2 of 4 series)
Pilot other considerations and requirements: Einstein Next Best Action on Flow(Blog 3 of 4 series)
Pilot FAQs-Einstein Next Best Action on Flow (Blog 4 of 4 series)

Pilot FAQs-Einstein Next Best Action on Flow (Blog 4 of 4 series)

Check out these blogs for an Overview, Tutorial and More considerations for Pilot

Here are a few FAQs you may have. I ‘ll start with the obvious one – Is Strategy Builder Going Away?? ..

Is Strategy Builder going away? Why do we need 2 ways to build the same thing? 

Great Question! No, it is not going away anytime soon. However, the good news is you stand to get a ton of great new features on the builder, Reporting and Display enhancements, templates etc that will be available on the new Recommendation Strategy Process type. You also get to enjoy some great platform features such as  templates, versioning, advanced debugging capabilities etc right off the bat! Stay tuned for the beta in winter ‘22. In other words, we’d hate for you to loose out on all these cutting edge flow features, so while we will continue to support Strategy Builder- Flow is the future!!

  • How do I get access to this pilot feature?
    1. Reach out to your AE to get nominated for the pilot, we will turn on the pilot perm on your Sandbox and you are ready to roll!
    2. Feature is available in Essentials, Professional, Enterprise, Performance, Unlimited, and Developer Editions. 
  • How do I connect to external services ?

Use Apex actions in flow to integrate external data sources and information from your Salesforce org into your strategies. You can connect to any number of EXTERNAL SERVICES: connect to an external endpoint such as a credit service provider AND easily bring back the logic, , For example say experian provides a RESTful interface for accessing credit score information. You can integrate the REST API, bring back the score . here and use that to filter out a few recommendations. Its basically a call out to Apex. So that helps with the business rules.

  • Can I connect to an AI of my choice?

In Beta/GA version of NBA in flow you will have access to Einstein Load node from Einstein  Recommendation Builder* directly integrated ( with the Recommendation strategy process type. However you can use Apex actions as mentioned above to call any Prediction service and retrieve these values in the flow. 

*Requirements for ERB  Contact your Account Executive to learn more on ERB

  • How do I Troubleshoot?

Before you activate a recommendation strategy test it thoroughly to make sure that it works as expected. Use the debug option in Flow builder to test the flow. This is analogous to the Inspect option on Strategy builder. 

  • What Perms do I have to enable?
To create or manage recommendationsModify All Data or Manage Next Best Action Strategies
To open, edit, or create a flow in Flow Builder:Manage Flow
To create and save Lightning pages in the Lightning App Builder:Customize Application
To view Lightning pages in the Lightning App Builder:View Setup and Configuration
To run a recommendation strategy on a Lightning record page:Run FlowsORFlow User field enabled on the user detail page
To create, edit and delete custom report types:Manage Custom Report Types
To view recommendation metrics data:Modify All Data or Manage Next Best Action Strategies
  • If I have strategies in my org already, will I have a migration tool ? 

We are considering building a migration tool and would love feedback on it. However, we definitely will have some templates on the Beta/GA version to help you get started. 

  • What is coming in future releases?

NBA on Flow Beta/GA (Winter/Spring ‘22 Safe harbor applies ) 

  1. Strategy Builder Parity elements: Filter ,Map, Branch Selector, Limit Reoffer elements will be added to the Recommendation Strategy process type.  This is to get to functional parity with Strategy builder. Beyond parity, the following features will be built. 
  2. Enhanced Reporting 
    1. Access to RecommendationReactions BPO for Reporting
    2. Reporting with dynamic recommendations created with Generate node
    3. Enabling sharing access on the object so access can be limited to reports for Business Users without giving access to the builder
  3. Enhanced Display 
    1. Mobile support for Display component
    2. Recommendation Reason: Ability to surface why a recommendation is surfaced along with Einsetin score if driven by a model 
    3. Capture Rejection reason
    4. Multi strategy support
  4. AI based Recommendations with Einstein Recommendation Builder*  
    1. Integrate AI in recommendations
    2. Low code Einstein integrated with NBA

*Requirements for ERB 

  1. Other platform features and much more : 
    1. Support for higher number of loads: Support of  upto 50000 loads (Up from 2000 loads currently supported)
    2. Triggered Recommendations: Support for triggered/scheduled Recommendations 
    3. Sub-strategies: Reference a subflow from within a flow

Check out the other blogs in the series for more info on the pilot

Summer ’21 Pilot Preview: Einstein Next Best Action on Flow! (Blog 1 of 4 series)
Pilot Tutorial -Einstein Next Best Action on Flow(Blog 2 of 4 series)

Pilot other considerations and requirements: Einstein Next Best Action on Flow(Blog 3 of 4 series)

Happy Next Best Actioning! 

Building a Scheduled Alert Generator with Next Best Action and Flow

Suppose that you have an NBA recommendation strategy that runs on Account record pages, generating insights and recommendations specific to a given account. Your salespeople have 50 accounts, and they don’t want to have to manually visit every account page each day to see if there’s something new waiting for them there. What do you do?

Watch the Video

Overview

In this solution, we create a two part process. Every night a scheduled flow runs that kicks off a recommendation strategy for every active Account in the organization. This might take a long time and a lot of processing power, but we’re doing it in the middle of the night and can spread it out if we run into any load issues. When the flow gets the results back for a given account, it is only concerned with the _count_ of recommendations. If at least one recommendation has been returned, it marks that Account record by setting to True a boolean Account field called HasAvailableInsight__c. The recommendations themselves are discarded.

When the salesperson starts work the next morning, instead of visiting an Account page, they visit their Home page, where a different NBA strategy is running. This strategy generates a recommendation for each Account that has an available insight. This provides the user with an effective task list of accounts to check. They can click on a recommendation to take them directly to that account page, where the original Account strategy will present them with useful insights.

You can install the package provided here, which consists of the Scheduled Flow that runs at night, the two sample NBA strategies, and the action flow that navigates the user from the NBA component on the Home page to the appropriate Account page.

How It Works

Here’s the Scheduled Flow that runs each night:

This scheduled flow starts by loading the desired set of accounts. It loops over them, running the Execute NBA Strategy flow action against each account. (Note that this flow action is included in this package). This flow action has been enhanced to return a count of the number of recommendations, and this count is used in a decision element to determine whether the HasAvailableInsight__c field should be set to true or false. After the looping is complete, the updated accounts are saved.

Here’s the configuration of the flow action:

The Home page looks like this:

Here’s the strategy that runs on the Home Page:

The account records are mapped into recommendation objects with this configuration:

To navigate the user to the appropriate account page from the home page, the Navigate Everywhere flow action is used.

The final strategy that runs on the Account page can be anything you want, but you obviously want it running the same analysis that the nightly scheduled flow runs.

Install

Not yet available as a package.

View Source

Source