Content recommendations


CR models depend on view events and the user’s action history. To display recommendations with Quantic, you must have configured a CR model and logged the required usage analytics events via the PageViewTracker component.

Implementation example

The following Lightning Web Component (LWC) example shows how you can implement a recommendation interface using the quantic-recommendation-interface and quantic-recommendation-list components.


    <div class="search__container slds-p-around_medium"
         onregisterresulttemplates={handleResultTemplateRegistration}> 1
        <c-quantic-recommendation-interface 2
            <c-quantic-recommendation-list 3
1 Optionally, register your own result templates to customize the appearance of your recommendation results, the same way you would in your main search interface.
2 The quantic-recommendation-interface component is the parent of all other Quantic components in a recommendation interface.
3 quantic-recommendation-list displays recommendations by applying the options provided to it.


import {LightningElement, api} from 'lwc';
// @ts-ignore
import caseTemplate from './resultTemplates/caseResultTemplate.html'; 1

export default class ExampleQuanticRecommendationsList extends LightningElement {
  @api engineId = 'quantic-recommendation-list-engine'; 2
  @api pipeline = 'mypipeline'; 3
  @api searchHub = 'mysearchhub';
  @api numberOfRecommendations = 3;
  @api recommendationsPerRow = 1;
  @api label = "Recommended for you";
  @api variant = "grid";
  @api fieldsToInclude = "objecttype,sfstatus,sfcasestatus,sfcasenumber"; 4
  @api recommendation = "recommendation"; 5

  handleResultTemplateRegistration(event) { 6

    const resultTemplatesManager = event.detail;

    const isCase = CoveoHeadless.ResultTemplatesHelpers.fieldMustMatch(

        content: caseTemplate,
        conditions: [isCase],
        fields: ['sfstatus', 'sfcasestatus', 'sfcasenumber'],
1 Import your custom result templates, if any.
2 The engineId is the unique identifier of the Headless engine that powers the recommendation interface. We recommend that you set a different engine from the one powering your search interface.
3 The searchHub and pipeline properties are required to correctly make requests to the Coveo Search API and usage analytics Write API. Although we recommend that you enforce these properties through the search token, you should still set them in your component to ensure that it works as expected.
4 The fieldsToInclude property is a comma-separated list of fields to include in the recommendation results. These fields are used to build the result templates and to display the recommendations.
5 The recommendation identifier used by Coveo ML to scope the recommendation interface.
6 Define result templates the same way you would in your main search interface.


<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="">
    <targets> 1
  <targetConfigs> 2
      <targetConfig targets="lightning__RecordPage, lightning__AppPage, lightning__HomePage, lightningCommunity__Page, lightningCommunity__Default">
          <property name="numberOfRecommendations" type="Integer" default="3" label="Enter the number of recommendations in total"/>
          <property name="recommendationsPerRow" type="Integer" default="1" label="Enter the number of recommendations per row"/>
1 Set the targets of your LWC.
2 Optionally, expose certain parameters through the Salesforce Experience Builder.

Generate search tokens for your component

We recommend that you create a search token provider dedicated to your recommendation component. Enforce the search hub through this provider to securely ensure that the component always has the required context.

  1. If you’ve installed and configured Coveo for Salesforce v4 or a later package in your Salesforce organization, it’s typically enough to copy the CoveoTokenProvider Apex class, along with its meta.xml file, into your Salesforce DX project. This class can automatically fetch your Salesforce users' information to generate search tokens for them. This is the best option for most use cases.

    If you haven’t installed Coveo for Salesforce v4 or a later package, or if the CoveoTokenProvider Apex class doesn’t fit your needs, you’ll have to implement your own search token provider.


    You can find an example in the Quantic project repository.

  2. Once you’ve copied or created your search token provider Apex class, you need to modify the Headless engine configuration used by the recommendation controller so that it calls your Apex class. You can modify the RecommendationsController file at force-app/quantic/classes. Locate the following line:

    return SampleTokenProvider.getHeadlessConfiguration();

    Modify it so that it leverages your search token provider instead:

    return YOUR_RECOMMENDATION_TOKEN_PROVIDER.getHeadlessConfiguration();

    where you replace YOUR_RECOMMENDATION_TOKEN_PROVIDER with the name of the search token provider Apex class that you created for your recommendation interface.

  3. After you deploy your project, your changes will be effective in your Salesforce organization.

Experiment with different variants and dimensions

The quantic-recommendation-list component supports different variants to display recommendations. Experiment with them to judge which one best fits your use case.


The grid variant displays recommendations in a grid layout, with the numberOfRecommendations and number of recommendationsPerRow of your choice.

  • numberOfRecommendations set to 3 and recommendationsPerRow set to 1

    Quantic recommendations in a narrow grid
  • numberOfRecommendations set to 9 and recommendationsPerRow set to 3

    Quantic recommendations in a wide grid

The carousel variant displays recommendations in a carousel layout, with the numberOfRecommendations and number of recommendationsPerRow of your choice.


numberOfRecommendations set to 9 and recommendationsPerRow set to 3

Quantic recommendations in a carousel