Chatbot
Add a Keural chatbot button to your organization's website with an install code.
Add a Keural chatbot to your organization's website. When a visitor presses the button in a corner of the screen, the chatbot window opens. Install it by pasting the install code created on the admin screen into your website.
Creating a chatbot
- An organization owner or admin presses + Add Chatbot under Organization management → Chatbots.
- Enter a chatbot name and a default domain (for example,
https://example.com) and register it. - Open the chatbot and set up the three tabs.
| Tab | Settings |
|---|---|
| Token & Install | Check the token, and copy the install code (HTML · Next.js) |
| Chatbot UI | Button image (PNG·JPG·GIF·WebP) and whether it is shown, chatbot name, header display, header expansion, header color, button color, button position (left or right), and horizontal and vertical offsets. Check with the preview |
| Advanced | Page addresses where the chatbot opens (allowed domains, up to 5) |
- Paste the install code into your website.
Install code
Copy the HTML or Next.js code from the Token & Install tab. The code consists of two parts.
- Loader: Creates the
Keuralfunction, and when the page has finished loading, loads the chatbot script (/plugin/keural-widget@1.0.1.js) asynchronously. Commands called before the script loads are queued and run in order. - Start command:
Keural('boot', { token: '…' }). The token starts withwgt_.
The script version is fixed in the address. When a new version is released, copy the install code again and replace it. If the install code is placed twice on the same page, the second one is ignored and an error is logged to the console.
<script id="keural-one-script">
/* Code copied from the Token & Install tab */
</script>In Next.js, add it with <Script id="keural-one-script" strategy="afterInteractive"> from next/script. To show the chatbot on every page, place it in the root layout.
Startup options
Values passed to boot take priority over the admin screen settings. Use them to change the appearance per page.
Keural('boot', {
token: 'wgt_…',
theme: 'system',
header: { enabled: true, extended: true, draggable: true, title: 'Customer support', color: '#495BD8' },
button: { visible: true, iconUrl: 'https://example.com/icon.png', color: '#495BD8', position: 'right', offsetX: 30, offsetY: 30 },
});| Option | Value | Name on the admin screen |
|---|---|---|
token | Required. The token from the install code | — |
theme | light · dark · system | — |
header.enabled | Show the header | Header display |
header.extended | Show the expand button in the header | Header expansion |
header.draggable | Move the window by dragging the header (default true) | — |
header.title | Header title | Chatbot name |
header.color | Header color | Header color |
button.visible | Show the button | Show button |
button.iconUrl | Button image address | Button image |
button.color | Button color | Button color |
button.position | left · right | Button position |
button.offsetX · button.offsetY | Distance from the screen edge (px) | X offset · Y offset |
The defaults for a newly created chatbot are: header display and expansion on, header and button color #495BD8, right side, offset 30px, and theme system.
Page control
| Call | Action |
|---|---|
Keural('open') · Keural.open() | Opens the chatbot window. |
Keural('close') · Keural.close() | Closes it. |
Keural('toggle') · Keural.toggle() | Closes it if it is open, and opens it if it is closed. |
Keural('reload') · Keural.reload() | Reloads the chatbot window. |
Keural('badge', n) · Keural.badge(n) | Shows a number badge on the button. |
Keural.isLoaded() | true when the script has fully loaded |
Keural.onOpen(cb) · Keural.onClose(cb) | Calls cb when the window opens or closes. |
Methods such as Keural.open() work only after the script has loaded. When you call them right after the page opens, use the function form such as Keural('open'), and the calls run in order.
<button onclick="Keural('open')">Contact us</button>You can also hide the default button (button.visible: false) and open the chatbot from a button on your page.
Screen size
The chatbot window is 390×800px, and if the screen width is 480px or less, it opens full screen. Enlarge the window with the expand button in the header.
Display domains
- The chatbot opens on pages with the same host as the default domain. Hosts are compared including the port, and letter case is not distinguished. Addresses with
www.and subdomains are different hosts. To test on a development server, create a separate chatbot with that address as its default domain. - The default domain cannot be changed after creation. To change it, create a new chatbot.
- If the allowed domains under Advanced are empty, the chatbot opens on all pages of the default domain. If allowed domains are entered, it opens only on pages starting with those addresses. Entering a path such as
https://example.com/helpnarrows it to pages under that path. Allowed domains start withhttp://orhttps://, and you can enter up to 5. - The token in the install code is exposed on the page. Connect only content that can be made public to the chatbot.
Content Security Policy (CSP)
If your site applies a Content-Security-Policy, allow the following. The addresses are based on keural.ai.
| Directive | What to allow |
|---|---|
script-src | https://keural.ai, and the inline script of the install code ('unsafe-inline' or a hash or nonce) |
connect-src | https://api.keural.ai |
frame-src | https://keural.ai |
style-src | 'unsafe-inline' or a nonce (the chatbot places styles on the page) |
img-src | The button image address, https://keural.ai, https://api.keural.ai |