Agent Intelligence API

Use the Agent Intelligence API to predict a field value based on one or more input fields and a trained solution.

This API can only be used when the Agent Intelligence application is activated.

Agent Intelligence API - GET now/agent_intelligence/solution/{solution_name}/prediction

Predict an output field value using a specific solution.

URL format

Default URL: /api/now/agent_intelligence/solution/{solution_name}/prediction

The URL parameter.
  • solution_name - The name of solution to use for predictions. For example, ml_incident_categorization.

Supported request parameters

Table 1. Parameters
Parameter Description
Solution definition input field key-value pair Enter the name of the solution input field as a key-value pair. For example, enter the key, short_description and the value, Unable to connect to VPN.

Headers

The following request and response headers apply to this HTTP action only, or apply to this action in a distinct way. For a list of general headers used in the REST API, see Supported REST API headers.

Table 2. Request headers
Header Description
None
Table 3. Response headers
Header Description
None

Status codes

The following status codes apply to this HTTP action. For a list of possible status codes used in the REST API, see REST response codes .

Table 4. Status codes
Status code Description
None

Response body

The API returns these JSON or XML elements in the response body to describe any prediction made.

Table 5. Elements returned in the response body
Element Description
outcome The prediction output field value. For example, an incident categorization solution would return an incident category such as inquiry.
confidence The estimated precision of the prediction as a percentage. For example, 53.84615375762915.

Sample cURL request

curl "https://instance.service-now.com/api/now/agent_intelligence/solution/ml_incident_categorization/prediction?short_description=unable%20to%20connect%20to%20VPN" \
--request GET \
--header "Accept:application/json" \
--user 'admin':'admin'
{
  "result": {
    "input": {
      "short_description": "unable to connect to VPN",
      "api": "api"
    },
    "output": {
      "outcome": "inquiry",
      "confidence": 53.84615375762915
    }
  }
}

Sample Python request

#Need to install requests package for python
#easy_install requests
import requests

# Set the request parameters
url = 'https://instance.service-now.com/api/now/agent_intelligence/solution/ml_incident_categorization/prediction?short_description=unable%20to%20connect%20to%20VPN'

# Eg. User name="admin", Password="admin" for this code sample.
user = 'admin'
pwd = 'admin'

# Set proper headers
headers = {"Content-Type":"application/json","Accept":"application/json"}

# Do the HTTP request
response = requests.get(url, auth=(user, pwd), headers=headers )

# Check for HTTP codes other than 200
if response.status_code != 200: 
    print('Status:', response.status_code, 'Headers:', response.headers, 'Error Response:',response.json())
    exit()

# Decode the JSON response into a dictionary and use the data
data = response.json()
print(data)
{
  "result": {
    "input": {
      "short_description": "unable to connect to VPN",
      "api": "api"
    },
    "output": {
      "outcome": "inquiry",
      "confidence": 53.84615375762915
    }
  }
}