14 days freeStart now
Docs

Web chat JavaScript API

For developers. Tell the web chat who your signed-in visitor is, which pages of your site it may open, open it from your own button and fix its language.

Once the web chat is on your site, your pages have a window.KW object. Use it to pass the agent what your site already knows, and to let the agent move the visitor around your site.

Install the script

The web chat page in Komplian gives you this tag with your own widget ID. Paste it on every page where the chat should appear.

html
<script src="https://api.komplian.com/widget.js" data-widget-id="YOUR_WIDGET_ID" async></script>
AttributeWhat it does
data-widget-idYour web chat. Required. Copy it from the web chat page in Komplian.
data-languageOptional. es or en. Sets the language of the chat's own texts until the conversation has a language.
asyncLoads the chat without slowing your page.

Methods

MethodWhat it does
KW.identify({...})Tells the agent who the visitor is.
KW.setCapabilities({...})Lists the pages of your site the agent may send the visitor to.
KW.toggle()Opens the chat, or closes it if it is open.

Identify the visitor

Call KW.identify when the visitor is signed in to your site.

js
KW.identify({
  externalId: 'user_123',
  email: 'ana@example.com',
  name: 'Ana Pérez',
  phone: '+34600000000',
  plan: 'premium',
  accountId: 'acct_42',
  customFields: { orders: 7, vip: true }
});
FieldWhat it holds
externalIdThe visitor's ID in your system.
email, name, phoneTheir contact details.
planTheir plan or tier in your product.
accountIdThe account or company they belong to in your system.
customFieldsUp to 20 extra keys. A key uses letters, numbers, _, . or -. Each value is text, a number or true/false.

These details come from your page, so Komplian treats them as unverified context. The agent uses them to answer, but they do not prove who the visitor is.

Let the agent use your site

Call KW.setCapabilities to list the pages of your site the agent may send the visitor to.

js
KW.setCapabilities({
  navigate: ['/pricing', '/account/orders']
});
KeyWhat it holdsLimit
navigatePaths on your own site, starting with /. Any other address is ignored.Up to 40 paths.

When the agent suggests one of these pages, the chat shows a button to open it. When the visitor presses it, the chat opens the page. Your page also receives a browser message with source: 'komplian-widget', type: 'komplian-host-actions' and actions: [{ kind: 'navigate', path }].

Open the chat from your own button

html
<button onclick="KW.toggle()">Chat with us</button>
Something here does not match what you see in Komplian? Tell usUpdated 4 November 2026

© 2026 Komplian AI Solutions, S.L. All rights reserved.

Web chat JavaScript API · Komplian Docs