Loading
Salesforce now sends email only from verified domains. Read More
Automate Your Business Processes
Table of Contents
Select Filters

          No results
          No results
          Here are some search tips

          Check the spelling of your keywords.
          Use more general search terms.
          Select fewer filters to broaden your search.

          Search all of Salesforce Help
          Strategy Builder Enhance Element

          Strategy Builder Enhance Element

          Get AI-driven predictions from services such as Einstein Discovery and Einstein Prediction Builder to enhance Next Best Action recommendations with additional information, such as propensity scores. The Enhance element allows you to modify a set of recommendations on the fly, every time a strategy is executed. These recommendations can be static and live as records in Salesforce, or dynamic and sourced from external data sources or other Salesforce objects.

          Required Editions

          View supported editions for Next Best Action.
          Field Description
          Label The name of the element as it appears on the canvas.
          API Name The API name of the element. The API name must be unique.
          Description Optional description of the element and how it works within the strategy.
          Apex Action Search or select an Apex action, which calls an Apex class. An Apex class must have a method marked as an invocable method to appear as an Apex action in declarative tools like Strategy Builder.
          Argument Specify one or more parameters for the selected Apex action.
          Example
          Example Assume that your company integrates separate data sources from the manufacturers of products your business sells. Those data sources include information about the current availability of each item (in stock, back ordered, or unavailable). You can connect an Enhance element to your strategy’s Load or Generate element to provide that information to users in the recommendation.
          Example
          Example You can use the Enhance element to calculate a discount percentage for your customers based on how long your company has managed their account. Or you can use it to A/B test two branches of recommendations.
          NBA recommendation dialog with discount
          Example
          Example Suppose you use Next Best Action to provide upsell recommendations. You want to add a 5% discount to your product recommendations for those customers who have been with your company for more than one year. Customers of more than two years get a 10% discount, customers of more than five years get a 20% discount, and so on. Use the Enhance element to call an Apex action that performs a SOQL query. The query retrieves the Account age and appends it to the description of all incoming recommendations.

          The strategy used with an Enhance element can be as simple as Load -> Enhance -> Output. All recommendations the Load element retrieves or loads are passed as a list of recommendations to the underlying invocable method.

          NBA strategy with Enhance element

          When configuring the Enhance element, select Enhance with Discounts Based on Age as the Apex action and specify $Record.id as the input parameter.

          Enhance dialog with discount

          The Enhance element in turn calls the getDiscounts invocable method in the Enhance_GetAccountDiscount class. Notice how the description of each recommendation has a discount value appended to it (r.Description + ‘ with a 5% discount’).

          global class Enhance_GetAccountDiscount {
              @InvocableMethod(label='Enhance with Discounts Based on Age' description='Returns an enhanced set of recommendations with appropriate discounts')
              global static List<List<Recommendation>> getDiscounts(List<DataContainer> inputData){
                  
                  List<Recommendation> recommendations = inputData[0].recommendations; 
                  List<List<Recommendation>> outputs = new List<List<Recommendation>>();       
                  Account[] accounts = [SELECT Name, Description,CreatedDate, id FROM Account WHERE id = :inputData[0].accountId];
                     Double ageAccountMonths = accounts[0].CreatedDate.date().monthsBetween(date.today()); 
                  Double ageAccount = ageAccountMonths/12;       
                  List<Recommendation> returnedRecommendations = new List<Recommendation>(); 
                  for (Recommendation r:recommendations){
                      if(ageAccount > 1){
                          r.Description = r.Description + ' with a 5% discount';
                      }
                      else if (ageAccount > 2){
                          r.Description = r.Description + ' with a 10% discount';
                      }
                      else if (ageAccount > 5){
                          r.Description = r.Description + ' with a 20% discount';
                      }
                      returnedRecommendations.add(r);
                  }
                  outputs.add(returnedRecommendations);                 
                  return outputs;
                  
              }
          
          }
          

          Usage

          The Enhance element requires an Apex action marked as an invocable method.

          @InvocableMethod(
          label='Enhance with Discounts Based on Age' 
          description='Returns an enhanced set of recommendations with appropriate discounts')
          

          Use the Enhance element in combination with the Strategy Builder Load or Generate element.

          The Enhance element can pass any number of inputs to the Apex action. The input parameter must be a list or a list of lists of a user-defined Apex object (for example, a custom class called DataContainer). The user-defined Apex object must include a List<Recommendation> variable. The List<Recommendation> variable is automatically defined with the recommendations that pass into the Enhance element.

          global class DataContainer {
              @InvocableVariable
              public string accountId; 
              
              @InvocableVariable
              public List<Recommendation> recommendations;
          }
          ________
          global static List<List<Recommendation>> invocableMethod(List<DataContainer> inputData)
          

          The Enhance element returns a list of recommendations, List<List<Recommendation>>. These recommendation enhancements exist only in memory and don’t persist after the strategy is executed.

          global static List<List<Recommendation>> invocableMethod(List<DataContainer> inputData)
          
           
          Loading
          Salesforce Help | Article