Skip to main contentWatson Assistant web chat

Genesys

Genesys web messenger

Overview

Web chat comes with a built-in integration to the Genesys Web Messenger. This integration currently only supports client-side configuration and is not available inside the Watson Assistant UI. This page documents the configuration settings needed by web chat to enable the integration.

You can find more information about setting up web messenger on the Genesys website.

Enabling the integration

To enable the integration you will need know your Genesys script URL, environment, and deployment ID. These values can be found in the embed code Genesys provides you for embedding the messenger on your website. You will need to include these values in the web chat configuration object as shown below.

Note: the environment value is only necessary if you are not using the default environment and it may not be included in your embed code. Also note that the Genesys SDK does not work if launched from a local HTML file opened directly in your browser (using file://). It needs to be served from a server (which can be localhost) over HTTP. You can use http-server if you need a simple local server for testing purposes.

<script>
  window.watsonAssistantChatOptions = {
    integrationID: 'YOUR_INTEGRATION_ID',
    region: 'YOUR_REGION',
    serviceInstanceID: 'YOUR_SERVICE_INSTANCE_ID',

    serviceDesk: {
      // This will enable the Genesys integration.
      integrationType: 'genesyswebmessenger',
      genesysMessenger: {
        scriptURL: 'https://apps.mypurecloud.com/genesys-bootstrap/genesys.min.js',
        deploymentID: 'YOUR_DEPLOYMENT_ID',
        environment: 'YOUR_ENVIRONMENT', // Only if provided.
      },
    },

    onLoad: function(instance) {
      instance.render();
    }
  };
  
  setTimeout(function(){const t=document.createElement('script');t.src='https://web-chat.global.assistant.watson.appdomain.cloud/versions/' + (window.watsonAssistantChatOptions.clientVersion || 'latest') + '/WatsonAssistantChatEntry.js';document.head.appendChild(t);});
</script>

Authenticated users

Genesys allows you enable configuration that ensures only authenticated users may connect to Genesys. To enable this functionality, you will need an OAuth provider that can provide an authentication code that you will make available to Genesys. To provide the code, web chat will fire events the same events that the Genesys SDK fires when it needs to perform authentication related operations. At a minimum, you will need to listen for the agent:genesysMessenger:AuthProvider web chat event to provide the authentication code.

You can read about setting up user authentication on the Genesys website as well as review their example code.

Example

instance.on({
  type: 'agent:genesysMessenger:getAuthCode',
  handler: (event) => {
    // Here you will add your code to call your oauth provider to get an authentication code. This may involve a
    // redirect to your authentication or login page so you may need to provide a redirect URL to get back to this
    // page.
    const authCode = await someFunctionToGetAuthCode();
    const redirectUri = 'YOUR_REDIRECT_URI';
    // Provide the authentication code to Genesys.
    event.genesysEvent.resolve({
      authCode,
      redirectUri,
    });
  },
});

Web chat events

This is the list of events that web chat fires. These events mirror the events fired by the Genesys SDK.

Web chat eventDescription
agent:genesysMessenger:AuthProviderThis is fired when the Genesys AuthProvider event is fired. The genesysEventproperty on the web chat event will provide access to the underlying Genesys event.
agent:genesysMessenger:getAuthCodeThis is fired when the Genesys getAuthCode event is fired. The genesysEventproperty on the web chat event will provide access to the underlying Genesys event.
agent:genesysMessenger:reAuthenticateThis is fired when the Genesys reAuthenticate event is fired. The genesysEvent property on the web chat event will provide access to the underlying Genesys event.
agent:genesysMessenger:loggedOutThis is fired when the Genesys loggedOut event is fired. The genesysEventproperty on the web chat event will provide access to the underlying Genesys event.
agent:genesysMessenger:authErrorThis is fired when the Genesys authError event is fired. The genesysErrorproperty on the web chat event will provide access to the underlying Genesys event.

Custom attributes

The Genesys SDK allows you to set custom attribute that may be available inside of Genesys. Web chat allows you to provide custom attributes before a chat has started by using the agent:pre:startChat event. To provide custom attributes, set the preStartChatPayload.customAttributes property of the event.

You can use an agent pre-chat form to gather any custom data you want to send to Genesys before the chat begins. The event documentation includes a basic example for how to do this. You can also view our tutorial for creating pre and post-chat forms based on the window open and closed events. Handling a pre or post-chat event with an agent will be similar code except you'll use agent:pre:startChat instead of window:open.

Example
instance.on({
  type: 'agent:pre:startChat',
  handler: (event) => {
    event.preStartChatPayload = {
      customAttributes: {
        attribute1: 'Some value',
      },
    };
  },
});