Skip to main content
The drop-in widget is a self-contained script that injects a floating chat button into any webpage. Click the preview above to see exactly what your users will see before reading a line of code.

Installation

Paste these two tags before </body> in your HTML:
The widget loads asynchronously and does not block your page render.
During development, issue an hk_test_ credential from the admin panel instead of a live hk_live_ one. Sandbox is a property of the credential, not a different base URL — you call the same https://api.humain.ai host either way. Sandbox sessions don’t consume production LLM credits and aren’t billed. See Sandbox mode.
Never expose live credentials in client-side code. Your hk_live_… token is a long-lived secret. In browser environments, either proxy API calls through your own server or issue an hk_test_… (sandbox) credential instead for public-facing demos. Treat it like a password.
If you are using a bundler (webpack, Vite, Rollup), install the npm package instead of the CDN script and call init() in your entry point:

Configuration options

Prefer a visual workflow? The Widget Interface Builder lets you configure every option below against a live preview and copies out ready-to-paste install code.

Programmatic control

Use the HumainWidget object to open, close, or destroy the widget from your own code:

Event callbacks

Pass callbacks to HumainWidget.init() to react to user interactions:

Advanced topics

If your site uses a Content-Security-Policy header, add the following directives to allow the widget to load and communicate:
There is no separate sandbox host to allow-list — sandbox vs. live is determined by which credential (hk_test_ vs hk_live_) the widget is configured with, not a different URL.The widget does not use iframes or inline eval(). If you use a strict script-src policy, you may need to add a nonce or hash for the inline <script> that calls HumainWidget.init().
For maximum page performance, load the widget script asynchronously and defer initialisation until after the page is interactive:
You can render multiple independent widget instances with different credentials (e.g. one for support and one for sales). Use HumainWidget.create() instead of HumainWidget.init():
Each instance is independent and can be controlled separately via the returned object.