Besides its configuration attributes, the widget adds two globals to window once its script has loaded:
GlobalUse it for
window.KeluThe six core functions and every event, called as Kelu("open", { query }) or Kelu.open(). Works before the script loads with a preinitialization stub. Same shape as kapa.ai’s window.Kapa
window.KeluWidgetThe full API: init(), open, close, expand, ask, reset, change source groups, set the signed-in user, subscribe to events
Both drive the same widget and share one set of event subscriptions.
  • Functions: open, close, render and unmount the widget, and change which source groups it answers from.
  • Events: every interaction, from the panel opening to an answer being rated, for Segment, Mixpanel, Amplitude or your own endpoint.
  • Preinitialization: call functions and subscribe to events before the script has loaded.
  • Widget lifecycle: render and unmount by hand, for single-page apps that show the widget on some routes only.

The two globals side by side

window.Kelu("open", { mode: "ai", query: "How do I rotate a key?", submit: true });
window.Kelu("onAskAIAnswerCompleted", (payload) => console.log(payload.answer));

window.Kelu.open({ mode: "search", query: "rate limits" });
window.Kelu.setSourceGroupIDs(["group-id-1"]);
Two differences:
  • window.Kelu waits for the widget. Kelu("open") called while the widget is still loading opens it once it is ready. KeluWidget.open() at that moment does nothing.
  • Spelling. window.Kelu has setSourceGroupIDs; window.KeluWidget has setSourceGroupIds.
Code written for kapa.ai’s window.Kapa works with window.Kelu once you change the name. The widget does not define window.Kapa.
The Support Form Deflector has its own global, window.KeluFormDeflector. See Rendering manually.