Virtual Agent Context Variables

benm3
Mega Guru

Hi there,

I'm trying to determine the current portal URL by using a context variable, however, the variable always return undefined and I cannot seem to figure out why. Any help would be greatly appreciated!

Context Variable (I have removed answer and tried, remove 'getSession' and tried but no luck) is the attachment.

Condition script on virtual agent topic: 

    gs.log("Context plswork: " + vaContext.portalCheck, "BenTest");
    
    if(vaContext.plsWork.includes("locker"))
    return false;
    else
    return true;

 

 

12 REPLIES 12

Mark Roethof
Tera Patron
Tera Patron

Hi there,

This article should help you:
Virtual Agent - Available topics depending on different Service Portals

In this article exact info on vaContext usage is explained.

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Mark

---

LinkedIn
Community article list

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

Thanks for the reply, I've seen that article however, it requires you to change the url. Unfortunately this isn't an option for me...

Ah oke.
Can you provide an example URL?

For example, in your script I see vaContext.portalCheck and vaContext.plsWork. Does your url contain sysparm_portalCheck and sysparm_plsWork?
So what exactly are you trying to fetch from the URL?

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Mark

---

LinkedIn
Community article list

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

This is the format of all our URLs:

https://byea.service-now.com/tech

https://byea.service-now.com/hr

So I'm trying to identify when its either /tech or /hr.

 

Aye sorry, the 'plsWork' should be 'portalCheck' (Was testing and forgot to revert before photo)

if(vaContext.plsWork.includes("locker"))

 

Thanks,

Ben