We’ve previously shown how you can take the official, out-of-the-box Next Best Action component and surface it in a Flow screen, where it will show recommendations. We wanted to support some additional use cases, though, so we’ve built a toolkit for complete customization of the Next Best Action presentation experience.
This solution consists of two parts:
- A Flow Action that sends an execution request to the Next Best Action engine and receives back a list of recommendations
- An open-source LWC Next Best Action display component that can be easily customized.
The Execute Strategy Flow Action lets you specify a strategy, a recordId, and the maximum number of results you want, and returns recommendations in the same data structure that the Apex api endpoint uses. You can take these recommendations and process them with your Flow. You can also pass them “as is” to the included Next Best Action “Compact” display component, which expects the same data structure.
The Compact NBA component is something of a test bed for features that Salesforce is considering for the main Next Best Action component. It has the following features:
- Works in flow screens unmodified
- Packs more recommendations into less space
- Supports multiple screens of recommendations (up to 25)
- When a recommendation is responded to, it disappears, and any recommendations that are ‘behind’ it slide up.
- Open-source. You can modify it easily to meet your custom needs
The Compact NBA component reports all reactions to the Recommendation Reaction endpoint for reporting. It does not support images or Community Cloud pages.
ExecuteStrategy Flow Action
|maxResults||up to 25. Default is 4|
<property name=”displayDescription” label=”Display Description” type=”Boolean” default=”false” role=”inputOnly”></property> <property name=”displayTitle” label=”Display Title” type=”Boolean” default=”true” role=”inputOnly”></property> <property name=”recordId” label=”Record Id” type=”String” role=”inputOnly”></property> <property name=”strategyName” label=”Strategy Name” type=”String” role=”inputOnly”></property> <property name=”displayMode” label=”Display Mode” type=”String” datasource=”ShowAll, ShowPages” default=”ShowAll” role=”inputOnly”></property> <property name=”maxRecommendations” label=”Max Recommendations” type=”Integer” default=”25″ role=”inputOnly”></property> <property name=”recommendations” label=”Recommendations” type=”apex://NBARecommendationsList” role=”inputOnly”></property>
For more information on the use of Apex-Defined data like the recommendation attribute, see this.
For another variation on incorporating NBA Recommendations into Flow, check out this post on how you can include the standard Out Of The Box NBA component in Flow screens.