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?
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.
Not yet available as a package.