cancel
Showing results for 
Search instead for 
Did you mean: 

SAP CAI Integartion with Open Connectors

0 Kudos

Hi,

I am developing SAP Conversational AI Bot to integrate with ServiceNow Application and want to update an incident using incident number only and not sys_id.Please help

Accepted Solutions (0)

Answers (2)

Answers (2)

VamsiKrishna_Gu
Discoverer
0 Kudos
This is very close to something I am looking for. I am trying to replace a working servicenow webhook connection from Google DialogFlow with SAP CAI. Though it is only for demosntration purpose, I am somehow not able to make it work. I get API error.

I roughly modified my REST API script on servicenow going through the JSON view from the CAI bot test but that did not work.

Any help is much appreciated towards adjusting either the webhook JSON or REST script on servicenow to identify the intent and send the response in the required JSON format?

(function process(/*RESTAPIRequest*/ request, /*RESTAPIResponse*/ response) {
var writer= response.getStreamWriter();
var hdrs = {};
var x= request.body.data;
var sn_hr_core_case = '';
var priority = '';
var state = '';
var assigned_to = '';
var context = '';
var command = '';
var message = '';
var status = '';
var desc = '';
var caller = '';
var content = '';
var summary = '';
var comments = '';
data = {};
if(x.queryResult.intents.slug== 'status_check')
{
//var number = (x.result.resolvedQuery).match(/\d+/g).join({});
var numbers = x.queryResult.entities.hrc + "";
//gs.log("number = "+number);
var ci = new GlideRecord('sn_hr_core_case');
ci.addQuery('number','ENDSWITH', numbers);
ci.query();
if(ci.next()){
if(ci.assigned_to != '')
assigned_to = ci.getDisplayValue('assigned_to');
else
assigned_to = "no one";
message= "Case " + ci.number + " requested by " +ci.getDisplayValue('opened_for') + " is currently assigned to " + assigned_to + ". Current state of the incident is " + ci.getDisplayValue('state') + ". This incident is last updated by " + ci.sys_updated_by + " on " + ci.sys_updated_on + "." ;
//summary={};
context='success';
}
}
var messages= "incident";
hdrs['content-type'] = 'application/json';
response.setStatus(200);
response.setHeaders(hdrs);
var response_body = {
"fulfillmentText": message,
"payload": {
"google" :{
"expectUserResponse": true,
"richResponse": {
"items": [
{
"simpleResponse": {
"textToSpeech" : message
}
}
]
}
}
}
};
writer.writeString(global.JSON.stringify(response_body));
//return response_body;
})(request, response);
0 Kudos

Service now does not allow us to update the ticket without sys_id. What we did in our bot was we fetched the sysid using the table incident api provided by service now ->service-now.com/api/now/v1/table/incident?number="incidentnumber" and stored the sysid in bot memory. Then we used it to update the ticket. Hope this answers your question.