Prerequisites
- Basic understanding of JavaScript and npm. Familiarity with how to run a JavaScript project, for example, using
npm start
or similar commands. - A JavaScript project set up with npm and the ability to modify it.
- Access to a Cognigy.AI instance with the 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.
Restrictions
- If your app uses React, the React version must be earlier than 19.0; 19.0 isn’t allowed.
Embedding
To embed Webchat v3 in your JavaScript project, follow these steps:-
Install the Webchat npm package:
-
Import and initialize the Webchat widget in your JavaScript code:
- ESM (requires React)
- UMD (includes React)
When using the ESM build in a non-React project, you need to include React and ReactDOM manually:
Include Custom Plugins and Stylesheets
If you have custom plugins or stylesheets:Customize Webchat Settings
You can customize the widget using a configuration object passed toinitWebchat
:
RTL (Right-to-Left) Configuration
For RTL languages, ensure the HTML root element has thedir="rtl"
attribute:
Test Webchat
Run your JavaScript project and verify the widget loads and interacts correctly.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 bot or user during the conversation.