The hosted widget manages its own conversation state, message polling, and operator handoff UI. For host-page analytics, wrap initialization in your own small adapter and emit events around script load, initialization, sign-in changes, and route changes.

TypeScript

Lifecycle Events to Track

EventWhen to emitUseful properties
script_loadedchatbot.js load event fires.Script URL, page path.
initializedinitKommanderChatbot has been called.userId, organizationId, signed-in state.
identity_changedVisitor signs in, signs out, or switches account.Signed-in state, account ID if non-sensitive.
resetYou reinitialize with forceReset: true.Reason, previous signed-in state.

Conversation Callbacks

Conversation and message state is owned by Kommander.ai. The widget stores local conversation continuity and sends messages to Kommander.ai APIs. If you need business callbacks, configure them as product features instead of reading widget internals:

  • Use customer-data connectors for authenticated order, account, or ticket lookups.
  • Use callback request automation when visitors ask for human follow-up.
  • Use Conversations in Kommander.ai for operator review and handoff.
  • Use your analytics adapter for page-level events such as script load and initialization.

Identity Change Callback

When your application changes identity after the widget has already loaded, reinitialize with forceReset: true and emit your own event.

window.initKommanderChatbot({ userId: "YOUR_KOMMANDER_USER_ID", forceReset: true, identity: signedIdentity }); window.dispatchEvent( new CustomEvent("kommander:widget", { detail: { type: "identity_changed", signedIn: true } }) );

Security Notes

  • Do not use client-side events as proof of identity.
  • Do not put HMAC secrets or access tokens into event payloads.
  • Do not scrape widget DOM for messages; use Kommander.ai product surfaces and APIs for conversation records.
  • Treat analytics callbacks as best-effort telemetry, not authorization.