Using AI Search Topic Block returns "'Here's what I found for ""' -- missing original search string

Andrew Sheldon
Tera Contributor

I am attempting to use the AI Search Topic Block inside another VA topic. I created a user input node for a user to enter a search string, and then immediately after inserted the AI Search topic block and am passing the user search term to the AI Search as the Search Term [input variables>search term]. When the search executes, it is correctly showing accurate results based on the user's search string, but for some reason it shows: "'Here's what I found for ""' [missing the user's search string]. 

For example if user enters "pay period", i would expect it to say "'Here's what I found for "pay period"', but instead it just shows "'Here's what I found for ""'.

 

Any ideas what I am missing here? I can't see where i might be missing passing the search term to the topic block... since it is set up in the input variables for the Search term, and it is correctly searching for the phrase...

AndrewSheldon_0-1685539117872.png

 

1 ACCEPTED SOLUTION

WillWitten
ServiceNow Employee
ServiceNow Employee

You may want to check this part of the flow

 

Flow.PNG

 

 

For this script

 

Script.PNG

 

This script is pulling vaSystem.getSearchText(), which pulls the user's utterance. This should instead be utilizing the input variable for the Topic Block. You should duplicate the Topic Block and rewrite it to look like this

 

(function execute()  {
    vaVars.shouldAskInfoHelpful = true;
    var searchTerm = vaInputs.search_term;
    return gs.getMessageLang('Here\'s what I found for "{0}"', vaContext.getRequesterLang(), [searchTerm]);
})()

 

By making this change, you can fix this issue!

 

TB Visual.png

 

 

Another place that you may need to modify is here, as when a Genius Result is displayed, the 'Show me more' option has a similar issue.

 

Second Flow.PNG

 

Second Script.PNG

 

You will want to change this to read as below 

(function execute() {
    var options = [];
    var searchTerm = vaInputs.search_term;

    if (!gs.nil(vaVars.catalogId)) {
        options.unshift({ 'value': 'request_catalog_item', 'label': gs.getMessageLang('Request Catalog Item', vaContext.getRequesterLang()), 'render_style': 'data'});
    } else {
        options.push({ 'value': 'yes', 'label': gs.getMessageLang('I\'m all set', vaContext.getRequesterLang()), 'render_style': 'data'});
    }
    options.push({ 'value': 'no', 'label': gs.getMessageLang('Show me more on "{0}"', vaContext.getRequesterLang(), [searchTerm]), 'render_style': 'data'});
    
    if (vaInputs.ask_another_search == 'true') {
        options.push({ 'value': 'another_search', 'label': gs.getMessageLang('Ask something else', vaContext.getRequesterLang()), 'render_style': 'data'});
    }
    return options;
})()

 

View solution in original post

6 REPLIES 6

WillWitten
ServiceNow Employee
ServiceNow Employee

Good morning!

Which release is this occurring in?

Hi! This is San Diego patch 10 hotfix 1A

WillWitten
ServiceNow Employee
ServiceNow Employee

You may want to check this part of the flow

 

Flow.PNG

 

 

For this script

 

Script.PNG

 

This script is pulling vaSystem.getSearchText(), which pulls the user's utterance. This should instead be utilizing the input variable for the Topic Block. You should duplicate the Topic Block and rewrite it to look like this

 

(function execute()  {
    vaVars.shouldAskInfoHelpful = true;
    var searchTerm = vaInputs.search_term;
    return gs.getMessageLang('Here\'s what I found for "{0}"', vaContext.getRequesterLang(), [searchTerm]);
})()

 

By making this change, you can fix this issue!

 

TB Visual.png

 

 

Another place that you may need to modify is here, as when a Genius Result is displayed, the 'Show me more' option has a similar issue.

 

Second Flow.PNG

 

Second Script.PNG

 

You will want to change this to read as below 

(function execute() {
    var options = [];
    var searchTerm = vaInputs.search_term;

    if (!gs.nil(vaVars.catalogId)) {
        options.unshift({ 'value': 'request_catalog_item', 'label': gs.getMessageLang('Request Catalog Item', vaContext.getRequesterLang()), 'render_style': 'data'});
    } else {
        options.push({ 'value': 'yes', 'label': gs.getMessageLang('I\'m all set', vaContext.getRequesterLang()), 'render_style': 'data'});
    }
    options.push({ 'value': 'no', 'label': gs.getMessageLang('Show me more on "{0}"', vaContext.getRequesterLang(), [searchTerm]), 'render_style': 'data'});
    
    if (vaInputs.ask_another_search == 'true') {
        options.push({ 'value': 'another_search', 'label': gs.getMessageLang('Ask something else', vaContext.getRequesterLang()), 'render_style': 'data'});
    }
    return options;
})()

 

Thank you Will! this worked.