Retrieve Case Classifications using Apex

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);
    Note

    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.

    Example
     Map<String, Object> classifications = client.getCaseClassifications(new Map<String, Object> {
         'clientId' => '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.

  4. Specify values for the following arguments:

    1. clientID identifies a specific instance of a browser client and provides insights into the events performed by the user.

    2. fields represents the fields of the current case that are considered meaningful for providing relevant case classifications. The subject and description fields are used to retrieve matching case classifications.

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

      • The field values should be read from the current case and passed as a Map<String, Object> with a value key.

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

    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.