Configure Groovy Scripts to Enable Agenting Orchestration

You need to use Groovy scripts to orchestrate Triage Agent and Resolution Agent. However, if you want to use the Triage Agent and the Resolution Agent individually, then Groovy scripts are not needed.

Here's how you can create a Groovy script:

  1. Navigate to Configuration > Sandboxes.
  2. Create a sandbox and select Application Composer.
  3. Navigate to Objects > Standard Objects > Service Request > Messages > Server Scripts and select Triggers.
  4. Create a new trigger and add the following Groovy script in the trigger's body.
    // Before insert trigger on message object.
    if (MessageTypeCd == 'ORA_SVC_AI_SYSTEM_NOTE') { def msgContent = MessageContent
    if (msgContent != null && msgContent.toString().contains("\"workflowCode\":\"sr.triage.agent.workflow\"")){
    if(msgContent.toString().contains("\\\"vague\\\":\\\"no\\\"") && (msgContent.toString().contains("\\\"additionalInformation\\\":null") || msgContent.toString().contains("\\\"additionalInformation\\\":[]"))){
    ServiceRequest?.StatusCd = 'TRIAGE_DONE'
     }
    else {
        ServiceRequest?.StatusCd = 'TRIAGE_WAITING'
        }
      }
    }
    // This groovy script is needed for Workflow Orchestration. The intent is to update SR Status to TRIAGE_DONE, when Customer replies with additional information requested by Triage Agent, which will kick off other workflow.
    if ((MessageTypeCd == 'ORA_SVC_CUSTOMER_ENTRY') && (ServiceRequest?.StatusCd == "TRIAGE_WAITING"))
    {
    ServiceRequest?.StatusCd = "TRIAGE_DONE"
    }
  5. Click Validate and after validating the script, save and close.
  6. Publish the sandbox.