ON Web Chat Client
Embed your chatbot on a website with our Web Chat Client.
Last updated
Embed your chatbot on a website with our Web Chat Client.
Last updated
The ON Web Chat Client is a versatile and easy-to-use that enables you to seamlessly integrate an ON chatbot into your website or mobile app. It can be displayed as a widget or a full conversation window, adaptable to various surfaces on your site and app. This guide will walk you through the steps to embed the chatbot, ensuring a smooth integration with your web application or mobile app through configurations and advanced features.
Embed our chatbot effortlessly on your website with our simple integration options. Choose from the following supported options:
recommended for most integrations
for older versions of Wordpress
tailored for React applications
The most straightforward way to add our chatbot to your website is by using our embed script. Simply place the following snippet on any page where you want the chatbot to appear:
Remember to replace YOUR_UNIQUE_CLIENT_ID
with the ID provided by our Customer Success team.
If you're using an older version of WordPress that doesn't recognize the on-chat-bot-client
tag, use this alternative JavaScript approach:
Remember to replace YOUR_UNIQUE_CLIENT_ID
with the ID provided by our Customer Success team.
Should you require more control over the web component distribution, or if your application is in React, we also make available our web component as an NPM package.
To install, simply run:
Then import our module in your javascript bundle:
Our NPM package includes a React component that wraps around our web component, allowing direct usage in your React application.
Our web chat client offers a range of configurable options, allowing you to tailor the client's behavior and appearance to suit your website's needs. You can set these options either as attributes passed to the <on-chat-bot-client>
HTML tag (using kebab-case
) or as properties in JavaScript (using camelCase
).
The display-mode
attribute controls the client's appearance on your site, with three options:
FULL_SCREEN (default): Displays the chatbot as a regular HTML box element, suitable for any website surface (e.g., a sidebar).
WIDGET: Shows a persistent button in the bottom right corner, opening a chat window upon interaction.
WIDGET_WITHOUT_BUTTON: Similar to WIDGET, but without the persistent button. This mode requires you to programmatically open the widget using a custom button or call to action.
Use should-auto-open
and should-auto-open-mobile
to have the chat window open automatically upon loading. This is particularly effective in widget mode.
Auto-opening on mobile may take over the entire screen, which may not be ideal for all sites.
Set an initial-prompt
attribute to send a predefined message to the bot as it initializes, guiding the initial user interaction (e.g., starting with a "new arrivals" message):
Example CSS:
Important CSS custom properties are documented below:
--on-chat-font-family
--on-chat-widget-bottom
--on-chat-widget-button-size
--on-chat-widget-right
--on-chat-widget-top-offset
--on-chat-widget-z-index
You can programmatically open the chat window in widget mode using our public methods, accessible via JavaScript.
Programmatically open only has an effect when the client is displayed in widget mode.
close()
Closes the chat window popup.
open()
Opens the chat window popup.
toggle()
Toggles the chat window state; opens it if closed and vice versa.
You will need to query for the Web Chat Client element in javascript, like so:
The web chat client dispatches several JavaScript events that you can listen for, allowing you to respond to chat interactions.
on-chat-card-link-click
{
cta: string;
href: string;
label: string;
}
Dispatched when a user clicks on one of our link attachment cards. The event payload contains the cta
in the card button, the card label
and the href
URL where the user navigated to.
on-chat-widget-close
null
Dispatched when the chat popup window is closed.
on-chat-widget-open
null
Dispatched when the chat popup window is opened.
on-client-send-message
{
message: string;
}
Dispatched when the user sends a message, either by clicking on a quick reply, or by typing on the input box and hitting the send button. The event payload contains the string the user sent to the bot.
Use the dispatched events by our Web Chat Client to track user interactions with your preferred analytics tools.
For example, you could integrate with Google Tag Manager using something like the following:
A conversational deep link is a URL or hyperlink that directs users to a specific point within our ON Web Chat UI. These links serve as powerful tools to guide users directly to specific point in the bot.
Note: Use the webpage where the bot is embedded as the base URL.
Add an ?on_should_auto_open=true
URL parameter if you want the chat to open automatically when the page loads.
For auto open on mobile, include: ?on_should_auto_open=true&on_should_auto_open_mobile=true
Add an &on_initial_prompt=xxx
URL parameter with the desired value to feed to the bot, following URL encoding rules.
Take the basic webview link accessible in the ON Portal.
Add an &initial_prompt=xxx
URL parameter with the desired text input for the bot.
Remember to URL encode the text, replacing special characters with their URL equivalent.
For example, if the initial prompt is "Mobile Ticketing Guide," it becomes "mobile%20ticketing%20guide
"
Personalize the look of your chat client with . You can add these to a style tag in your HTML or declare them in your external stylesheets.
The to use when rendering text within the chat window.
Sets the space between the widget button and the bottom of the screen, specified as a .
Determines the size of the widget button or the maximum height for a custom image button, specified as a .
Sets the space between the widget button and the right side of the screen, specified as a .
Defines the minimum space to be maintained between the top of the screen and the widget, ensuring it doesn't overlap with key elements like a tall navigation bar. Specified as a .
The of the chat widget and chat window popup. Sets the stacking order, ensuring the chat is always visible above other elements.