sgiant-ai-widget

A framework-agnostic AI chat widget. This page uses no bundler and no build step.

Everything below this line is the whole integration. The bubble in the corner is real — open it and send a message.

<script src="sgiant-ai-widget.global.js"></script>
<script>
  SgiantAiWidget.createAiChatWidget({
    endpoint: "https://your-backend.example.com/chat",
  });
</script>

About this demo: there is no server behind this page — it is served as a static file. So it installs a small stub that answers the widget's own request format (newline-delimited JSON) with a canned reply, streamed a word at a time. That stub is at the bottom of this file and is about fifteen lines; your real backend replaces it. The protocol it implements is documented in BACKEND.md.

More examples

What a backend has to do

Answer one POST with a stream of JSON lines. Four frame types matter: {"type":"text","d":"…"} to append text, {"threadId":"…"} to name the conversation, {"type":"done"} to end the turn, and {"type":"error","message":"…"} if it fails.