Virtual Agent - Available topics depending on diff... - ServiceNow Community
Mark Roethof
Tera Patron
Tera Patron

Hi there,

Most frequent usage of the Virtual Agent Service Portal widget will be on the default "sp" Service Portal. Though what if you are also using other Service Portals? And want to use the Virtual Agent Service Portal widget also on those Service Portals. Actually, no problemo! Works like a charm. Though, you might not want all Topics to be available on your "CAB Workbench" portal, or different Topics on your "Customer Support" portal. How to achieve this?!

Default behavior

By default, all Topics will be visible. For example, below a screenshot of the "Customer Support" portal.

find_real_file.png

Virtual Agent Designer - Condition

Looking at the previous screenshot, you might want to hide certain topics or show certain topics only on specific portals. The Virtual Agent Designer looks very limited on this, though actually you could utilize the Condition field for this. The Condition field is also described as: "The expression that must return true or false to display the topic to the user when searching from the client".

find_real_file.png

Virtual Agent scripts - Context variables

From the Docs:
"You can use variables in system parameters within the web client URL. These variables can be used anywhere in the conversation using the vaContext object. Use these options to create links to Virtual Agent with predefined variables.

https://<instance>.service-now.com/$sn-va-web-client-app.do?sysparm_city=rome

The example link contains a parameter, sysparm_city=rome. In addition to opening a Virtual Agent conversation, using this link creates a variable called city with a value of rome. This variable can be accessed in a script using vaContext.city."

Combining the Condition and Context variables

The Condition field and the Context variables should give us enough possibilities to make Topics portal specific. First, we should add a sysparm to the web client URL. For example: "sysparm_entity=csm". This sysparm would be available in the Condition field of the Virtual Agent Designer as "vaContext.entity".

The rest is almost common code, using an if condition to check the variable.

Condition (vaContext.entiry as example)

(function execute() {

	if(!vaContext.entity) {
		return true;
	}

	if(vaContext.entity != 'csm'
		return true;
	}

})()

Web client URL

https://<your-instance>.service-now.com/$sn-va-web-client-app.do?sysparm_entity=csm

The result should be that the Topic will not be visible for the user.

find_real_file.png

Obviously, you could change the condition to your logic. Maybe having a topic that should only be visible on the "Customer Support" portal for example. The code would just be:

Condition

(function execute() {

	if(!vaContext.entity) {
		return false;
	}

	if(vaContext.entity == 'csm'
		return true;
	}

})()

---

And that's it actually! A common question asked on the community summarized in this article.

👍
If this post helped you in any way, I would appreciate it if you hit bookmark or mark it as helpful.

Interested in more articles, blogs, videos, and Share projects on Virtual Agent I published?
Virtual Agent


Kind regards,
Mark

---

LinkedIn

Comments
kgupta
Tera Contributor

Hi Mark,

thanks for detailed info, i tried but may be i am making some mistake which is the reason i am not able to achieve it. I am separating ITSM and HR topics. Can you make me understand a bit what is .entity used for? 

Mark Roethof
Tera Patron
Tera Patron

Hi there,

Can you share what you've tried? Or just make a new Community topic for this, then I can have a look or maybe an other Community member will also spot your question.

Don't forget to mark the article helpful 🙂

Kind regards,
Mark

---

LinkedIn
Community article list

kgupta
Tera Contributor

Thanks for your quick reply Mark, Actually we have two portals HR and Customer service Portal. Please refer to the screenshot, in the screen shot when enable virtual agent conversation by default all the topics which i have activated for HR and Customer portal is showing on both portals. I want to have this segregated. General Inquiry for HR portal and Check IT ticket Status for  Customer Portal.

I tried the code you mentioned, i used that in condition but bit confused what is entity you are referring too.

 

vaContext.entity  here vaContext is clear that we have defined an object but what is entity we are referring too. Also please guide me how we can separate this.

Mark Roethof
Tera Patron
Tera Patron

Ah oke.

For example, on both your portals, you should call the Virtual Agent with additional parameter, like sysparm_portal or something 🙂

For example, for HR:
https://<instance>.service-now.com/$sn-va-web-client-app.do?sysparm_portal=hr

For example, for Customer Portal:
https://<instance>.service-now.com/$sn-va-web-client-app.do?sysparm_portal=cp

With this, you could add a condition to your topics. Condition like for example:

if(!vaContext.portal) {
	return false;
}

if(vaContext.portal == 'hr'
	return true;
}

Kind regards,
Mark

---

LinkedIn
Community article list

kgupta
Tera Contributor

Thanks Mark, still not able to achieve, Please refer the attached and this is where it created confusion earlier as well with calling virtual agent with additional parameter.

for customer portal i am using dh_sp and for hr portal i am using dhhr.

Mark Roethof
Tera Patron
Tera Patron

The URL I'm showing, is the URL within the Virtual Agent widget. So you have to perform this in the widget instance. Out-of-the-box, the Virtual Agent widget has a URL option where you could add this URL. Obviously you would need a different widget instance depending on the Service Portal.

Kind regards,
Mark

---

LinkedIn
Community article list

kgupta
Tera Contributor

Got it, Thanks Mark, i realized for HR i already made a clone widget. all confusion cleared. Thanks Much Mark.

kgupta
Tera Contributor

Thanks for All your help mark!! Its done, will go through rest of your articles. Very Very Helpful. Thanks Again.

kamer
Kilo Expert

Hi Gupta,

Kindly explain little bit more how you achieved this,even i am also having same requirement.

Mark Roethof
Tera Patron
Tera Patron

Here's one of the replies:

For example, on both your portals, you should call the Virtual Agent with additional parameter, like sysparm_portal or something 🙂

For example, for HR:
https://<instance>.service-now.com/$sn-va-web-client-app.do?sysparm_portal=hr

For example, for Customer Portal:
https://<instance>.service-now.com/$sn-va-web-client-app.do?sysparm_portal=cp

With this, you could add a condition to your topics. Condition like for example:

if(!vaContext.portal) {
	return false;
}

if(vaContext.portal == 'hr'
	return true;
}

Kind regards,
Mark

---

LinkedIn
Community article list

kamer
Kilo Expert

Hi Gupta,

Thanks for the response.Actually i understood the above script but my question is how and where to call virtual agent with additional parameters,we should add that above script to each topic ?

We have configured VA in our portal Footer.

Kindly explain how to separate ITSM and HRSM topics for this two portals.

Mark Roethof
Tera Patron
Tera Patron

To configure URL parameters through the instance options, see this article:
https://community.servicenow.com/community?id=community_article&sys_id=1ce3cd66db9e88101cd8a345ca961...

To configure the URL directly in your widget, you would need to clone the "Virtual Agent Service Portal Widget" widget and edit the URL in the Client Controller/Client Script:
$ctrl.vaSource = '/$sn-va-web-client-app.do?sysparm_nostack=true&sysparm_stack=no';

Kind regards,
Mark
2020 ServiceNow Community MVP
2020 ServiceNow Developer MVP

---

LinkedIn
Community article list

kamer
Kilo Expert

Hi Mark,

Thanks for the response.Actually i understood the above script but my question is how and where to call virtual agent with additional parameters,we should add that above script to each topic ?

We have configured VA in our portal Footer.

Kindly explain how to separate ITSM and HRSM topics for this two portals.

anindya_11
Giga Contributor

Hi Kamer,

I have the same issue. The VA is embedded in the footer with widget options.

However when I try to use vaContext.<param> = <param_name> it fails to recognize.

Were you able to solve this ?

 

Mark Roethof
Tera Patron
Tera Patron

Hi there,

Can you open a topic for this? And share in detail how you set up your widget (for example embedded in the footer), if you added widget options, etc..

Myself or other community members will spot your question there. 

Kind regards,
Mark

---

LinkedIn
Community article list

kamer
Kilo Expert

Hi Anindya,

 

If you want to show topic in ITSM portal then use below script in your topic condition:

Script:

ITSM prefix:

(function execute() {
if(!vaContext.portal) {
    return false;
}
if(vaContext.portal == 'ITSM'){      //add ur portal prefix in place of ITSM
    return true;
}
})()
 
If you want to show topic in HRSM portal then use below script in your hrsd topic condition:
 
HRSM Prefix:
 
(function execute() {
if(!vaContext.portal) {
    return false;
}
if(vaContext.portal == 'hrsm'){      ////add ur portal prefix in place of hrsm
    return true;
}
})()
 
mrafi
Giga Contributor

Hi @Mark Roethof ,

 

I have created different topics for different service portals and all the topics are added with a conditional script.

Everything is working fine in the Desktop version of the Virtual agent.

But, the same script is not working in the Now mobile app virtual agent.

I could see that the interaction context record is not getting updated with the values(portal, page,etc) whenever an interaction gets started from mobile app virtual agent due to which conditions in the topics are returning false.

Could you please help here?

 

Thanks in advance,

Mohammed Rafi

Mark Roethof
Tera Patron
Tera Patron

Hi there,

My first thought is, how are you calling the Virtual Agent on your Now Mobile app versus the Virtual Agent web client on the Service Portal? On the Service Portal, for example did you add a parm to the URL? Or are you for example using vaContext.portal? How are you doing this on your Now Mobile app?

Can you open a new topic for this. And describe in detail how you've set this up?

Kind regards,
Mark

---

LinkedIn
Community article list

mrafi
Giga Contributor

Hi @Mark Roethof ,

I have configured the virtual agent widget through AGENT CHAT CONFIGURATION setup instead of adding widget on portal page.
And am using vaContext.portal to check which portal user is and returning true/false.

As I said, the context values are populating in the v_interaction_context record properly when a user starts interacting with virtual agent via desktop but the same values are NOT populating when interacted via mobile app.

Configurations in NowMobile App:

Followed the instructions in the path below:

https://docs.servicenow.com/bundle/newyork-mobile/page/administer/tablet-mobile-ui/concept/additional-mobile-configuration.html#sg-mobile-virtual-agent

 

Thanks in advance

Mohammed Rafi

 

Natalia26
Kilo Contributor

Hi Mark,

Do you know if there is a way to hide the topics according to their scope or something that may not require edit each topic's condition?

I have a task to limit the Topics from the VA Topic Picker based on the topic scope on a specific portal. Let’s say that I have a HR portal and I want only HR topics to show up there.

My issue with changing the Condition is that I may have several topics in several scopes and the users are constantly installing plugins which may bring more VA Topics. I cannot control all those topics and their conditions.

Sushant13
Tera Contributor

Hi Natalia,

Did you find a way to restrict topic visibility in the VA Topic picker based on topic scope on a specific portal without having to modify every Topic's properties - roles or conditions using vaContext?

I am facing a similar issue where there are ton of existing topics for different business functions (HR, IT) which do not restrict visibility and I want to exclude them from my business function (CSM) specific  virtual agent chatbot.

Thanks,
Sushant

 

Nata
Kilo Contributor

Hello Sushant,

Unfortunately no, we had to proceed adding the topic's condition using the vaContext, additionally we added a Custom Greeting and Setup for the portal to make the topics visible at the chatbot's initial screen so the user can easily identify them.

Version history
Last update:
‎09-24-2019 11:16 PM
Updated by: