Hi Guys,
I'm Vishal. I'm working on Virtual Agent for a long time now. It is a great plugin and I want to share this knowledge and lessons I learnt during all this time to ease your work. I'll guide you through Virtual Agent Best Practices, Tips and Tricks and will go through the docs with a more simple language. So, Welcome to this series : How to read the Docs - Virtual Agent.
If you had ever visited this page on ServiceNow Docs, you as well might have seen this picture :
Have a look at Knowledge results shown in the above screenshot. It contains Article Numbers. But How the results are actually displayed using Virtual Agent? Have a look at below screenshot from a OOTB Topic 'Search Knowledge Base' (Provided with 'ITSM Virtual Agent Conversations' Plugin) :
Yup. There are no article numbers when used OOTB search.
We had the requirement to make our knowledge search like one shown in the above screenshot. So are you ready to see how did we achieve it?
We had the requirement to make our knowledge search like one shown in the above screenshot. So are you ready to see how did we achieve it?
Step 1) Search for the existing OOTB Topic and Open It.
2) Click 'Duplicate'.
3) Give it a unique name and click 'Save'.
4) Click 'Edit Topic Flow' in newly created Topic Properties Page.
5) In the designer canvas, locate the bot response 'Display KB(s)' that display's knowledge results.
6) Open '' script from response properties.
7) Replace the OOTB Script with the Script given below and click 'Save' :
(function execute(header) {
var groupedLinksOutMsg = new sn_cs.GroupedPartsOutMsg();
groupedLinksOutMsg.setHeader(header);
var limit = parseInt(vaVars.limit);
var searchJsonObj = JSON.parse(vaVars.search_kb_json_string);
var index = parseInt(vaVars.index);
var linkBuilder = new global.cxs_SearchResultLinkBuilder();
test = '<html><body><table style="text-align:left"><tr><td colspan="2"></td>OK. Before creating your incident, here are some KB articles that may help.</tr>';
test += '<tr><th style="width:30%">KB Number</th><th>Short Description</th></tr>';
for (var i = index; i < index + limit && i < searchJsonObj.length; i++) {
var link = linkBuilder.build(searchJsonObj[i], vaInputs.portal);
var articleLink = link.link;
var articleNumber = articleLink.match(/KB\d{7}/);
test += '<tr><td><a href="'+articleLink+'">'+ articleNumber + '</a></td><td>' + link.label + '</td></tr>';
}
test += '</table></body></html>';
return test;
})(header)
8) Locate the Bot Response 'Found Result Message' and delete it.
Hurray, You have created the Custom BA Knowledge Results Response which looks like as mentioned in the Docs.
If you'll compare it with OOTB script you'll realize the only change made was using HTML tags and RegEx.
See You in the next lesson with another trick.
Thank You.
Vishal Ingle
ServiceNow Certified System Administrator
DxSherpa Technologies Pvt. Ltd.
Maharashtra, India
No comments:
Post a Comment