Embedding of a Virtual Agent into an external website with SSO integration Not working as expected

Anish KUMAR1
Tera Contributor

Hi, I am currently working on implementing a virtual agent chat icon on an external website so that users can access the virtual agent from the external site in the same way they do from our employee center or service portal.

 

I have tested this solution on the external website and observed that the virtual agent on external website only functions when both pages, "$sn-va-web-client-app" and "sn_va_web_client_app_embed," are marked as public (active = true) in the "sys_public" table.

 

However, I have noticed an unexpected behavior that I need assistance with. If anyone has a solution, I would appreciate their help.

 

Our external website and ServiceNow both use the same SSO. Currently, if a user is logged into ServiceNow and clicks the chat icon on the external site, the virtual agent loads as expected because the user is already logged into ServiceNow in the same browser.

 

However, if the user is not logged into ServiceNow and clicks the chat icon on the external site for the first time, the browser refreshes the page. The user then has to click the virtual agent icon a second time to access it.

 

My concern is that since we are using the same SSO for both the external website and ServiceNow, and the user has accessed the external site through the same SSO, the virtual agent should work as expected on the first click. Why is this not happening?

 

below code I am using on external site to access virtual agent.

 

<p><script type="module" >
import ServiceNowChat from "https://instanceName.service-now.com/uxasset/externals/now-requestor-chat-popover-app/index.jsdbx?sy...";
var chat = new ServiceNowChat({ instance: "https://instanceName.service-now.com/", });
</script></p>
<script>
window.addEventListener("message", function(e) {
// redirect to SSO login if the web client logs in but is logged in as a guest user(unauthenticated)
if(e.data.type==="SESSION_CREATED" && e.data.authenticated === false)
window.location.href = "https://instanceName.service-now.com/sn_va_web_client_login.do?sysparm_redirect_uri="+ encodeURIComponent(location.href);

// redirect to SSO login if the ServiceNow platform logs out from underneath the web client
if(e.data.type==="SESSION_LOGGED_OUT")
window.location.href = "https://instanceName.service-now.com/sn_va_web_client_login.do?sysparm_redirect_uri=" + encodeURIComponent(location.href);
});
</script>

1 REPLY 1

Tang Phat
Tera Contributor

Hi Anish,

 

I have the same issue when embedding the Virtual Agent in our external website, do you found any solution for this?