Virtual agent html bot response i'm not able to add the onclick event

shiva10
Tera Contributor

Hi All,

 

i need to switch topic on click on a text i tried the below code on click event is not triggered

 

<html>
<body>
<script>
function click(){
vaSystem.switchTopic('Contact Live Agent');
}
</script>
<span onclick="click()"
style="color: blue; cursor: pointer">click me </span>
</body>
</html>
8 REPLIES 8

IC2
Tera Expert

Hi there,

I do not think we can have onclick events from HTML responses in VA. If someone knows, that would open a lot of possibilities for further developments.

However, there is a workaround that could work for your use case.

Try the following as your <a> tag:

<a href="/$sn-va-web-client-app.do?sysparm_nostack=true&sysparm_stack=no&sysparm_skip_load_history=true&sysparm_topic=a491bb0adb13d4d0a09249ee3b9619ce">Contact Live Agent</a>

And replace the value of the "sysparm_topic=" with the *sys_id of your Live Agent topic.

*To get the sys_id of your Live Agent topic, you can go to the "sys_cs_topic" table.

**You might need to add more parameters to handle unexpected behavior. For example your branding key(sysparm_branding_key ).

With the above I was able to simulate switching topics after clicking in the link. But you might need to be cautious with unexpected behavior. For example, in my case I did not get the "closing message" after finishing the Live Agent conversation (you might need to force it).

Kind regards,

 

 

 

Prakash36
ServiceNow Employee
ServiceNow Employee

GREG,

Already implemented the "

<a href="/$sn-va-web-client-app.do?sysparm_nostack=true&sysparm_stack=no&sysparm_skip_load_history=true&sysparm_topic=a491bb0adb13d4d0a09249ee3b9619ce">Contact Live Agent</a>

", but the problem is, it is opening in a new conversation. and we want to be part of the same conversation.

 

Thanks,

Prakash

 

Yeah, I understand that might be the challenge.

The other idea could be to present those options as static choices instead of plain text. That way you leverage the Out of the box components. See the example below.

find_real_file.png

I hope that helps,

Kind regards,

Chris D
Kilo Sage
Kilo Sage

Suddenly I realize my own use case for this and completely empathize with the frustrating limitation...

I have a topic for high impact incidents/outages and if a quick query returns any results, I want my greeting message to include a message notifying the user and letting them access that topic to see details and create a child ticket. But the thing is, I still need it to return the topic picker - vaSystem.sendTopicPickerControl(greetingMessage) - in addition to a button/link to switch topics.

I can't rely on using an a tag/link because we have users in MS Teams not using the portal widget.

I also don't want to burden users with an additional click by using a Static Choice input to either start the topic or display the topic picker. There's not many other use cases for it, but we need an option for asynchronous user input - i.e. present a Static Choice, but still continue with the topic flow.

For the time being, I'm just displaying a message like "There are X outages... type in 'view outages' to see more details.'