Views:

Overview

In this article we use a simple scenario to show how you can easily embed output from an OpenAI LLM into your decision tables. The decision table logic changes the inputs for the OpenAI analysis and then uses the output for the rules to determine the appropriate queue for a new Case. We show you how easy it is to connect the OpenAI LLM using the CallRestAPI() function, and use the results for decision making. You can use this as a basis to build significantly more complex scenarios.

Rules for Case Prioritisation

Rule #Description
1
If the customer has a Gold service level, the Case will be analysed by OpenAI gpt-4.1 model, with allowable outputs of Urgent and Moderate prioritisation. 
2
If the customer has a Silver service level, the Case will be analysed by OpenAI gpt-4.1 model, with allowable outputs of Urgent, Moderate and Low prioritisation. 
3
If the customer has a Bronze service level, the Case will be analysed by OpenAI gpt-4.1 model, with allowable outputs of Urgent, Moderate and Low prioritisation. 

North52 Decision Suite Solution

The North52 Decision Suite solution works like this:

  • A Formula is set up on the Case table which:

    • Determines the instructions to sent to the OpenAI LLM

    • Calls the OpenAI web service using the CallRestAPI() function

    • Parses the JSON returned from the web service

    • Uses this information to determine which Queue to assign the Case (using the AddToQueue() function)

Set up xCache and Formula

First, you need obtain an API key from your OpenAI account. This is then securely stored in a xCache record. 

xCache

To securely store the API key we use an xCache record. Only System Administrators or specifically authorized users will be able to access this value.

  • Open the North52 App

  • Navigate to Business Process Activities > N52 xCache

  • Create a new xCache record

    • Enter OpenAI for the Category

    • Add APIKey to the Base Key so that the full BaseKey name is OpenAI_APIKey

    • In the Value Information tab enter your OpenAI API key into the Value (Secured) field

  • Click Save

North52 xCache form

Formula

Copy the following changing the relevant part to start defining the process of creating a new formula. 

  • Open the North52 App

  • Navigate to Business Process Activities > Formulas

  • Create a new formula, setting the following values in the Formula Guide:

    • Source Entity set to Case

    • Set Formula Type to Save - Perform Action

    • Select the Decision Table editor

  • Change the Name of the formula to Case - Send to Queue Based on AI Analysis

  • Set the Source Property to Description (this is field that will trigger the Formula to apply the rules)

  • Click Save

Sheet 1 - Determine Instructions

This sheet set out the rules that will shape the instructions for the OpenAI LLM

 

  • Double-click on the sheet tab name, change the text to Determine Instructions

  • Select cell A2

    • From the Source tab, expand Source and select Description

  • Select cell A4

    • From the Functions tab, search for containsdata

    • CTRL + click (CMD + click Mac) the ContainsData function, to add it to the cell in the format {{{ContainsData}}}

  • Copy cell A4 to A5

  • Select column B, then right-click and select Insert > Insert Condition

  • Select cell B2

    • From the Source tab, expand Source and select Service Level

  • Select cell B4

    • Expand the Service Level node in Source and select Gold to add {Gold} to the cell

  • Select cell B5
    • Select Silver to add {Silver}
    • Select Bronze to add {Bronze} to the same cell
  • Select column C, then right-click and select Insert > Insert Inline Calculation
    • Add 'gpt-4.1' (including single quotes) to cell C4 and C5  
  • Select column D, then right-click and select Insert > Insert Inline Calculation
    • In cell D4, add the text (using the StringFormat function we replace the {0} within the text with the Contract Service Level name value): 
      StringFormat('You are a customer service representative analysing new support requests to determine their priority. You will determine the priority by analysing the sentiment and tone of the request. Our company has 3 levels of customer service level - Gold, Silver and Bronze. This customer status is: {0}. You will only one output either: Urgent, Moderate', [incident.contractservicelevelcodename]) 
    • In cell D5, add the text: 
      StringFormat('You are a customer service representative analysing new support requests to determine their priority. You will determine the priority by analysing the sentiment and tone of the request. Our company has 3 levels of customer service level - Gold, Silver and Bronze. This customer status is: {0}. You will only one output either: Urgent, Moderate or Low', [incident.contractservicelevelcodename])
  • Select column E, then right-click and select Insert > Insert Inline Calculation
    • Select cell E4, and from the Source tab, select the Description field. This will add {Description} in the cell.
    • Copy cell E4 to E5
  • In cell F2, enter the text: Exit if Data Missing
    • Select cell F6
    • Click the Functions tab, search for exit, and click on the ExitAllDecisionTables() function
Decision Table

Sheet 2 - Execute AI Model

This sheet calls the OpenAI API and extracts the response.

 

  • Right-click on the Determine Instructions sheet, select Insert > Insert Decision Table

  • Select column A, then right-click and select Insert > Insert Inline Calculation
    • In cell A2, enter Call AI
    • In cell A4, enter:
       

      CallRestAPI(
          SetRequestBaseURL('https://api.openai.com/v1/'),
          SetRequestResource('responses'),
          SetRequestDetails('Post'),
          SetRequestHeaders('Content-Type', 'application/json', 'Authorization', 'Bearer ' + xCacheGetGlobal('OpenAI_APIKey')),
          SetRequestParams(
              'model', {GPT Model},
              'instructions', {Instructions},
              'input', {Input}
          ),
          SetRequestAuthenticationNone(),
          SetRequestFiles(),
          SetRequestExpected('200'),
          SetRequestActionPass(),
          SetRequestActionFail('Error!: ' + GetVar('ResponseContent'))
          )
    • {GPT Model}, {Instructions}, and {Input} are references to the inline calculations on the first sheet and can be inserted from the Source tab
    • The xCacheGetGlobal('OpenAI_APIKey') is inserted from the xCache node on the Source tab
  • Select column A, then right-click and select Insert > Insert Inline Calculation
    • In cell B2, enter Output
    • In cell B4, enter GetVarJsonValue('output[0].content[0].text') - this gets the value we need from the JSON response
  • Select columns D and E, right-click and select Delete > Delete Column

Decision Table

Decision Table - CallRestApi

Sheet 3 - Assign Case to Queue

This sheet processes the output and assigns the Case to the appropriate Queue.

 

  • Right-click on the Execute AI Model sheet, select Insert > Insert Decision Table
  • Select cell A2
    • From the Source tab, expand Decision Table Calculations > Execute AI Model then click on Output
  • Select cell A4
    • Enter 'Urgent'
  • Select cell A5
    • Enter 'Moderate'
  • Select cell A6
    • Enter 'Low'
  • Select cell B2
    • Enter Add to Queue
  • Select cell B4
    • Select the Functions tab, search for addtoqueue, and click the AddToQueue function
    • Delete 'recordid' including the quotes, then select the Source tab, expand Source and click on Case
    • Replace entityname with incident
    • Delete 'destinationqueueid' including the quotes, then select the Functions tab, search for quickid and shift-click on the FindValueQuickId function to open the function wizard:
      • Leave Friendly name blank
      • Find and select the Queue entity
      • For Name of Record to Find ID of enter Enter Cases - Urgent
      • Click Generate
    • Delete last paraemter including comma: , 'sourcequeueid' 
  • Copy cell B4 to B5 and B6
  • In cell B5, change Urgent to Moderate Priority
  • In cell B6, change Urgent to Low Priority
 
Decision Table