Retrieving Case Classifications Using Apex

Enterprise

Coveo for Salesforce 4.8 (October 2020)

Prerequisite

You must have your Case Assist ID on hand. If you don’t, see Retrieving Your Case Assist ID.

Retrieving Case Classifications

  1. In Salesforce, access the Developer Console.

  2. Instantiate the CaseAssistApiClient as follows:

     String caseAssistId = '00000000-0000-0000-0000-000000000000';
     Boolean debug = false;
     CoveoV2.CaseAssistApiClient client = CoveoV2.CaseAssistApiClient.getClient(caseAssistId, debug);
    

    The debug parameter is optional. It indicates whether to include an execution report for debugging purposes. The default value is false.

  3. Invoke the getCaseClassifications method to retrieve the case classifications. For example:

     Map<String, Object> classifications = client.getCaseClassifications(new Map<String, Object> {
         'visitorId' => '56f994be-320d-4c06-ab8e-f7c312d517ff',
         'fields' => new Map<String, Object> {
             'subject' => new Map<String, Object> {'value' => 'The case subject'},
             'description' => new Map<String, Object> {'value' => 'The case description'}
         }
     });
    

    The getCaseClassifications method takes a Map<String, Object> as an input.

    You must specify values for the following arguments:

    • visitorId is an ID attributed to any site visitor. This ID allows Coveo to analyze the past visitor actions. For more information, see Visitor ID.

    • fields represents the fields of the current case that are considered meaningful for providing relevant case classifications.

      • subject and description are the case fields used to retrieve matching case classifications.
      • The field values should be read from the current case and passed as a Map<String, Object> with a value key.

      • More fields can be added to better suit the use case.

    The result is a Map<String, Object>, which contains suggested values for the fields configured in the Case Classification configuration. For example:

     Map<String, Object> fields = (Map<String, Object>)classifications.get('fields');
    

    You’re now ready to retrieve and use case classifications in your own application.

What's next for me?