---
agentTools:
  projectIndex: https://docs.sofi.ai/llms.txt
---

# Enabling Predictions on Forms

Following these steps to enable Sofi Service Agent Predictions on a ServiceNow Form  such as the Incident form.

[block:api-header]
{
  "type": "basic",
  "title": "1. Create Classifier Context"
}
[/block]

**Navigate to Sofi > Configuration > Classifier Context**

*Classifier contexts* define how a Classifier should behave in different contexts. Where a context is the the means by which a Classifier is triggered. There For example, a **UI** context is when the Classifier is trigger via a client script on  ServiceNow form (eg Incident form). An **email** context when the classifier is trigger via a record generated by an InBound Email action.

[block:parameters]
{
  "data": {
    "h-0": "Field",
    "h-1": "Description",
    "0-0": "Context",
    "0-1": "The type of the context. Options are:\n  * UI - context for records generated by forms\n  * Email - context for records generated by Inbound email actions \n  * SVA - context for records generated by the Sofi Virtual Agent",
    "2-0": "Classifier",
    "2-1": "The classifier that this context relates to.",
    "3-0": "Auto classify",
    "3-1": "If active, predictions will automatically be applied  to the target record if the *Auto classify threshold* value is met or exceeded.",
    "4-0": "Auto classify threshold",
    "4-1": "The confidence value of a classifier prediction result that must be achieved in order for the prediction result to be automatically applied.",
    "5-0": "Minimum confidence",
    "5-1": "The minimum confidence value that must be achieved for a prediction result to be displayed. Default value is 0.",
    "1-0": "Description",
    "1-1": "The description of the classifier context."
  },
  "cols": 2,
  "rows": 6
}
[/block]

[block:callout]
{
  "type": "success",
  "title": "Example Classifier Context",
  "body": "Incident Classifier UI Context"
}
[/block]

[block:image]
{
  "images": [
    {
      "image": [
        "https://files.readme.io/6822698-Sofi_Classifier_Context.png",
        "Sofi_Classifier_Context.png",
        2012,
        800,
        "#f3f4f5"
      ],
      "caption": "Classifier Context - Incident UI"
    }
  ]
}
[/block]

[block:api-header]
{
  "title": "2. Configure Client Scripts and Business Rules"
}
[/block]

A Classifier requires a number client scripts and business rules to trigger and control the behaviour of the classifier.

### Default Client Scripts

[block:parameters]
{
  "data": {
    "h-0": "Name",
    "h-1": "Description",
    "0-0": "SoapboxAIClient",
    "1-0": "(SBxAI) Inc - Short description update",
    "1-1": "OnChange client script that triggers Sofi and renders the results on the form. \nBy default, Sofi is triggered as the user enters keystrokes in the Short Description field.\n\nFor new classifiers it is recommended to duplicate and rename this Client Script.",
    "0-1": "OnLoad, global script to allow all task inheriting tables to use the SoapboxAI classifiers. Will not do anything at all if a corresponding configuration for the table is not found. The configuration is provided on the Service-now Scratchpad variable by a related 'Display' business rule. If the display business rule is not fired, or does not find any configuration, this script will not do anything."
  },
  "cols": 2,
  "rows": 2
}
[/block]

For Classifiers relating to tables extended from the Task table, you only need to create (or update if you are modifying an out of the box classifier) the 'Tigger' client script:

**(SBxAI) Inc - Short description update**
This script triggers the Incident classifier and knowledge classifier when the user enter's characters into the Short Description field.

[block:image]
{
  "images": [
    {
      "image": [
        "https://files.readme.io/50fd8b1-Classifier_Trigger_Client_Script.png",
        "Classifier_Trigger_Client_Script.png",
        2016,
        1366,
        "#f8f8f9"
      ],
      "caption": "Default Incident Classifier Trigger Client script"
    }
  ]
}
[/block]

[block:code]
{
  "codes": [
    {
      "code": "function onChange(control, oldValue, newValue, isLoading, isTemplate) {\n\tif (window.SoapboxAIClient) {\n\t\tSoapboxAIClient.onChange(control, isLoading, {\n\t\t\tclassifier: \"incident\", // <== Update Classifier Name as required\n\t\t\tknowledge: \"knowledge\",\n\t\t\t// template: \"incident.template\", // <== Comment out template if not configured\n\t\t\tleading: true\n\t\t});\n\t} else {\n\t\tjslog(\"Can't find client\");\t\n\t}\n}",
      "language": "javascript",
      "name": "(SBxAI) Inc - Short description update"
    }
  ]
}
[/block]

### Default Business Rules

[block:callout]
{
  "type": "danger",
  "title": "For non-task extended tables",
  "body": "When creating a classifier for a table NOT extended from the Task table, you will need to copy the two client scripts and three business rules and change the Table reference to the new table."
}
[/block]

[block:parameters]
{
  "data": {
    "h-0": "Name",
    "h-1": "Description",
    "0-0": "(SBxAI) Task: Configure client",
    "1-0": "(SBxAI) Task: Trigger indexing",
    "2-0": "(SBxAI) Task: Metrics updated_on",
    "0-1": "When creating a classifier for a table NOT extended from the TASK table, you will need to copy this business rule and change the Table reference to the new table. \n\nOtherwise, no change is required.",
    "1-1": "When creating a classifier for a table NOT extended from the TASK table, you will need to copy this business rule and change the Table reference to the new table. \n\nOtherwise, no change is required.",
    "2-1": "When creating a classifier for a table NOT extended from the TASK table, you will need to copy this business rule and change the Table reference to the new table. \n\nOtherwise, no change is required."
  },
  "cols": 2,
  "rows": 3
}
[/block]

[block:api-header]
{
  "title": "3. Enable Sofi on a user's profile"
}
[/block]

The Sofi Service Agent Assistant is enabled on a users' account using the role sbxai\_classification.

**Note**: When adding a role to a user account in ServiceNow you will be required to log out and log back in before the new role will take affect.