Prerequisites
- Ability to modify the HTML content of your website.
- Access to a Cognigy instance with a Webchat v3 endpoint.
- Familiarity with Webchat v3 embedding parameters. Keep in mind that:
- Specifying parameters in the embedding code overwrites parameters configured in the endpoint settings.
- Some settings are specific to embedding parameters and aren’t available in the endpoint settings.
Embedding
Copy the HTML code from the Webchat v3 endpoint associated with the agent you want to deploy on your website:- In the navigation menu of the project, go to Deploy > Endpoints.
- On the Endpoints page, select a Webchat v3 endpoint that you recently created.
- On the Setup tab, in the Integration section, go to Embedding HTML and click Show embedding HTML snippet.
- Copy the HTML code.
-
The HTML code contains the following entities:
- The Webchat JavaScript bundle: hosted externally on GitHub, it ensures that your web page loads the latest version of Webchat v3. You can also deploy another Webchat v3 version by replacing
https://github.com/Cognigy/Webchat/releases/latest/download/webchat.jswithhttps://github.com/Cognigy/Webchat/releases/download/<webchat-version>/webchat.js, where<webchat-version>is the Webchat v3 version you want to use. For example, to use Webchat v3.2.0, enterhttps://github.com/Cognigy/Webchat/releases/download/v3.2.0/webchat.js. If you enter a specific version, make sure it’s the same as or later than the version in which the Webchat v3 features you use were introduced. Learn more about Webchat v3 versions on the Webchat v3 release page. - The
initWebchat()function: initializes the Cognigy Webchat widget with the provided configuration. You call theinitWebchat()function with the required argument, which is the URL of the Webchat v3 endpoint to connect to.
- The Webchat JavaScript bundle: hosted externally on GitHub, it ensures that your web page loads the latest version of Webchat v3. You can also deploy another Webchat v3 version by replacing
Include custom plugins and stylesheets
If you have custom plugins or stylesheets for Webchat, include them by adding the appropriate<script> and <link> tags, respectively. Replace the placeholders with the paths to your custom files.
Customize Webchat settings
You can customize the Webchat settings according to your requirements:colors: customize the Webchat v3 colors. In the example:primaryColor: change the primary color.
behavior: customize the Webchat v3 behavior by adjusting Webchat v3 endpoint settings. In the example:enableTypingIndicator: activate a typing indicator that shows when the agent is replying.messageDelay: set the time interval, in milliseconds, between the agent’s messages.enableSTT: enable the speech-to-text button in the Reply field of the chat. Mozilla Firefox doesn’t support this parameter.
embeddingConfiguration: activate settings related to Webchat browser embedding. These settings aren’t configurable in the endpoint editor.awaitEndpointConfig: wait until the endpoint configuration loads. This setting is required for the maintenance settings.
maintenance: configure maintenance mode to prevent users from using Webchat during maintenance. In the example:mode: set how Webchat behaves during maintenance mode. Choose tohidethe Webchat widget,disableit, orinformthe user about maintenance mode.text: the text displayed to users during maintenance mode. For example:The agent is currently in maintenance mode, please try again later.title: the title displayed to users during maintenance mode if the mode is set toinform. For example,Maintenance hours. Leave empty for no header.
customAllowedHtmlTags: set a custom array of HTML tags that are allowed in Webchat widget messages. By default, Webchat allows a wide range of HTML tags. The array you set in this parameter overrides the default setting. To restrict the allowed HTML tags for security reasons, use this parameter to include only the tags you want to allow.
RTL configuration
By default, the Webchat widget uses the LTR (left-to-right) layout. To override this setting for languages that use RTL (right-to-left), add the attributedir="rtl" to the <html> tag on the web page where the widget is placed.
For example, for a web page in Arabic, use <html lang="ar" dir="rtl">.
Test Webchat
After you implement the code, open your web page in a browser to test that Webchat works as expected.- LTR (left-to-right) layout
- RTL (right-to-left) layout
What’s next?
Customize Webchat further to align with your brand identity and meet specific interaction goals:- Webchat API. Use the Webchat API to create tightly coupled integrations.
- CSS customization. Customize the look and feel of the Webchat to match the design language of your website.
- Analytics API. Get notified and react to events that happen in your Webchat.
- Custom avatars. Change the avatar of the agent or user during the conversation.