Virtual Agent Contextual Search KB Error

alex_tan
Kilo Contributor

Hi All,

I am encountering issues with contextual search on knowledge base for virtual agent and would like to seek help on this.

Virtual Agent error after searching KB: I'm having technical issues and won't be able to continue this conversation. Please stand by while I connect you to a live agent.

System Error logs:

com.glide.script.RhinoEcmaError: "ItsmVaHelper" is not defined.
Task.sys_id : Line(5) column(0)
2: return (function execute() {
3: var kbs = JSON.parse(vaVars.search_kb_json_string);
4:
==> 5: var helper = new ItsmVaHelper();
6: var baseURL = gs.getProperty('glide.servlet.uri') + '/' + gs.getProperty('sn_itsm_va.com.snc.itsm.virtualagent.portal_url');
7:
8:

I am not sure what is wrong with line 5: var helper = new ItsmVaHelper(). How should it be corrected?

The codes i am using are listed below.

User input:

variable name : user_input

I had declared 2 live agent variables: query and search_context_sys_id under script variables.

Search Query Action :

(function execute() {

vaVars.query = gs.getMessage(vaInputs.user_input.getValue());

})()

Contextual Search Action:

(function execute() {

var search_term = vaVars.query;
var context = vaVars.search_context_sys_id;
var contextualSearch = new sn_itsm_va.VAContextualSearchUtil();
var response = contextualSearch.search(context, search_term);
var success = contextualSearch.processSearchResponse(response);
if (!success) {
return;
}
var relevantSearchResults = contextualSearch.processGeneralResults(response, 3, -2);
vaVars.kbResultCount = relevantSearchResults.length;

vaVars.search_kb_json_string = JSON.stringify(relevantSearchResults);

return;
})()

Display KB Result Script Output:

(function execute() {
var kbs = JSON.parse(vaVars.search_kb_json_string);

var helper = new ItsmVaHelper();
var baseURL = gs.getProperty('glide.servlet.uri') + '/' + gs.getProperty('sn_itsm_va.com.snc.itsm.virtualagent.portal_url');


var items = kbs.map(function(kb) {
return helper.formatKBSearchResult(baseURL, kb);
}).join('<br />');

var html =
'<div>' +
'<div>' + gs.getMessage('I found some information that might help you:') + '</div><br />' + items +
'</div>';

return html;
})()

 

Thanks in advance for your help.

5 REPLIES 5

Hi Mark,

I need help on restricting few IT based knowledge articles in the virtual agent which should not come up in the KB search results.

Can you please help me with this.

Thanks in Advance.

Kind Regards,

Koyel