The Zurich release has arrived! Interested in new features and functionalities? Click here for more

How to get portal url in virtual agent script

kamer
Kilo Expert

Hi,

I have a requirement to get the portal URL in virtual agent script.Like i need to check weather its HR portal or IT Portal in greetings message topic.

1 ACCEPTED SOLUTION

Imam Pasha1
Giga Guru

Hi Kamer,

As per your details provided please try below code and let me know.Its working fine for me with below solution:Add this below code in greeting topic inside script action

(function execute() {
vaVars.greeting_message = vaSystem.getGreetingMessage();

if(!vaContext.portal){
returnfalse
}
elseif(vaContext.portal=='sp'){

return vaVars.LiveAgent_queue='d50bdb2fdb501010b45e9444ca96192a';

}
elseif(vaContext.portal=='esc'){
return vaVars.LiveAgent_queue='fde232209f22120047a2d126c42e70ab';

}

})()
 
Please mark as correct answer if its working for you.
 
Regards,
Imam Pasha

View solution in original post

8 REPLIES 8

Mark Roethof
Tera Patron
Tera Patron

Hi there,

See this article I wrote a few weeks back with detailed explanation on how you can achieve this. With: vaContext.
Virtual Agent - Conditions based on different Service Portals

The article is on conditions, though principle is the same.

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

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

---

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

Awesome! Bookmarked.

Mark Roethof
Tera Patron
Tera Patron

Snipped from the article:

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."

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

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

---

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

Basically i have a requirement to route live agent to particular queues from connect support option.So greeting message is start of conversation so i am writing script in its condition as below

if(vaContext.portal=='ITServices') {
    return vaVars.LiveAgent_queue='7ae3eb0bdbcc10d0f612df9b5e9619a3';
}

if(vaContext.portal == 'hrportal'){
    return vaVars.LiveAgent_queue='f4d701b1b3900300f7d1a13816a8dc8e';
}
 
 
This is routing only to IT queue.