greatkb chat — demo

This page embeds the chat widget the same way any host site would. Click the launcher button in the bottom-right to open it.

Embed snippet

<script>
  (function(){
    var c = window.GreatKB = window.GreatKB || function(){(c.q=c.q||[]).push(arguments)};
    c.q = c.q || [];
    ["init","update","open","close","toggle","attach","on","off"].forEach(function(m){
      c[m] = c[m] || function(){
        var args = [m]; for (var i=0;i<arguments.length;i++) args.push(arguments[i]);
        c.q.push(args);
      };
    });
  })();
  GreatKB.init({
    kbId: "YOUR-KB-UUID",
    assistantName: "Aria",
    pageContext: "Short description of the current page.",
    theme: "auto",
  });
</script>
<script async src="https://chat.greatkb.com/widget.js"></script>

Config schema

interface GreatKBConfig {
  kbId: string;                       // required
  assistantName?: string;             // default "Assistant"
  pageContext?: string;               // sanitized + capped server-side
  theme?: "auto" | "light" | "dark";  // default "auto"
  launcher?: false | LauncherConfig;  // default = {} (floating button)
}

interface LauncherConfig {
  label?: string;                     // default "Chat"
  icon?: string;                      // SVG markup or https:// URL
  background?: string;                // CSS color, default "#2563eb"
  color?: string;                     // CSS color, default "#fff"
  position?: "bottom-right" | "bottom-left";
  attachTo?: string | Element;        // bind open() to a host element
}

Programmatic API

GreatKB.init(config)        // one-shot bootstrap
GreatKB.update(partial)     // change settings at runtime
GreatKB.open() / close() / toggle()
GreatKB.attach("#my-btn")   // bind a host element to toggle()
GreatKB.on("message", ({ role, text }) => console.log(role, text))
GreatKB.off("message", handler)

Recipes

Default floating launcher
GreatKB.init({ kbId: "..." });
Bring your own button
GreatKB.init({
  kbId: "...",
  launcher: false,
});
document.getElementById("help")
  .addEventListener("click", () => GreatKB.open());
// or:  GreatKB.attach("#help");
Branded floating launcher
GreatKB.init({
  kbId: "...",
  launcher: {
    label: "Ask Support",
    background: "#10b981",
    color: "#fff",
    position: "bottom-left",
  },
});

Full reference: see apps/chat/README.md.