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.

Blog : How to Re-Display Topics After Conversation Ends in ServiceNow Virtual Agent

Amitlokre
Kilo Guru

Hi Everyone,

I was working on a requirement in ServiceNow Virtual Agent (Yokohama) where I needed the main topics to appear again automatically once a topic conversation ended.

This requirement was specifically for LLM Topics, and the default "Anything Else" topic exists only in NLU topics, so some extra configuration was required.

 

Step 1: Locate the Setup Topic – “Anything Else Topic”

First, search for the setup topic named “Anything Else Topic” as shown in the screenshot.

This topic is only available under NLU topics, and since we are working with LLM topics, we need to migrate it.

Amitlokre_0-1765279168439.png

Step 2: Migrate and Activate the Topic

After migration:

  • Activate the Anything Else setup topic

  • Publish it (it is an out-of-the-box topic)

 

Step 3: Add the Topic in Virtual Agent Settings

Navigate to:

Conversational Interfaces > Settings > Virtual Agent (Tab) > Select your VA assistant

Here, add the Anything Else setup topic using the link shown in the screenshot.

Amitlokre_1-1765279596990.png

For many instances, the above three steps alone will make the VA display topics again automatically.
If not, proceed with the second method below.

 

Case 2: When Setup Topic Doesn’t Work (Custom Solution)

In one of my client instances, the above steps did not work as expected.
So I had to customize the “Anything Else” setup topic.

What I did:

  • Inside the topic, after the system asks the user "Do you need anything else?",
    I added choice options (the topic names)

  • Each choice is mapped to a script that triggers the corresponding topic

  • The final script node contains the custom logic

Amitlokre_2-1765280002575.png

See screenshot below, how i added the choices into it :

Amitlokre_3-1765280059340.png

 

Now I am pasting here the code which I used in the last script part :


(
function execute() {
var myChoiceValue = vaInputs.select_topic_name.getValue();
var choice = (myChoiceValue || "").toString().trim().toLowerCase();

var topicMap = {
"email issue": "c0abcede1b9d3e100cbbeb91b24bcb01",
"printer issue": "f2350f521bd17e100cbbeb91b24bcb4b",
"escalate it ticket": "65c9c6821b5dfa100cbbeb91b24bcbe7",
"check it ticket status": "92f77a131b11f2100cbbeb91b24bcb3e",
"meeting room issues": "618bf5971b99b2100cbbeb91b24bcbaf",
"troubleshoot microsoft team issue": "c58ff9db1b99b2100cbbeb91b24bcb91",
"create incident": "90d6b5df1b59b2100cbbeb91b24bcb8a"
};

var targetSysId = topicMap[choice];

if (targetSysId) {
 
vaSystem.switchTopicById(targetSysId);
}
 
})()
 

If you want to reuse this code for your own topics, simply copy and paste it into your script node.
Just update the choice names and their corresponding topic sys_ids inside the topicMap, and you’re done.

Thank you!

 

Thanks to @Dr Atul G- LNG @Nawal Singh for help and Support!

0 REPLIES 0