The hosted script exposes one public initializer: window.initKommanderChatbot. Load https://app.kommander.ai/chatbot.js, then call the initializer after the script has finished loading.
Public Initializer
window.initKommanderChatbot(options: KommanderWidgetInitOptions): void | Promise<void>;type KommanderWidgetInitOptions = {
userId?: string;
organizationId?: string;
trialMode?: boolean;
forceReset?: boolean;
preloadSettings?: Record<string, unknown>;
userData?: Record<string, unknown>;
identity?: {
id: string;
email: string;
userHash: string;
};
audience?: string;
timer?: boolean;
timerEnabled?: boolean;
containerId?: string;
display?: 'floating' | 'page';
language?: string;
};Options
| Option | Use |
|---|---|
userId | Loads a personal assistant. Use the value shown in the embed snippet. |
organizationId | Loads an organization-owned assistant. Prefer this for team workspaces when provided. |
containerId | Mounts into a custom container ID. Defaults to kommander-chatbot. |
forceReset | Unmounts and remounts an existing widget instance. Use when visitor identity changes. |
userData | Non-secret analytics and routing attributes. |
identity | Server-generated signed visitor identity. |
audience | The visitor’s knowledge audience, such as 'licenza-movolab'. Answers use the shared knowledge plus the documents and FAQs tagged with this audience in Training; without it, only shared knowledge is used. It selects content, it is not access control: never tag secret documents. |
timerEnabled | Shows response latency timing when enabled. |
timer | Backward-compatible alias for timerEnabled: true. |
display | floating (default) shows the chat bubble. page fills the containerId element, always open, with the visitor’s conversations in a sidebar. |
language | Pins the widget to one language, such as your page’s locale ('it', 'en'). It replaces the browser language, the dashboard language and the guess from the visitor’s first message. For replies to follow it too, turn off Automatic language detection in Settings. Unsupported codes are ignored. |
Full-Page Chat
Use display: 'page' for a dedicated assistant page in your app. Give the
container the height it should fill:
<div id="assistant" style="height: calc(100vh - 64px)"></div>
<script>
window.initKommanderChatbot({
organizationId: 'YOUR_ORGANIZATION_ID',
containerId: 'assistant',
display: 'page',
forceReset: true,
});
</script>Only one widget instance runs per page, so a single-page app that shows the
floating bubble elsewhere calls the initializer again with forceReset: true
when entering and leaving the assistant page.
preloadSettings and trialMode are used by Kommander.ai preview surfaces. Production embeds should normally rely on saved settings loaded by the widget.
Lifecycle
- The script resolves its own origin from the script URL.
- The initializer loads React when needed.
- The widget stylesheet is injected once as
kommander-style. - The target container is found or created.
- The widget mounts into the container.
- Conversation ID, anonymous end-user ID, and selected local state are kept in browser storage.
- Messages are submitted to Kommander.ai and assistant updates are retrieved by polling.
Single-Page Apps
Initialize the widget from a root shell or layout that persists across route changes.
const WIDGET_CONTAINER_ID = "kommander-chatbot";
export function mountWidget(identity?: KommanderWidgetInitOptions["identity"]) {
window.initKommanderChatbot?.({
userId: "YOUR_KOMMANDER_USER_ID",
containerId: WIDGET_CONTAINER_ID,
identity,
forceReset: Boolean(identity),
});
}Do not call the initializer on every client-side route change. If a route change only changes the URL, the existing widget can stay mounted.
State Changes
| Change | Recommended handling |
|---|---|
| Anonymous visitor signs in | Fetch signed identity from your backend, then call with forceReset: true. |
| Visitor signs out | Call with forceReset: true and omit identity. |
| Visitor switches account | Fetch a new signed identity and call with forceReset: true. |
| Theme or color changes in Kommander.ai | Reload the host page to validate the saved widget settings. |
| Host route changes | Keep the widget mounted unless the assistant context must change. |
Limits
The widget does not expose public methods for open, close, sendMessage, or reading conversation messages. Use product settings, customer-data connectors, callback request automation, and Kommander.ai APIs for supported integration points.