Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Get last utterance from user with vaSystem.getSearchText()

MB Richards
Tera Contributor

I know that the user's last VA utterance is stored in vaSystem.getSearchText() 

 

I am using this script within a Topic, so I can access that string, and I created the associated script variable.  But the variable "desc" is returning "null".  This seems straightfoward - what am I doing wrong?

 

Script:

(function execute() {
     var desc = vaSystem.getSearchText();
     return desc;
})()

 

Script Variable

desc

 

For example, within the topic, I want to save the string "I need admin rights" (typed after the greeting) as a variable:

 

MBRichards_0-1723666861642.png

Thanks in advance!

6 REPLIES 6

MB Richards
Tera Contributor

Ok, I have this working now - hope it helps someone else!

 

Script:  Bot Response (Orange) - to print vaSystem.getSearchText() value to screen

 

Script:

(function execute() {
     var desc = vaSystem.getSearchText();
     return desc;
})()

 

Script Variable

desc

 

Script:  Utilities (Black) - to save vaSystem.getSearchText() value as a VA variable

 

(function execute() {
      vaVars.user_typed= vaSystem.getSearchText();
})()
 

Script Variable

user_typed

Hi @MB Richards 

I am exactly facing the same issue while modifying in anything else topic. 

I tried in the same way you have mentioned. But, still vaSystem.getSearchText() returns null. I have attached all screenshots for your reference.

 

Your help on this would be appreciated

Hi @madhumithap2209 

After struggling with for so long, I also just found an example in the Search Fallback Topic.  Just look for the "User Search Text" node.  Make sure to add the Script Variable as well.

 

I hope this helps!

Hi @MB Richards ,

 

It is not working yet. I have attached the complete recording of what I have done. Could u pls check and revert.

 

Its better if you record and send the working flow