Need help in Virtual Agent scripting
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-07-2024 09:44 AM - edited 05-07-2024 12:06 PM
I have requirement to set the category of the incident based on the short description provided by the user.
Eg: If user enters "My laptop is not getting charged" and sys_choice table has laptop then need to set the Laptop as the category of the incident. I have written the below code for testing purpose and it's not working.
var str = vaInputs.sub;
var words = str.split(" ");
for (var i = 0; i < words.length-1; i++) {
var gr1 = new GlideRecord('sys_choice');
gr1.addEncodedQuery('name=incident^element=category^inactive=false');
gr1.addQuery('label',words[i]);
gr1.query();
while(gr1.next()){
vaVars.subcat1=gr1.label; // subcat1 is defined in scripted variables in the topic
gs.log("CATEGORY IS "+vaVars.subcat1 );
gs. log('Category is selected as '+vaVars.subcat1);
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-07-2024 11:43 AM
HI @Admin7267 ,
You can use glidechoicelist to achieve this, checkout this article explaining solution for similar problem, Consider the category input should also be choice else you will leave room for typo errors.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-07-2024 12:04 PM
Thanks for the response @Muralidharan BS , but my requirement is different.
Need to get category from the short description provided
Eg: If user enters "My laptop is not getting charged" and sys_choice table has laptop then need to set the Laptop as the category of the incident.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-07-2024 12:42 PM
You may not actually need to manually script this. This sounds like a great use case for using NLU entities and I'd recommend you exploring NLU to learn more.
As a quick summary, "Laptop" would be set as an entity (i.e. "#Device" or "#Incident_Category"). Then in VA Designer you create a user input and use "slot-filling" in the user input to map the entity to the input, then when the topic creates/updates the RITM, you map the INC Category to the VA Input - and all this is done with no code.