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

Mark Roethof
Tera Patron
Tera Patron

Hi there,

Is this on a step in a custom Topic you build? Or in a out-of-the-box topic?

If a custom Topic, in which scope did you build this? Global scope? ITSM Conversations?

The new ItsmVaHelper() part calls a Script Include. Be aware this is a scoped Script Include. You might need to call new sn_itsm_va.ItsmVaHelper() instead of without the sn_itsm_va part.

Kind regards,
Mark

---

LinkedIn

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

If you copy a conversation from ITSM Conversations and you're in Global this is the problem.  I think I noticed this in the Email Issues (ITSM conversation) template.  

Mark Roethof
Tera Patron
Tera Patron

Or of course, check if you even have a Script Include "ItsmVaHelper" in your instance. It should be, out of the box when you installed the ITSM Conversations. Though just double check.

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Mark

---

LinkedIn

 

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

Hi Mark,

Thanks for your help, notice that the virtual agent is not able to call the script include due to the application.

Need to seek your advice on another matter, i am trying to do a return to the previously options, however, i am not able to achieve it using switch topic.

The flow is similar to this:

User is greeted after launching virtual agent, user search for laptop as a keyword, virtual agent found 3 matches and return them as option 1, option 2, option 3. My flow currently is after user select option 1/ option 2/option 3, using a boolean if no is selected, it will search the kb and lastly create an incident if that did not help.

User is not able to return back to the previously screen, i am trying to besides the yes, no, have a return function. I tried to use a static choice with these 3 values, however, i am not able to extract the values after my decision branch.

I have read some posts in the community and understood that this can be achievable using topic switch.

Can you give me some sample codes to achieve the following:

1) able to return back to the previously screen and system will remember option 1, option 2, option 3 and let user repick

2) how to read the values input by user from a static choice to extract option: yes, no, return for decision branch

3) i notice if i use the reference choice topic list script shared by simon, system will return the list and user can only click the options return and cannot search by any keyword, can both be used at the same time

https://community.servicenow.com/community?id=community_article&sys_id=7e8a90cbdb097344200f0b55ca961929

4) using the same sample code in option 3, lets say if i hardcode the reference choice topic list to a laptop topic at the beginning of the flow, i notice that system will prompt that laptop topic list has been selected, choose yes or no to proceed, how do i remove the yes/no option and proceed directly?

5) i tried method 5 and 6 in your post for the start conversation, there is an error testing the URL, how do i populate the section for the definition for start conversation?

https://community.servicenow.com/community?id=community_article&sys_id=8fba850ddb6d3f84a39a0b55ca96198a

6) after the end of the topic, what would be a good way to direct user back for more searches again?

Thank you.