Is there a way to use the virtual agent chat bot for non service now users?

Yashyasvi
Kilo Contributor

I am working on an extrernal webapp on react and have embedded the chat bot using an iframe in the app, but it requires me to sign in first for it to work. However I am using this bot to serve users who are not service now users and thus they don't have a service now user id and thus cannot login, so is there a way where I can use this for the general users and not the service now users only.

2 REPLIES 2

Community Alums
Not applicable

Hi Yashyasvi,

 

Kindly refer the below article, let me know if its helpful :-

You can load the Virtual Agent web client interface in an external web page by using an inline frame element (iframe). You can also optionally enable the single sign-on (SSO) authentication process to run automatically for guest users who are using the web client and are not logged in.

Before you begin

  • If you want to trigger SSO authentication from the web client, your instance must be set up to use an external SSO provider. Your hosting site must also use the same SSO provider as your instance. For details on setting SSO providers, see External single sign-on (SSO).
  • Role required: admin

About this task

  • In this task, you set two system properties (com.glide.cs.embed.csp_frame_ancestors and com.glide.cs.embed.xframe_options) that determine the security policy for the embedded web client, namely how browsers render and secure HTML content (Virtual Agent and Live Agent chat) in an iframe, before embedding the web chat client.
  • To trigger SSO authentication for guest users, create a script that uses the Window.postMessage() method (Web API) to trigger authentication and also specifies the URL where users are redirected after authentication. For more information on this method and Window objects, see Window.postMessage().
Note: If you're using the Content Management System (CMS) application to create custom interfaces for the Now Platform and ServiceNow® applications, be aware that it does not support Virtual Agent.

Procedure

  1. Set both the com.glide.cs.embed.csp_frame_ancestors and com.glide.cs.embed.xframe_options system properties to specify the HTTP header directives for securing the iframe contents.
    The HTTP header directives tell the browser whether a page can be embedded on certain domains, to mitigate clickjacking attempts. Setting both properties ensures that there security directives for major browsers and also older browsers such as Internet Explorer.
    1. In the Navigation filter, enter sys_properties.list.
    2. In the System Property [sys_properties] table, locate these HTTP header response properties and specify the values for both properties:
      com.glide.cs.embed.csp_frame_ancestors

      Sets the source value of the HTTP header directive: Content-Security-Policy:frame-ancestors <source>. Use the host-source value to specify the domains in which the external web page can be embedded. This property applies to most major browsers, except for Internet Explorer.

      Specify the value, where source is:
      • Type: string
      • Value (you can specify one or more sources):
        • host-source: Internet host site by name, IP address, or optional URL and/or port number. Site address can start with a wildcard (asterisk) character.

          Example value: http://*.example.com

        • scheme-source: A schema.

          Example value: http: or https:

        • 'self': Default value. Indicates that the origin is the same as the page being served.
        • 'none': No matching URLs.
      • Learn more: For details on source values that you can specify, see CSP:frame-ancestors and Virtual agent embedded client content security policy in Instance Security Hardening Settings.
      com.glide.cs.embed.xframe_options

      Sets the value of the X-Frame-Options header directive, to indicate whether the browser can render an external web page in a frame. Use the sameorigin value to specify the domains in which the external web page can be embedded. This property applies to older browsers, such as Internet Explorer 11.

      Specify the directive value:
      • Type: String
      • Value:
        • sameorigin: Default value. Display the page in a frame that has the same origin as the page itself.

          Example value: allow from https://example.com

        • deny: Do not display the page in a frame.
        • allow-from uri: Display the page only in a frame on the specified origin. (No longer works in modern browsers.)
      • Learn more: For details on the directive values that you can specify, see X-Frame-Options and Virtual agent embedded client X-Frame-Options in Instance Security Hardening Settings.
  2. Create the iframe element and specify the following URL with your instance name to embed the Virtual Agent client in the iframe: https://<instance "https://<your-instance>service-now.com/name>.service-now.com/sn_va_web_client_app_embed.do
    For example:
    <iframe id="sn_va_web_client"
        title="ServiceNow Virtual Agent Client"
        width="600"
        height="900"
        src="https://your instance.servicenow.com/sn_va_web_client_app_embed.do">
    "https://<your-instance>service-now.com/"https://<your-instance>service-now.com/</iframe>
    Note: Use the ?sysparm_skip_load_history=true parameter at the end of the URL to load the interface without the conversation history.
  3. Optional. Create a JavaScript script that uses the window.postMessage() method (Web API) to define event conditions that trigger SSO authentication in a user interface page and returns users to a web client page that you specify. For example:
    <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://<your-instance>.service-now.com/sn_va_web_client_login.do?sysparm_redirect_uri=<your-page>";
          
          // 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://<your-instance>service-now.com/"https://<your-instance>service-now.com/sn_va_web_client_login.do?sysparm_redirect_uri=<your-page>";
        });
      </script>

    In this example, authentication is triggered in the specified instance when the SESSION_CREATED or SESSION_LOGGED_OUT events occur. After authentication (when the SSO credentials for users have been accepted), users are redirected to the embedded web client page that you specified in sn_va-web_client_login.do?sysparm_redirect_uri=<your-page>.

     

    Thanks.

event.data.type==="SESSION_CREATED" && event.data.authenticated === false

 

In my implementation, Why everytime this condition is getting true.  Every time it's getting true that's why every time it's redirecting to login page and then again open external website and still treating me as guest user.