Virtual Agent Bot Integration API
The Virtual Agent Bot Integration API provides endpoints that allow users to integrate any chat interface or a bot ecosystem with the ServiceNow Virtual Agent and/or Live Agent.
This API is built on the conversational custom chat integration framework provided with Virtual Agent and operates in the sn_va_as_service namespace.
For additional information on installing and configuring the Virtual Agent Bot Integration API, see Virtual Agent API.
VA Bot Integration - POST /sn_va_as_service/bot/integration
Sends a specified message, attachment, or URL to a specified secondary ServiceNow Virtual Agent (VA) bot.
A customer's site can have one or more secondary ServiceNow bots. In addition to passing messages to a ServiceNow VA secondary bot, the primary bot or chat client can use this endpoint to pass messages to an agent through Live Agent chat. Use the action parameter passed in the request body to specify how the specified content should be handled.
URL format
Default URL: /api/sn_va_as_service/bot/integration
Supported request parameters
| Name | Description |
|---|---|
| None |
| Name | Description |
|---|---|
| None |
| Name | Description |
|---|---|
| action | Action that the VA should take. Valid values:
Data type: String Default: Null |
| botToBot | Flag that indicates whether the conversation is between bots, such as between a primary bot and secondary bot. Possible values:
Data type: Boolean Default: true |
| clientSessionId | Unique client session identifier of the application/service that the end user is using to communicate with the ServiceNow bot. This ID helps identify the set of request/responses for a specific user conversation. The format of this parameter is determined by the implementer. Data type: String Default: Null |
| clientVariables | Pass-through JSON-formatted name-value pairs that are sent back in the response. These values aren't processed by the endpoint, but can be used to keep specific customer information attached to the
conversation. Data type: Object Default: Null |
| contextVariables | JSON-formatted name-value pairs that provide addition information about the user. Provide this information to customize the conversation experience. For additional information on context variables, see Define and publish chat context variables. For example: Data type: Object Default: Null |
| emailId | Required when enabling account linking, otherwise all users are considered guest users. Email address of the chat client end user, the person the bot is interacting with. For additional information on account
linking, see Link your ServiceNow user account to a messaging application for Virtual Agent conversations. Data type: String |
| history | History of the primary bot’s conversation with the user, starting with the initial request by the user. Data type: Object For example: |
| history.displayName | Name of the user to whom the message was sent. If the primary bot, pass
Bot. Data type: String |
| history.isBotMessage | Flag that indicates whether the message was sent by the primary bot. Valid values:
Data type: Boolean |
| history.type | Type of message sent. Valid values: text Data type: String |
| history.value | Content of the information. For example, the message text. Data type: String |
| intent | Describes the intent of the conversation. Provide this information when the action parameter is set to SWITCH.Data type: Object |
| intent.id | NLU Intent ID of the system topic to switch the conversation to. The intent.id is resolved based on the language passed in the chat session. If no language is passed when
starting a conversation, it obtains the language from the user's session/profile. Data type: String Table: CS Topic Language [sys_cs_topic_language] |
| message | Required. Details of the message to send to the ServiceNow bot. Data type: Object |
| message.attachment | Required if sending attachments. Details of each attachment to send. You can only pass attachments as a URL. A virus scan is triggered on all attachments. There is no restriction on the size of an attachment, however, large files can take significant time to transfer. Data type: Array of Objects |
| message.attachment.clientAttachmentId | Unique identifier of the attachment to send to the ServiceNow bot. The format of this identifier is determined by the implementer. Data type: String Default: Null |
| message.attachment.contentType | Required if attachment specified. Standard mime type of the attachment. Valid values (not case-sensitive):
Data type: String |
| message.attachment.fileName | Required if attachment specified. File name of the attachment. Data type: String |
| message.attachment.headers | Additional information needed if the attachment file is private and
protected. Data type: Object |
| message.attachment.headers.Authorization | Information needed to obtain authorization to access the attachment, such as a
user name and password. Data type: String |
| message.attachment.url | Required if attachment specified. URL where the attachment is located. The VA obtains the attachment from this URL, runs a virus scan, and then processes the file. If the attachment isn't a public file, you must
pass an message.attachment.header object that contains the authorization information so that the attachment can be accessed. You must also ensure that URL domain is present in the trusted domains filed
in sys_cs_provider. Data type: String |
| message.clientMessageId | Unique alphanumeric identifier for the message. The format of this identifier is determined by the implementer. Data type: String Default: Null |
| message.text | Required if attachment parameter isn't specified. Message text. The language of the message should be passed in the contextVariables parameter. Data type: String Maximum length: Unlimited |
| message.typed | Required. Flag that indicates whether the message was typed in or was an option selection (selected). Valid values:
Data type: Boolean |
| requestId | Required. Unique alphanumeric identifier for this request. The format of this
identifier is determined by the implementer. Data type: String |
| silentMessage | Flag that indicates whether this is a silent message. A silent message is a message that doesn’t require a response. Valid values:
Note: If a request with silentMessage = true is sent, all subsequent bot messages remain suppressed until a request to turn off silent mode is sent by passing silentMessage = false.Data type: Boolean Default: false |
| timestamp | Unix epoch time when the message was sent from the end user of the chat client. Data type: Number Unit: Milliseconds Default: Current time |
| timezone | GMT time zone of the end user of the chat client. For example: For a list of the available time zone values, see https://en.wikipedia.org/wiki/List_of_tz_database_time_zones. Data type: String Default: GMT time zone of the ServiceNow instance. |
| topic | Required if the user wants to switch to a particular topic by specifying a topic name. Name-value pair of the topic to switch to. You can either specify the topic name or the topic sys_id. Note: You can only specify a single topic name or id in the object. Data type: Object For example: |
| topic.name | Name of the topic to switch to. Data type: String Table: In the name field of the Virtual Agent topics [sys_cs_topic] table. |
| topic.id | Sys_id of the topic to switch to. Data type: String Table: Virtual Agent topics [sys_cs_topic] |
| userId | Required. Unique user identifier. This is the identifier of the end user who is interacting with the bot. Data type: String |
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.
| Header | Description |
|---|---|
| Accept | Data format of the response body. Only supports application/json. |
| Content-Type | Data format of the request body. Only supports application/json. |
| token | Required if using token-based authentication; optional for Basic or OAuth authentication. Authentication token to use if token authentication has been set up for this endpoint. Data type: String |
| 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 API HTTP response codes.
| Status code | Description |
|---|---|
| 200 | Successful. The request was successfully processed. If you receive a 200 status code, but don’t receive a response back, check the following things:
|
| 400 | Bad Request. A bad request type or malformed request was detected. |
| 401 | Unauthorized. The user credentials are incorrect or have not been passed. |
| 405 | Invalid method. The functionality is disabled. |
| 500 | Internal server error. An unexpected error occurred while processing the request. The response contains additional information about the error. |
Response body parameters
Status of the endpoint call. This is sent in response when the initial call request is received. The request hasn’t yet been processed.
| Name | Description |
|---|---|
| error | Description of the detected error. Only returned if an error occurs. Data type: Object |
| error.detail | Details about the encountered error. Data type: String |
| error.message | Error message thrown. Data type: String |
| status | Status of the endpoint call. Valid values:
Data type: String |
VA response body parameters
Response body sent from the VA to the configured response endpoint.
| Name | Description |
|---|---|
| agentChat | Flag that indicates whether the conversation is connected to the ServiceNow
Live Agent. Possible values:
Data type: Boolean |
| body | List of objects that describe the elements of the response message body. Data type: Array of Objects |
| body.actionType | Type of action message dispatched by the secondary bot to the primary bot. For example, typing indicator or agent wait time. Possible values:
For example: Sending Sending Data type: String |
| body.agentInfo | If enabled in the agent chat setup, the name and avatar of the associated agent. Data type: Object For example: |
| body.agentInfo.agentAvatar | URL of the agent's associated avatar file. For example: "https://instance.servicenow.com/ee4eebf30a0004d963b5c5ac0d734dc4.iix?t=small" Data type: String |
| body.agentInfo.agentName | Display name of the agent. Data type: String |
| body.agentInfo.sentFromAgent | Flag that indicates whether the message was sent by a live agent. Possible values:
Data type: Boolean |
| body.data | JSON string that defines the data within the card. Data type: String |
| body.group | Rich control group to which the body element belongs. You can further transform these default controls by writing outbound transformation scripts. For additional information on these scripts, see Virtual Agent action scripts. Possible values:
Data type: String |
| body.header | Link header. Data type: String |
| body.height | Height of the HTML element. Data type: Number Unit: Pixels |
| body.itemType | Type of body element. Possible values: (case-sensitive)
Data type: String |
| body.label | Label to display for the associated element. Data type: String |
| body.maskType | Sensitivity of the associated data. Possible values:
Data type: String |
| body.maxCount | Only returned when uiType is FileUpload. Maximum number of attachments that can be uploaded at one time.Data type: Number (Integer) |
| body.maxSize | Only returned when uiType is FileUpload. Maximum size of the attachment that can be uploaded.Data type: Number (Integer) Unit: Megabytes |
| body.message | Only returned when actionType is
StartSpinner. Message to display to user.Data type: String |
| body.multiSelect | Flag that indicates whether the user can select multiple options. Possible values:
Data type: Boolean |
| body.nluTextEnabled | Flag that indicates whether the user chat client can receive Natural Language Understanding (NLU) text messages. Possible values:
Data type: Boolean |
| body.options | List that describes the options available for a picker control. Data type: Array of Objects |
| body.options.attachment | URL of the image in the carousel to retrieve. Data type: String |
| body.options.description | Description of the carousel item. Data type: String |
| body.options.enabled | Flag that indicates whether the picker control is enabled on the end user's chat client. In bot-to-bot implementations, the primary bot is responsible for ensuring the picker control is disabled. Possible values:
Data type: Boolean |
| body.options.label | Label to display for the associated body.options.value
parameter. Data type: String |
| body.options.renderStyle | Style to use when rendering the associated element. Possible value: data Data type: String |
| body.options.value | Value to display for the associated body.options.label
parameter. Data type: String |
| body.promptMsg | Prompt message to display with the picker control. Data type: String |
| body.required | Flag that indicates whether the end user must respond to the query in the body element. Possible values:
Data type: Boolean |
| body.spinnerType | Only returned when actionType is StartSpinner. Type of spinner shown to chat user.Possible values: wait_time: Message indicating the amount of delay before being transferred to a live agent. Data type: String |
| body.style | Style of body element. Possible values:
Data type: String |
| body.templateName | Name of the template to use to display the associated card. Data type: String |
| body.type | Only returned for DefaultOutputLink. Type of return data. Possible values: link Data type: String |
| body.uiType | Type of body element. The possible values depend on the value in the body.group parameter. These values map back to the controls defined in the Virtual Agent Designer. For more information,
see Getting started with Virtual Agent Designer. Possible values:
Data type: String |
| body.value | Data to use to process the body element. The type of information that is passed back depends on the type of body element. OutputLink: Object. OutputImage: String. Image URL. OutputHtml: String. HTML that the client needs to render. Data type: String or Object |
| body.value.action | Only returned for DefaultOutputLink. URL of returned link. Data type: String |
| body.waitTime | Amount of time that the user has to wait before being connected to a live
agent. Data type: String |
| body.width | Width of the associated HTML element. Data type: Number Unit: Pixels |
| clientSessionId | Unique client session identifier of the chat application/service that the end user is using to communicate with the ServiceNow bot. Data type: String |
| clientVariables | JSON-formatted name-value pairs that are copied from what is passed in the clientVariables parameter in the request body. These values aren’t processed by the endpoint, but can be used to
keep specific customer information attached to the conversation. Data type: Object |
| completed | Flag that indicates whether the ServiceNow
Virtual Agent has successfully completed the conversation. Possible values:
Data type: Boolean |
| enterpriseId | Currently unused. |
| message | Details of the message sent to the ServiceNow VA. This is the same as the passed in message object. Data type: Object |
| message.attachment | Details of the attachment. Attachments can be either a file or a URL. Data type: Object |
| message.attachment.clientAttachmentId | Unique identifier of the attachment sent to the ServiceNow VA. The format of this identifier is determined by the implementer. Data type: String |
| message.attachment.contentType | Standard mime type of the attachment. Possible values (not case-sensitive):
Data type: String |
| message.attachment.fileName | File name of the attachment. Data type: String |
| message.attachment.url | URL where the attachment is located. Data type: String |
| message.clientMessageId | Unique alphanumeric identifier for the message. Data type: String |
| message.text | Message text. Data type: String Maximum length: Unlimited |
| message.typed | Flag that indicates whether the message was typed in or was an option selection (selected). Possible values:
Data type: Boolean |
| nowBotId | Currently unused. |
| nowSessionId | Currently unused. |
| requestId | Unique identifier for this request. Data type: String |
| score | Intent confidence score from the ServiceNow
NLU model, specified as a percent, such as 87.3%. This score enables the primary bot to make the decision whether to surface the associated intent based on the primary bot’s NLU model’s confidence threshold. The ServiceNow
NLU model’s confidence threshold is ignored on the ServiceNow instance so that the primary bot’s NLU model’s confidence threshold can be consistently applied across all secondary bots. Data type: Number |
| takeControl | Flag that indicates that the ServiceNow
Virtual Agent wants to hand control back over to the primary bot. Possible values:
Data type: Boolean Default: false |
| userId | Identifier of the end user who is interacting with the bot. Data type: String |
Start a conversation using the START_CONVERSATION action to start a conversation
The following example shows how to use the START_CONVERSATION action to start a conversation with Virtual Agent. This call directs the user to the greeting topic.
curl "https://instance.servicenow.com/api/sn_va_as_service/bot/integration" \
--request POST \
--header "Accept:application/json" \
--header "Content-Type:application/json" \
--data "{
"requestId": "asd2423-sda23-qwe23-we23",
"action": "START_CONVERSATION",
"enterpriseId": "ServiceNow",
"nowBotId": "A85PWLERF",
"clientSessionId": "",
"nowSessionId": "",
"message":{
"text": "",
"typed": true,
"clientMessageId": "ABC-123"
},
"userId": "beth.anglin",
"emailId": "beth.anglin@example.com",
"timestamp": 1588824102,
"timezone": "America/New_York"
}"
--user "username":"password"
The following is the response body sent from the VA to the configured response endpoint.
{
"requestId":"asd2423-sda23-qwe23-we23",
"clientSessionId":"",
"nowSessionId":"",
"message":{
"text":"",
"typed":true,
"clientMessageId":"ABC-123"
},
"userId":"beth.anglin",
"body":[
{
"uiType":"OutputText",
"group":"DefaultText",
"value":"Hi, I'm your Virtual Agent. Let me know how I can help you today.",
"maskType":"NONE"
},
{
"uiType":"TopicPickerControl",
"group":"DefaultPicker",
"nluTextEnabled":false,
"promptMsg":"Hi guest, please enter your request or make a selection of what I can help with. You can type help any time when you need help.",
"label":"Show me everything",
"options":[
{
"label":"b2b topic",
"value":"2bb7bd7670de6010f877c7f188266fc7",
"enabled":true
},
{
"label":"Live Agent Support.",
"value":"ce2ee85053130010cf8cddeeff7b12bf",
"enabled":true
}
]
}
],
"score":1
}
Transfer a conversation to Live Agent using utterance
The following example illustrates how to transfer a conversation to Live Agent, bypassing the greeting topic, by passing agent as an utterance in the
message.text parameter. Possible utterance values are defined in the
sys_cs_contextual_action table. For additional information on contextual actions, see Contextual actions for custom chat
integrations.
curl "https://instance.servicenow.com/api/sn_va_as_service/bot/integration" \
--request POST \
--header "Accept:application/json" \
--header "Content-Type:application/json" \
--header "token: ORANGE" \
--data " {
"requestId": "322bas2be70-sadsa-we32-3eq2-1231ra9",
"botToBot": true,
"clientSessionId": "",
"silentMessage": false,
"message":{
"text": "agent",
"typed": true
},
"userId": "abel.tuter",
"emailId": "abel.tuter@servicenow.com",
"timestamp": 1588824102,
"timezone": "America/New_York"
}"
The following is the response body sent from the VA to the configured response endpoint.
{
"requestId":"322bas2be70-sadsa-we32-3eq2-1231ra9",
"clientSessionId":"",
"message":{
"text":"agent",
"typed":true
},
"userId":"abel.tuter",
"body":[
{
"uiType":"Picker",
"group":"DefaultPicker",
"required":true,
"nluTextEnabled":false,
"label":"I want to be sure I got this right. What item best describes what you want to do?",
"itemType":"List",
"style":"list",
"multiSelect":false,
"options":[
{
"label":"Live Agent Support.",
"value":"Live Agent Support.",
"renderStyle":"data",
"enabled":false
},
{
"label":"Virtual Agent Capabilities.",
"value":"Virtual Agent Capabilities.",
"renderStyle":"data",
"enabled":false
},
{
"label":"I want something else",
"value":"-1",
"renderStyle":"data",
"enabled":false
}
],
"scriptedData":null
}
],
"score":1
}
Transfer a conversation to Live Agent Support based on the user's selection
The following example shows transferring the conversation to Live Agent Support based on the user's selection from the prior interaction.
curl "https://instance.servicenow.com/api/sn_va_as_service/bot/integration" \
--request POST \
--header "Accept:application/json" \
--header "Content-Type:application/json" \
--header "token: ORANGE" \
--data "{
"requestId": "322bas2be70-sadsa-we32-3eq2-1231ra9",
"botToBot": true,
"clientSessionId": "",
"silentMessage": false,
"message":{
"text": "Live Agent Support.",
"typed": true
},
"userId": "abel.tuter",
"emailId": "abel.tuter@servicenow.com",
"timestamp": 1588824102,
"timezone": "America/New_York"
} "
The following is the response body sent from the VA to the configured response endpoint.
{
"requestId":"322bas2be70-sadsa-we32-3eq2-1231ra9",
"clientSessionId":"",
"message":{
"text":"Live Agent Support.",
"typed":true
},
"userId":"abel.tuter",
"body":[
{
"uiType":"OutputText",
"group":"DefaultText",
"value":"Please stand by while I connect you to a live agent."
}
],
"agentChat":true,
"score":1
}
End a Virtual Agent conversation by setting the action parameter
The following example shows how to end a Virtual Agent conversation by
setting the action parameter to END_CONVERSATION.
curl "https://instance.servicenow.com/api/sn_va_as_service/bot/integration" \
--request POST \
--header "Accept:application/json" \
--header "Content-Type:application/json" \
--data "{
"requestId": "s345ew-sjg554-qwe23-we23",
"action": "END_CONVERSATION",
"enterpriseId": "ServiceNow",
"nowBotId": "A85PWLERF",
"clientSessionId": "",
"nowSessionId": "",
"message":{
"text": "b2b topic",
"typed": true,
"clientMessageId": "ABC-123"
},
"userId": "beth.anglin",
"emailId": beth.anglin@example.com,
"timestamp": 1588824102,
"timezone": "America/New_York"
}"
--user "username":"password"
The following is the response body sent from the VA to the configured response endpoint showing the conversation ended.
{
"requestId":"s345ew-sjg554-qwe23-we23",
"clientSessionId":"",
"nowSessionId":"",
"message":{
"text":"",
"typed":true,
"clientMessageId":"ABC-123"
},
"userId":"beth.anglin",
"body":[
{
"uiType":"OutputText",
"group":"DefaultText",
"value":"The conversation has ended. If you need help again, type hi.",
"maskType":"NONE"
}
],
"score":1
}
End a Live Agent conversation by setting the action parameter
The following example shows how to end a Live Agent conversation by setting
the action parameter to END_CONVERSATION.
curl "https://instance.servicenow.com/api/sn_va_as_service/bot/integration" \
--request POST \
--header "Accept:application/json" \
--header "Content-Type:application/json" \
--data "{
"requestId": "sad-sjg554-qwe23-we23",
"action": "END_CONVERSATION",
"enterpriseId": "ServiceNow",
"nowBotId": "A85PWLERF",
"clientSessionId": "",
"nowSessionId": "",
"message":{
"text": "",
"typed": true,
"clientMessageId": "ABC-123"
},
"userId": "beth.anglin",
"emailId": "beth.anglin@example.com",
"timestamp": 1588824102,
"timezone": "America/New_York"
}"
--user "username":"password"
The following is the response body sent from the VA to the configured response endpoint showing the conversation ended.
{
"requestId":"sad-sjg554-qwe23-we23",
"clientSessionId":"",
"nowSessionId":"",
"message":{
"text":"",
"typed":true,
"clientMessageId":"ABC-123"
},
"userId":"beth.anglin",
"body":[
{
"uiType":"OutputText",
"group":"DefaultText",
"value":"The conversation has ended. If you need help again, type hi.",
"maskType":"NONE"
}
],
"completed":true,
"score":1
}
Use commands defined in the sys_cs_contextual_action table as an utterance to start a conversation with Virtual Agent
The following example shows how to use the Hi command defined in the
sys_cs_contextual_action table as an utterance to start a conversation with Virtual Agent instead of setting the action parameter to
START_CONVERSATION as shown in prior examples. This example shows using
one of the language variants of the Hi command, "hola".
curl "https://instance.servicenow.com/api/sn_va_as_service/bot/integration" \
--request POST \
--header "Accept:application/json" \
--header "Content-Type:application/json" \
--header "token: ORANGE" \
--data "{
"requestId": "302bas2be70-sadsa-we32-3eq2-1231ra9",
"botToBot": true,
"clientSessionId": "",
"silentMessage": false,
"message":{
"text": "hola",
"typed": true
},
"userId": "fred.ludy",
"emailId": "abel.tuter@servicenow.com",
"timestamp": 1588824102,
"timezone": "America/New_York"
}"
The following is the response body sent from the VA to the configured response endpoint.
{
"requestId":"302bas2be70-sadsa-we32-3eq2-1231ra9",
"clientSessionId":"",
"message":{
"text":"hola",
"typed":true
},
"userId":"fred.ludy",
"body":[
{
"uiType":"OutputText",
"group":"DefaultText",
"value":"Hi, I'm your Virtual Agent. Let me know how I can help you today.",
"maskType":"NONE"
},
{
"uiType":"TopicPickerControl",
"group":"DefaultPicker",
"nluTextEnabled":false,
"promptMsg":"Hi guest, please enter your request or make a selection of what I can help with. You can type hellllp! any time when you need help.",
"label":"Show me everything",
"options":[
{
"label":"boolean check",
"value":"1b5257a1db712010d3d6d9595e9619f3",
"enabled":true
},
{
"label":"Test_table_datepicker",
"value":"6515f0cadb4220108249f7541d961980",
"enabled":true
},
{
"label":"Test File upload",
"value":"76c1f4b2db7520108249f7541d9619a7",
"enabled":true
},
{
"label":"Test B2B 2",
"value":"8373e55cdb8120108249f7541d96196d",
"enabled":true
},
{
"label":"FAQ Conversation Builder_Global",
"value":"9f3114a3dbc520108249f7541d961981",
"enabled":true
},
{
"label":"Get to know you",
"value":"a443dd6adb812010d3d6d9595e961954",
"enabled":true
},
{
"label":"Get to know you_Global",
"value":"b1a56b87db8120108249f7541d9619b2",
"enabled":true
},
{
"label":"Live Agent Support.",
"value":"ce2ee85053130010cf8cddeeff7b12bf",
"enabled":true
},
{
"label":"Apply for PTO_B2B NLU",
"value":"d948c94cdb052010d3d6d9595e961969",
"enabled":true
}
]
}
],
"score":1
}
Use commands defined in the sys_cs_contextual_action table as an utterance to end a conversation
The following example shows how to use the Bye command defined in the
sys_cs_contextual_action table as an utterance to end a conversation with Virtual Agent instead of setting action to
END_CONVERSATION as shown in prior examples. This example shows using one
of the language variants of the Bye command, "choa".
curl "https://instance.servicenow.com/api/sn_va_as_service/bot/integration" \
--request POST \
--header "Accept:application/json" \
--header "Content-Type:application/json" \
--header "token: ORANGE" \
--data "{
"requestId": "302bas2be70-sadsa-we32-3eq2-1231ra9",
"botToBot": true,
"clientSessionId": "",
"silentMessage": false,
"message":{
"text": "choa",
"typed": true
},
"userId": "fred.ludy",
"emailId": "abel.tuter@servicenow.com",
"timestamp": 1588824102,
"timezone": "America/New_York"
}"
The following is the response body sent from the VA to the configured response endpoint.
{
"requestId":"302bas2be70-sadsa-we32-3eq2-1231ra9",
"clientSessionId":"",
"message":{
"text":"chao",
"typed":true
},
"userId":"fred.ludy",
"body":[
{
"uiType":"Picker",
"group":"DefaultPicker",
"required":true,
"nluTextEnabled":false,
"label":"Please make a selection.",
"itemType":"List",
"style":"list",
"multiSelect":false,
"options":[
{
"label":"End conversation",
"value":"1",
"renderStyle":"data",
"enabled":false
},
{
"label":"Cancel",
"value":"0",
"renderStyle":"data",
"enabled":false
}
],
"scriptedData":null
}
],
"score":1
}
Change an ongoing conversation using the SWITCH action parameter
The following example shows how to use the SWITCH
action parameter to change an ongoing conversation to the topic that
matches what is specified in the intent.id parameter.
curl "https://instance.servicenow.com/api/sn_va_as_service/bot/integration" \
--request POST \
--header "Accept:application/json" \
--header "Content-Type:application/json" \
--data "{
"requestId": "sdfsfs-hgfhg-34fssd-zxcz-sd43",
"enterpriseId": "ServiceNow",
"nowBotId": "A85PWLERF",
"clientSessionId": "",
"nowSessionId": "",
"action": "SWITCH",
"intent" : {
"id": "Saloon Vehicle"
},
"message":{
"typed": true,
"clientMessageId": "ABC-123"
},
"userId": "Guest",
"timestamp": 1588824102,
"timezone": "America/New_York"
}"
--user "username":"password"
The following is the response body sent from the VA to the configured response endpoint showing the VA switched to the new topic.
{
"requestId":"sdfsfs-hgfhg-34fssd-zxcz-sd43",
"clientSessionId":"",
"nowSessionId":"",
"message":{
"typed":true,
"clientMessageId":"ABC-123"
},
"userId":"Guest",
"body":[
{
"uiType":"InputText",
"group":"DefaultText",
"required":true,
"nluTextEnabled":false,
"label":"limo input:",
"maskType":"NONE"
}
],
"score":1
}
Obtain a Natural Language Understanding (NLU) confidence score for an utterance
The following example shows how to obtain a NLU confidence score for an utterance if NLU is enabled in VA.
curl "https://instance.servicenow.com/api/sn_va_as_service/bot/integration" \
--request POST \
--header "Accept:application/json" \
--header "Content-Type:application/json" \
--data "{
"requestId": "sdfsfs-hgfhg-34fssd-zxcz-sd43",
"enterpriseId": "ServiceNow",
"nowBotId": "A85PWLERF",
"clientSessionId": "",
"nowSessionId": "",
"message":{
"text": "most popular choice",
"typed": true,
"clientMessageId": "ABC-123"
},
"userId": "Guest",
"timestamp": 1588824102,
"timezone": "America/New_York"
}"
--user "username":"password"
The following is the response body sent from the VA to the configured response endpoint showing the NLU confidence score.
{
"requestId":"sdfsfs-hgfhg-34fssd-zxcz-sd43",
"clientSessionId":"",
"nowSessionId":"",
"message":{
"text":"most popular choice",
"typed":true,
"clientMessageId":"ABC-123"
},
"userId":"Guest",
"body":[
{
"uiType":"InputText",
"group":"DefaultText",
"required":true,
"nluTextEnabled":false,
"label":"model input:",
"maskType":"NONE"
}
],
"score":"0.92"
}
Transfer a conversation to Live Agent in a specific queue
The following example shows how to transfer a conversation to Live Agent in a specific queue. You must first set up your queues with specific conditions. You then pass those conditions as contextVariables in the request body. For additional information on creating a work item queue, see Create a work item queue.
curl "https://instance.servicenow.com/api/sn_va_as_service/bot/integration" \
--request POST \
--header "Accept:application/json" \
--header "Content-Type:application/json" \
--data "{
"requestId": "34re-dasd-qwe23-dsds", // Unique value for a message (hash)
"enterpriseId": "ServiceNow", // ServiceNow (Optional
"nowBotId": "A85PWLERF", // In case of multiple ServiceNow secondary bots (one for HR, one for ITSM)
"action":"AGENT", // Actions to close conversation. Other possible value is END_CONVERSATION
"clientSessionId": "", // Client conversation id
"nowSessionId": "", // ServiceNow conversation id
"message":{
"text": "How are you?", // User passed message
"typed": true, // typed or clicked
"clientMessageId": "ABC-123"
},
"userId": "abraham.lincoln", // User’s id in their system
"emailId": "abraham.lincoln@example.com",
"timestamp": 1588824102,
"timezone": "America/New_York",
"contextVariables":{
"b2b_category":"humanresource"
}
}"
--user "username":"password"
The following is the response body sent from the VA to the configured response endpoint.
{
"requestId":"34re-dasd-qwe23-dsds",
"clientSessionId":"",
"nowSessionId":"",
"message":{
"text":"How are you?",
"typed":true,
"clientMessageId":"ABC-123"
},
"userId":"abraham.lincoln",
"body":[
{
"uiType":"OutputText",
"group":"DefaultText",
"value":"I am sorry but I didn't understand your request.",
"maskType":"NONE"
},
{
"uiType":"OutputText",
"group":"DefaultText",
"value":"Please try giving me your request in a different way. I'm currently better at understanding short sentences.",
"maskType":"NONE"
},
{
"uiType":"TopicPickerControl",
"group":"DefaultPicker",
"nluTextEnabled":false,
"promptMsg":"Hi guest, please enter your request or make a selection of what I can help with. You can type help any time when you need help.",
"label":"Show me everything",
"options":[
{
"label":"Live Agent Support.",
"value":"ce2ee85053130010cf8cddeeff7b12bf",
"enabled":true
}
]
}
],
"score":0
}
Transfer a public application/pdf attachment file
This example shows how to transfer a public application/pdf attachment.
curl "https://instance.servicenow.com/api/sn_va_as_service/bot/integration" \
--request POST \
--header "Accept:application/json" \
--header "Content-Type:application/json" \
--header "token: BOT_Token" \
--data "{
"requestId": "f42f3550-5b44-4cde-aa52-9b6756b3131c",
"clientSessionId": "U94CSJLEN",
"message": {
"attachment": {
"clientAttachmentId": "my-unique-identifier",
"contentType": "application/pdf",
"fileName": "MY PDF TEST",
"url": "http://www.africau.edu/images/default/sample.pdf"
}
},
"userId": "U94CSJLEN",
"emailId": "admin@example.com"
}"
--user "username":"password"
The following is the response body sent from the VA to the configured response endpoint.
{
"requestId":"f42f3550-5b44-4cde-aa52-9b6756b3131c",
"clientSessionId":"U94CSJLEN",
"message":{
"attachment":{
"clientAttachmentId":"my-unique-identifier",
"contentType":"application/pdf",
"fileName":"MY PDF TEST",
"url":"http://www.africau.edu/images/default/sample.pdf"}
},
"userId":"U94CSJLEN",
"body":[
{
"uiType":"OutputText",
"group":"DefaultText",
"required":false,
"nluTextEnabled":false,
"label":"File got",
"maskType":"NONE",
"itemType":"outputtext"
},
{
"uiType":"OutputText",
"group":"DefaultText",
"required":false,
"nluTextEnabled":false,
"label":"The conversation has ended. If you need help again, type hi.",
"maskType":"NONE",
"itemType":"outputtext"
}
],
"completed":true,
"score":1
}
Transfer a video/mpeg attachment
This example shows the request/response for uploading a video/mpeg attachment.
curl "https://instance.servicenow.com/api/sn_va_as_service/bot/integration" \
--request POST \
--header "Accept:application/json" \
--header "Content-Type:application/json" \
--header "token: BOT_TOKEN" \
--data "{
"requestId": "f42f3550-5b44-4cde-aa52-9b6756b3131c",
"clientSessionId": "U94CSJLEN",
"message": {
"attachment": {
"clientAttachmentId": "my-unique-identifier10",
"contentType": "video/mpeg",
"fileName": "MY TEST10.mp4",
"url": "https://sample-videos.com/video123/mp4/720/big_buck_bunny_720p_1mb.mp4"
}
},
"userId": "U94CSJLEN",
"emailId": "admin@example.com"
}"
--user "username":"password"
The following is the response body sent from the VA to the configured response endpoint.
{
"requestId":"f42f3550-5b44-4cde-aa52-9b6756b3131c",
"clientSessionId":"U94CSJLEN",
"message":{
"attachment":{
"headers":{
"Authorization":"Basic amFzbWluZS53YWRod2FuaWE6VGVzdGluZ0AxMjM="
},
"clientAttachmentId":"my-unique-identifier10",
"contentType":"video/mpeg",
"fileName":"MY TEST10.mp4",
"url":"https://sample-videos.com/video123/mp4/720/big_buck_bunny_720p_1mb.mp4"
}
},
"userId":"U94CSJLEN",
"body":[
{
"uiType":"OutputText",
"group":"DefaultText",
"required":false,
"nluTextEnabled":false,
"label":"File got",
"maskType":"NONE",
"itemType":"outputtext"
},
{
"uiType":"OutputText",
"group":"DefaultText",
"required":false,
"nluTextEnabled":false,
"label":"The conversation has ended. If you need help again, type hi.",
"maskType":"NONE","itemType":"outputtext"
}
],
"completed":true,
"score":1
}
Transfer a image/jpeg attachment
This example shows the request/response for uploading a image/jpeg attachment.
curl "https://instance.servicenow.com/api/sn_va_as_service/bot/integration" \
--request POST \
--header "Accept:application/json" \
--header "Content-Type:application/json" \
--header "token: BOT_TOKEN" \
--data "{
"requestId": "f42f3550-5b44-4cde-aa52-9b6756b3131c",
"clientSessionId": "U94CSJLEN",
"message": {
"attachment": {
"clientAttachmentId": "my-unique-identifier10",
"contentType": "image/jpeg",
"fileName": "MY TEST10.jpg",
"url": "https://image.imagestock.com/image-photo/pink-butterfly-isolated-on-white-260nw-1218104047.jpg"
}
},
"userId": "U94CSJLEN",
"emailId": "admin@example.com"
}"
--user "username":"password"
The following is the response body sent from the VA to the configured response endpoint.
{
"requestId":"f42f3550-5b44-4cde-aa52-9b6756b3131c",
"clientSessionId":"U94CSJLEN",
"message":{
"attachment":{
"headers":{
"Authorization":"Basic amFzbWluZS53YWRod2FuaWE6VGVzdGluZ0AxMjM="
},
"clientAttachmentId":"my-unique-identifier10",
"contentType":"image/jpeg",
"fileName":"MY TEST10.jpg",
"url":"https://image.imagestock.com/image-photo/pink-butterfly-isolated-on-white-260nw-1218104047.jpg"
}
},
"userId":"U94CSJLEN",
"body":[
{
"uiType":"OutputText",
"group":"DefaultText",
"required":false,
"nluTextEnabled":false,
"label":"File got",
"maskType":"NONE",
"itemType":"outputtext"
},
{
"uiType":"OutputText",
"group":"DefaultText",
"required":false,
"nluTextEnabled":false,
"label":"The conversation has ended. If you need help again, type hi.",
"maskType":"NONE",
"itemType":"outputtext"
}
],
"completed":true,
"score":1
}