How to extend async calls that Servicenow sends to a third-party chat endpoint.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2024 11:29 PM - edited 06-13-2024 11:40 PM
The situation is as follows: we have integrated Virtual Agent Chat with a third-party chat. Everything works.
But now we need to add our own additional value in JSON-Response which will change depending on the dialog state.
For integration we use System Web Services > REST Message > VA Bot to Bot. So it is the Endpoint that is specified in the Endpoint field that should receive this extended JSON message.
Now the third-party Chat receives a JSON-message like:
{
"agentChat": true,
"body": [
{
"actionType": "StartSpinner",
"message": "Sie werden an einen Servicemitarbeiter weitergeleitet...",
"spinnerType": "wait_time",
"uiType": "ActionMsg",
"waitTime": "1 Minute"
}
],
"score": 1,
"userId": "637a68f8781a4a02800ec0de99d26201"
}
or like this:
{
"agentChat": true,
"body": [
{
"actionType": "System",
"message": "Max Mustermann has joined.",
"uiType": "ActionMsg"
}
],
"score": 1,
"userId": "637a68f8781a4a02800ec0de99d26201"
}
We would like to add our own tag to the JSON depending on the "actionType".
For example like that with a new element "type":
{
"agentChat": true,
"body": [
{
"actionType": "System",
"message": "Max Mustermann has joined.",
"uiType": "ActionMsg",
"type": "add_to_chat"
}
],
"score": 1,
"userId": "637a68f8781a4a02800ec0de99d26201"
}
is this possible ?
Thank you for you time !
- Labels:
-
actionType
-
Live Chat
-
VA Bot to Bot
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2024 11:54 PM
Hi @Alex G_
Please take a look at the script below.
var data ={
"agentChat": true,
"body": [
{
"actionType": "System",
"message": "Max Mustermann has joined.",
"uiType": "ActionMsg"
}
],
"score": 1,
"userId": "637a68f8781a4a02800ec0de99d26201"
};
gs.print(JSON.stringify(data));
data.body[0].actionType= 'new test tag';
gs.print(JSON.stringify(data));
Thanks
dgarad
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-14-2024 12:49 AM - edited 06-14-2024 12:49 AM
Hello dgarad ,
Thanks for your reply, but it's not what I need. The JSON I provided above is generated von ServiceNow (Live Chat) and sent asynchronously to the third party chat-vendor. We are looking for a way to extend it, or perhaps a ServiceNow Script that could be rewritten/extended