Einstein Next Best Action #TexeiTestsForYou

By

7 minutes de lecture

At Texei, we believe that keeping up-to-date with the latest Salesforce features is important, but testing them ourselves is even better. With that in mind, after hearing a lot about Einstein Next Best Action, my coworker Jorge Centeno and I decided to get our hands dirty and launch #TexeiTestsForYou.

Einstein Next Best Action
Example of Recommendation displayed via the Standard NBA Component

What is Einstein Next Best Action?

For those of you that don’t know what Einstein NBA is, let’s dive in a little. Basically, it’s a feature first released in Spring 19, that helps you guide your users, clients or partners by recommending them, at a specific point, the best personalized course of action according to your company’s strategy.

In Salesforce, it translates as :

There is a lot of quality content online, providing a quite complete tool-box to help you master these different elements of NBA. You’ll find some of my personal favorites at the end of this article.

The purpose of this article is definitively not to reinvent the wheel. Instead, I want to tell you about the designing part. Yes, you know, what comes before making a feature as useful as this :

source, bright side : https://cutt.ly/ne4E0bk

And I also want to tell you about what we were confronted to and how we dealt with it.

How to design and implement

Often, people talk about how to do things. I believe it is equally important to tell you about what comes first : understanding your business need and designing your solution.

As a picture is worth a thousand words :

A few example of use cases are:

  • Cross-selling a product to a customer based on his previous purchases and/or is location, and/or his level of attrition
  • Advising sales or support people to take a specific action for a customer, i.e. renew support contract, offer special discount if several cases have been escalated recently… and guide them through the process.

But more than a list of use cases, the most interesting — and important — thing is combining all these recommandations together and making them emerge only in the right situation and at the right time so that each customer will get the best customized and adequate experience. Bring even more value with a scalable, easy to manage solution.

In practical terms: one object, one strategy, as many — valuable and pertinent — recommandations and flows as needed, and nearly unlimited combinations between them thanks to the different elements provided by the Strategy Builder.

Following our own advice, Jorge and I finally jumped right into implementation and…

Issues and workarounds

Yes, we loved Einstein NBA, but let’s face it, nothing is ever completely easy. Plus, it is still a relatively young feature, so there’s bound to be some challenge.

  1. Managing criteria in the Strategy Builder

In the Strategy Builder, you’re very limited by the “Standard” settings tab for each element. If you try to use it, you can only filter on your recommendation records. But there’s always the “Advanced” tab, which works just the same as a formula field.

Great, isn’t it? The only thing is you can type whatever you want, you won’t know if what you typed makes sense before testing your whole strategy.

Unless… you create a new formula field in an object to use as draft, and test your syntax in there before copying/pasting into the advanced filter ;)

2. Trying to work with non-persisted records in your flow

As a “technico-functional” consultant, sometimes behavior that seems fairly easy and logical to me well… just isn’t. So what I wanted was to call an Apex invocable action in our flow that would return a list of potential business partners (accounts) when we didn’t have one. Easy. But I wanted to give the users the choice of which partner they would want to sign and then, save the choice as a new Account. Well… it turns out that working with non-persisted records in a flow isn’t possible (or I didn’t find out how). And the simple reason is… non-persisted records don’t have Id’s! So how do you assign them to variables, iterate and perform operations on them?

The answer is : you don’t. So what we did was think backwards : save the records in the apex method, — you could also save them in the flow before processing them — let the users choose the potential business partner they want to work with and delete the others.

3. When you cannot find your invocable methods in the flow builder

After creating a new environment, we faced another pleasant issue. As I created my flow, I couldn’t find our invocable action. I couldn’t understand what had happened, because it was the exact same code in our Apex class than in the previous sandbox. After a couple of hours and multiple google researches, we finally found the answer: it appears that, sometimes, there is a caching issue impacting the Lightning Flow Builder that prevents your invocable actions from being available.

The trick is then to enable the good-old Cloud Flow Designer, which doesn’t suffer from this terrible affliction. Your invocable action will be loaded. Close the designer, reopen the new builder and Voilà! You will now be able to see and use your invocable actions.

4. Getting frustrated with the checkbox groups behavior

This one was definitely the most frustrating of them all. Checkbox groups do not have the same behavior between the Cloud Flow Designer and the Lightning Flow Builder. How so? Before, you could get the record choices selected by the user, assign them to a collection variables, then use them as you wished.

Today, apparently, you can only capture one record. The last choice that was selected by the user. What is tricky while trying to debug this is, you can capture all the Id’s (or other fields available) of the choices in a string and display them. But when it comes to passing them into a record collection, nothing seems to work.

So, if you’re trying to let the user select multiple records via a checkbox groups, get the choices and apply some logic to them, the only option currently seems to be using the Cloud Flow Designer.

And Einstein in all that?

More than once, I asked myself why Einstein NBA had Einstein in its name if -as an admin – you are the one giving the strategy its intelligence. Where’s AI in all that?

Well, you can and most likely will use NBA without AI. And it remains a great feature that can provide a lot of value to your business.

But you can also add some AI. There are mainly two ways to do so.

  1. With Einstein Discovery : find more about it here
  2. Using the Generate or Enhance Elements in the Strategy Builder with an invocable action that calls a predictive analysis service

In both cases, the idea is the same. You use AI to generate or surface recommendations thanks to predictive analysis based on your data or external information. For example, you send information about products purchased, cases you have recorded on a client and sentiment analysis over a particular product, and you can surface a product personalized product recommendation for your customer.

I didn’t test it, but if you do, don’t hesitate to share it with us!

Some useful links

That’s all about Einstein Next Best Action. If you want to learn more, check out our article onfigure Einstein enhanced instant search results layout by Profiles and follow us on Linkedin!

Read more posts

Enforce code standards with PMD

Developers working on a project usually set coding rules to have a standardized codebase. It is an important piece of the code maintainability, and it can be very easy …
March 2023
Advices
Scratch orgs

Uncovering Salesforce Settings: A Step-by-Step Guide for Scratch Orgs

Today, it’s pretty easy to build your Scratch Org definition file when you know what Settings you want to activate, as they are mapped with the same setting names …
February 2023
Advices
Business Analyst

Core qualities of a Business Analyst?

A common definition we are used to hear is that being a Business Analyst means to have a combination of both hard skills and soft skills. What does a …
June 2022
Advices
Image d'illustration d'une employée travaillant sur un ordinateur portable

Process builder and workflow make way to Flows (½)

Overview “If you can do it with a Workflow, then do it with a Process Builder, because everything a Workflow does, a Process Builder does it better”. If you …
March 2022
Advices

Day 22 : Salesforce new “Migrate To Flow tool” in Spring 22

As most of you already know, the workflow rules and process builders are planned to be retired in 2023 (no precise date defined so far). Today, I’m going to …
December 2021
Advices

Day 18 : Fake callout responses for test classes !

Hello everybody ! Today let’s talk about Apex tests classes in Salesforce. Everyone loves a good test class, and Salesforce makes it official by requiring to have a minimum …
December 2021
Advices