Case Management in the context of a viabl.ai application relates to the management of interactions with one (or more) deployed knowledge base and relating it to a single Case. Each case has a unique ID, a state and a payload.
An typical scenario for case management would be a viabl.ai (silent) knowledge base designed to receive an incoming customer enquiry (perhaps via email). This enquiry might then be passed to a second, agent-facing, (dialog) knowledge base to continue processing. Once the agent has dealt with the enquiry, it is then passed to a third (silent) knowledge base which performs some back-end operations.
As you can see from the above example scenario, the solution combines 3 separate knowledge bases into a single solution. These knowledge bases require data to be passed from one to the next in order to progress the case (which in this example is a customer enquiry).
The first step in implementing case management is to create a solution. This is performed by the viabl.ai Deployment Server front end. The deployment server front end can be accessed from the main vaibl.ai menu > Server Management Portals > Deployment Server
When creating your solution, the main aspect is the format of the unique (automatically generated) case IDs. You can choose to have either an incremental case ID (from a given start number), or, a random case ID (to a given number of digits). This random number can also be included into a fixed format string.
Following on from our example scenario, a solution might choose to have incremental IDs (starting at 4000000) and use this in a format to produce a customer-facing ticket ID using the format "TKT_X" where the _ is replaced by the unique (incremental) number. So the first ticket produced would be "TKT4000000X"
Once you have created your solution, make a note of the unique solution ID (e.g. "111D1111-C321-123B-A123-123456789ABC") as this is required by all case management build tools.
The Add Case build tool is the mechanism to start a new case. A new case is associated with a solution (via the unique solution ID you can access from the Deployment Server Front End). It can have an optional developer-defined "state" (which defaults to "working" if omitted) and an optional initial payload.
The object created by the build tool is a Text Object which holds the unique Case ID. This case ID is passed between the different Knowledge Bases to track the unique case.
The payload (of an existing case) is retrieved by creating an object with the Get Case Payload build tool. This tool simply a unique caseID and returns the payload as a stringified JSON object.
Typical usage is to hold the answers to various questions in the payload object where the question name is the property name. For example...
{
"Grade": "Director",
"Department": "Sales",
"Hotel Cost": 150
}
If this is the chosen payload strategy, the auto-assign catalog objects build tool option can be used. As the name suggests, this option assigns any catalog object values where the object name matches the property name.
The same process can be achieved programatically via the inbuilt xpertrule.setValues method.
e.g. If the name entered into the Get Case Payload build tool was "case_payload", the code to assign the question answers would be...
xpertrule.setValues(JSON.parse(#case_payload.val()));
To add or update data in the case payload, use the Update Case Payload build tool. This build tool takes the object holding the case ID and an JSON object to update the payload with.
n.b. If an individual property in the update payload matches an existing property, then the property value is updated. If an individual property does not already exist in the payload, it is added.
Tip: A simple way to add all captured questions to the case payload is to use the xpertrule.getValues method. A sample function would look like...
let payload = xpertrule.getValue();
xpertrule.cases.update(#case_id.val(), payload);
All the case management functionality can also be access via the xpertrule.cases interface. The various methods are as follows...
xpertrule.cases._lastError
xpertrule.cases.add(solutionID, payloadObject, status)
xpertrule.cases.filter(solutionID, payloadFilterObject, statusFilter, expiredOnly)
xpertrule.cases.get(caseID)
xpertrule.cases.getStatus(caseID)
xpertrule.cases.setStatus(caseID, status)
xpertrule.cases.update(caseID, payloadObject)