Deploy Case Quality Agent on Salesforce

Until now, you have configured the Case Quality Auditor in the Agentic Suite. In this section, you will learn how to install the configured agent on Salesforce. You can either perform the installation yourself or get assistance from the SearchUnify team.

For assisted installation, click Connect with Our Team.

Fig. A snapshot of the Deployment screen.

If you’re installing the Case Quality Auditor Agent in Salesforce yourself, click the document icon to view the deployment instructions.

Fig. A snapshot of the Deployment screen.

Currently, only the Salesforce platform is supported. A prerequisite to installing the agent on Salesforce is to first configure SLAs in your Salesforce Service Console. The next image displays the deployment instructions for the Salesforce platform.

Once you're done, click Save. Next, move to activating your agent on the Agents List screen.

Instructions

For a Case Quality Agent to work, it must be able to recognize when a case is marked as closed. Closed cases can be detected through HTTP callouts. Create the Apex Class for the HTTP Callout This function performs the following steps: In Setup → Apex Classes → New, paste the following:

Copy
public class CaseQualityTesting { 
    @future(callout = true)
    public static void sendClosedCase(String recordId) {
        try {
            Http http = new Http();
            HttpRequest req = new HttpRequest();
            req.setEndpoint('https://yourcompany.searchunify.com/su-agent-suite/su-agent-suite/tex/api/webhooks/agent-webhook');
            req.setMethod('POST')
            // Headers
            req.setHeader('Content-Type', 'application/json');
            req.setHeader('uid', 'abcdefgh-abcd-abcd-abcd-abcdasdfasdfas');
            // Body payload
            Map < String, Object > payload = new Map < String, Object > ();
            payload.put('id', recordId)
            req.setBody(JSON.serialize(payload))
            HttpResponse res = http.send(req);
            System.debug('CaseQualityTesting Response: ' + res.getBody());
        } catch (Exception e) {
            System.debug('Error in CaseQualityTesting: ' + e.getMessage());
        }
    }
}

Navigate to Setup→ Object Manager→ Case.Go to Triggers→ New.Paste the following trigger code:

Copy
trigger CQCaseAfterCloseTrigger on Case(after update) {
    for (Case c: Trigger.new) {
        Case oldCase = Trigger.oldMap.get(c.Id);
        // Check if Status has changed to 'Closed'
        if (c.Status == 'Closed' && oldCase.Status != 'Closed') {
            CaseQualityTesting.sendClosedCase(c.Id);
        }
    }
}

Test the Trigger

To test the trigger:

  1. Create or open a case.

  2. Change its Status to Closed.

  3. Save the record.

  4. Before Salesforce allows the HTTP callout, the endpoint must be whitelisted. Go to Setup → Remote Site Settings → New Remote Site.

    Enter a Name (e.g. FeatureAIAPI). Remote Site URL: https://yourcompany.searchunify.com/su-agent-suite

  5. Click Save.

  6. Closing the Case Using Apex Code If you are unable to close the case manually from the Salesforce UI, you can close it programmatically using Apex:

  7. Open Developer Console in Salesforce. Go to DebugOpen Execute Anonymous Window. Paste and run the following code :

    Copy
    Case c = [SELECT Id, Status FROM Case WHERE Id = 'CASE_ID'
      LIMIT 1
    ];
    c.Status = 'Closed';
    update c;