npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@squadico/chatbot

v1.8.1

Published

Chatbot Squadico — web component (HTML, Next.js, Vue 2, Vue 3)

Readme

@squadico/chatbot

Standalone web component for the Squadico assistant: a floating button that opens the chatbot in a sidebar on the right of the screen. Installable on any front end — plain HTML, Next.js, Vue 2, Vue 3 — without imposing a framework.

The agent answering in it is built on Squadico, the no-code platform to create AI agents that know your documents (knowledge base), act in your tools (tools and MCP) and answer on your website, Slack, WhatsApp or Microsoft Teams. See it live on the Crema Collective demo shop.

npm install @squadico/chatbot
<squadico-chatbot
  embed-key="sq_pub_paste_yours_here"
  context='{"workspace": {"id": "WS-1", "name": "Acme"}}'
></squadico-chatbot>

The embed-key is the public key of an application created in Squadico (back office → Applications → Installation).

What the package contains

| Entry point | Contents | For whom | |--------------------------------|------------------------------------------------|-------------------------------| | @squadico/chatbot | Registers <squadico-chatbot> | Every host | | @squadico/chatbot/react | <SquadicoChatbot />, typed props + callbacks | Next.js / React | | @squadico/chatbot/standalone | IIFE bundle, plus the extras file it fetches | classic <script> tag, CDN | | @squadico/chatbot/jsx | JSX types for the tag | React, using the tag directly |

The standalone build is two files in dist/: chatbot.global.js (the chat, Preact runtime and CSS included — under 30 kB gzip) and chatbot-widgets.global.js (the form, chart and tool-approval widgets, under 20 kB gzip), which the chat fetches from beside its own script the first time an answer needs it. That lookup reads document.currentScript, so prefer a classic <script>; loaded as type="module", the bundle finds itself in the page by its file name (chatbot.global.js, or the bare package URL on a CDN), so keep that name. Do not import it through a bundler, and keep both files side by side when self-hosting. The budgets are checked at build time by npm run size.

Implementation choices

  • Preact, not React. The API is React's (hooks, JSX) but the runtime weighs ~4 kB instead of ~45. It is bundled, never a peer dependency: the widget has to work on a Vue 2 host with no React runtime at all. The /react subpath is the only one importing react, as an optional peer dependency — it is a plain adapter around the custom element, not a second widget.
  • Shadow DOM. The widget styles do not leak into the page, and the page CSS cannot break the widget. The only extension points are the --sqc-* variables (see below).
  • No authentication at all. The widget is the public surface: it carries the application's embed-key, and the conversation it opens hands back a visitor token it presents on every later request. There is no bearer token to provide and no auth SDK to embed — which also means the key is safe in client HTML: it identifies the surface and authorizes nothing. Which pages may open a conversation with it is decided by the origin allowlist configured beside it in Squadico, and the browser is the one that tells the API where the page is.
  • The server names the conversation. Its id comes back from the open call: a visitor allowed to name their own conversation is a visitor choosing which one to read.
  • Who the visitor is, when the page knows. user — { id, name?, digest? } — is sent once, when the panel opens, and labels every message that person writes. Without a digest it is attribution and never authorization: anyone can open devtools and send another id, so it groups conversations and names turns in a transcript and decides nothing. Changing the id opens a new conversation rather than relabelling the old one. Optional by design: a marketing site has anonymous visitors, and their conversations are anonymous. See Verified visitors below for the application that asks for proof.
  • The conversation survives a reload. Its id and token are remembered for the tab, and a panel that finds one reads the transcript back rather than opening a second conversation and orphaning the first. Remembered per application and per claimed user: switch either and the panel starts a new conversation. Closing the tab starts one too — that token is the whole of the authorization on somebody's conversation, and it does not belong in a shared machine's storage for weeks.
  • Several agents, addressed by name. An application can hold more than one agent, each with a handle. A message leading with one goes to it — @sales what does the pro plan cost? — and anything else goes to the agent the organization set as the one answering plain text. Typing @ offers the handles that application chose to show; a name nobody answers to still gets an answer, with the names that would have worked shown under it. agent opens the panel on one of them, for a page that already knows who should answer.
  • The name is read from the message, server-side. The picker writes text and nothing else, so a handle chosen from the list is indistinguishable from one somebody spelled out — and a page cannot pick an agent the application does not offer.
  • No backdrop. The sidebar is a docked panel, not a modal: the page stays readable and clickable during the conversation.
  • Markdown rendered, never HTML injected. The agent's answers (headings, lists, listing tables, code, links) are converted into Preact nodes — hence escaped by construction — and hrefs are limited to http/https/mailto. No Markdown library: the subset the agent produces is enough.
  • Option lists = clickable options. - ( ) Delivery lines are a single choice: one button per option, and clicking sends the exact label as the turn's answer, since the agent matches it against the candidates by name. - [ ] Email lines are a multiple choice: tick any, then one button sends the labels joined by , . (x) / [x] pre-tick an option. Over 20 options, the list stays plain Markdown. Only the last answer's options are live — those of earlier turns stay displayed, locked on what was picked.
  • Closed questions = Yes / No buttons. When the last line of an answer ends with (yes/no), (oui/non) or (sí/no) (any case, spaces allowed around /), the marker is hidden and three buttons appear: Yes and No send yes or no in the visitor's language — the agent recognizes those bare answers without an LLM call — and "Propose something else" sends nothing: it hands the visitor the composer, empty. An agent that writes no marker still gets the buttons under a narrow set of confirmation phrasings (src/widgets/parse/confirm.ts): an open question must not show buttons.
  • Pending tool call = two buttons, and nothing written. A tool the organization marked as needing approval stops the turn before it runs: the answer is the agent's recap, and the frame beside it says which call is waiting. The widget shows "Yes, apply" and "No, cancel" and sends the decision to POST /public/conversations/{id}/approvals. Nothing has left for the tool until then — and typing something else instead is a decision too: the call was never approved, so it never runs, and the backend closes it as the new question goes out.
  • Several agents, one panel. An application can hold more than one agent, and a done frame says which one answered — so the transcript signs each answer with its own name and avatar, and chatbot-message carries the handle for a host page that wants to react per agent. A single-agent integration renders exactly as it did before.
  • An agent rail, once there are two. When the application lists two agents or more, the panel shows a thin column of their avatars down its left edge — the way a chat app lists its workspaces — with each name in a tooltip. The agent being talked to is marked; clicking another makes the next message lead with its handle, which is how the server already routes, and the conversation stays one thread. An avatar is the picture uploaded on the agent, or its initial on its colour (AgentHandle.avatarUrl, since 1.2.0).

Attributes

All optional. An attribute is a string; object or function values are set as properties (see the next section).

| Attribute | Default | Role | |-------------------|----------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | embed-key | — (required) | Public key of the Squadico application this page embeds. Safe in client HTML: it identifies the surface and authorizes nothing | | context | — | Page context, as a serialised JSON object. An entry is written "workspace": {"id": "…", "name": "…"} or, without its name, "workspaceId": "…" | | user | — | Who the page has signed in, as JSON: '{"id":"42","name":"Ada"}'. A label for the transcript, never an authorization — unless the application verifies visitors, where it also carries digest (see Verified visitors) | | agent | the application's default agent | Handle the panel opens on — agent="sales" on a pricing page. A name nobody answers to opens on the default agent rather than refusing; the visitor can address somebody else afterwards | | heading | translated (Assistant in en) | Header title. Empty hands it back to the translation | | subheading | Squadico | Subtitle | | assistant-name | translated (Assistant in en) | Name the assistant signs its answers with | | greeting | translated greeting | First message from the assistant | | placeholder | translated | Input placeholder | | suggestions | — | '["a","b"]' or a\|b | | width | min(392px, 100vw) | Panel width | | accent | black (white in dark) | Accent colour: the launcher, the visitor's bubbles and the main buttons. Text on it turns white or dark by itself | | theme | light | light | dark | auto | | position | bottom-right | Anchor of the floating button — and of the window with layout="floating" (the sidebar stays on the right) | | layout | sidebar | sidebar | floating. The sidebar takes the full height of the right edge; floating opens a rounded window in the launcher's corner, width wide and --sqc-height tall (640px, never more than the screen allows). Full screen on a phone either way | | open | absent | Presence = open at mount, for a first visit — a panel the user opened or closed themselves wins | | persist-open | true | The panel stays open (or closed) across a refresh or a page change, for the lifetime of the tab. persist-open="false" → the state starts from open on every mount | | show-context | true | Since 1.3.0. Shows the page context as chips under the header. show-context="false" hides them — the context is still sent with every message | | scope | absent | Since 1.5.0. Partitions remembered conversations the way the host does (an organization, a workspace). A conversation is only resumed under the scope it was opened with; changing it opens a new one | | locale | browser languages, then en | Interface language and date locale, in BCP-47. When absent, navigator.languages is read in the user's order of preference. Three languages ship — en, fr, es; anything else falls back to English. The region is only read by Intl: fr-CA = French copy, Canadian dates |

Icon of the floating button

The assistant spark by default. It is replaced by a child of the custom element carrying slot="launcher-icon" — not by an attribute: the widget renders inside a shadow root, where a host component cannot be mounted. Projected through the slot, the element stays in the page's tree (its CSS applies) and inherits the button color, so a currentColor is enough. The frame is 26 px.

<squadico-chatbot>
  <svg slot="launcher-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor">
    <path d="M3 12h13l-2-4h4l3 4v4H3z" />
  </svg>
</squadico-chatbot>

With the React wrapper the same thing is said as a prop — any React node, which the adapter projects into that slot:

<SquadicoChatbot launcherIcon={<BotIcon className="size-6" />} />

A child with no slot is projected nowhere, and therefore not displayed.

Properties and imperative API

const chatbot = document.querySelector('squadico-chatbot')

chatbot.context = {
  workspace: { id: 'WS-1', name: 'Acme' },
  anyOtherKey: 'forwarded as-is',
}
chatbot.embedKey = 'sq_pub_…'
chatbot.user = { id: 'host-42', name: 'Ada' } // or leave it out: anonymous

chatbot.openChat()
chatbot.closeChat()
chatbot.toggleChat()
chatbot.reset() // clears the history; the next message opens a new conversation
chatbot.sendMessage('List my agents') // opens the sidebar and sends
chatbot.open // boolean, read/write
chatbot.sessionId // string — the server's id, empty until the panel has opened

context, embedKey, user, getSubjectToken and agent may be written before the script has loaded — from a framework's first effect, say. Since 1.1.2 the element picks those values up when it is defined, and every later write reaches it too; before, an early write froze the value it held at that moment.

Events

Emitted on the element, bubbles + composed (they cross the shadow root).

| Event | detail | |----------------------------------|-----------------------------------| | chatbot-open / chatbot-close | { sessionId } | | chatbot-message | { role, content, sessionId, agent? } — agent is the handle that answered, on an application holding several | | chatbot-error | { message, status?, sessionId } | | chatbot-reset | { sessionId } |

CSS customisation

The variables are set on the host element, from the page:

squadico-chatbot {
  --sqc-accent: #2563eb; /* default: black, white in the dark theme */
  --sqc-width: 480px;
  --sqc-height: 560px; /* floating window only; default 640px */
  --sqc-radius: 12px; /* message bubbles and floating window; default 16px */
  --sqc-z: 9999;
  --sqc-font-family: 'Inter', sans-serif; /* default: Plus Jakarta Sans */
  --sqc-font-heading: 'Inter', sans-serif; /* header, Markdown headings; default: the body family */
  /* Series of the charts an agent draws, 1 to 6; defaults #2448cc, #0d7f78,
     #b86e00, #a92f73, #557c00, #5a6a80 */
  --sqc-series-1: #2563eb;
}

The widget applies the Squadico design system (v2, near-monochrome): black for action (slate-800 on hover), slate for surfaces, rules and secondary text, blue-600 for links, a neutral focus ring, and its radius hierarchy — 16px for the bubbles, 12px for buttons and inputs, full for the launcher and badges. The values are hard-copied into src/styles.css, and the package depends on no CSS variable of the host application. The typeface is referenced, never downloaded — the widget issues no font request. If the page loads Plus Jakarta Sans itself, font-family resolution crosses the shadow root and the widget benefits; otherwise the system fallbacks apply.

Widgets

Since 1.4.0 the package also exports the elements the chat draws an answer's interactive blocks with, for a host that has no chat around them (the Squadico console renders agent answers this way):

import {
  defineChatWidgets,
  defineWidgetExtras,
  parseAnswer,
  isLive,
  WIDGET_TAGS,
} from '@squadico/chatbot/widgets'

defineChatWidgets() // <sqc-table>, <sqc-choices>, <sqc-confirm>
defineWidgetExtras() // <sqc-form>, <sqc-chart>, <sqc-approval>

Both are idempotent and do nothing where there is no DOM, and importing the entry touches none either, so it is safe to import server-side (Next.js). parseAnswer(text, language, confirmable = true) splits an answer into Markdown and widget blocks, and says whether Yes / No buttons go under it; pass confirmable: false where none may (a visitor's own message, a turn still streaming), and the (yes/no) marker then stays in the text. isLive says whether a message is still answerable; WIDGET_TAGS maps each widget to its tag name. Types ship in dist/widgets/index.d.ts.

| Tag | Data property | | --------------- | ------------------------------------------------ | | sqc-table | table | | sqc-choices | options, multiple, checked | | sqc-confirm | none: Yes / No / Propose something else | | sqc-approval | call (the paused tool call) | | sqc-form | form (fields, as a FormSpec) | | sqc-chart | chart (spec), body (file text: string or Promise<string>), filename |

Every element takes these as properties, not attributes, plus locked (shown, no longer interactive) and language (en | fr | es). An answer leaves as a bubbling, composed DOM event: sqc-reply with { text } (the visitor's answer, which also locks the element), or sqc-decision with { approved } from sqc-approval. sqc-confirm's third button dispatches sqc-compose, with no detail: the host focuses its message composer (left empty), and the element stays live until the visitor's next message arrives. The elements are styled by the same --sqc-* variables as the chat, including --sqc-series-1 to --sqc-series-6 for the charts; outside a chat the fallbacks apply.

The standalone build is two files: chatbot.global.js (the chat) and chatbot-widgets.global.js (form, chart and approval, loaded by the chat on demand).

Integration

HTML / CDN

The standalone bundle is served from npm by jsDelivr and unpkg as soon as a version is published — there is nothing else to deploy. Add the script, then the tag, anywhere in the page:

<script src="https://cdn.jsdelivr.net/npm/@squadico/[email protected]/dist/chatbot.global.js"></script>
<squadico-chatbot
  embed-key="sq_pub_paste_yours_here"
  context='{"workspaceId":"WS-1"}'
></squadico-chatbot>

unpkg works the same way: https://unpkg.com/@squadico/[email protected]/dist/chatbot.global.js.

The form an agent may ask the visitor to fill in, the charts it draws and the Yes / No card of a tool call waiting on the visitor's approval live in a second file, chatbot-widgets.global.js, published next to chatbot.global.js in dist/. The chat loads it on its own, from the same folder as its own script, the first time an answer holds a form, a chart or an approval — so it is never fetched by a conversation that does not need it. A self-hosted copy must therefore keep both files side by side. The short CDN URL (https://cdn.jsdelivr.net/npm/@squadico/[email protected], served through the package's jsdelivr / unpkg fields) works too: a script URL that does not end in .js is taken as the package root, and the extras file is fetched from its dist/ folder. The injected script carries the main script's nonce, so a CSP built on nonces covers it. Until the file arrives — or if it cannot — a form shows its field labels and a chart its filename, as plain text.

Pin the version. @1.8.1 never changes, so a release cannot alter a customer page. Leaving it out (@squadico/chatbot/dist/…) serves the latest version, cached by jsDelivr for up to 12 hours; a range such as @1 follows the newest 1.x.y. Prefer a pinned version in production.

Before the page goes live:

  1. Embed key — create the application in Squadico and paste its sq_pub_… key into embed-key.
  2. Origin — the page's origin (https://www.example.com, no path) has to be on the application's allowlist, or the API answers origin_not_allowed. It also has to be in the API's CORS_ORIGINS.
  3. Content Security Policy — a site that sets one needs script-src https://cdn.jsdelivr.net (or https://unpkg.com) and connect-src https://api.squadico.com. The widget loads no font and no other asset.
  4. Check — the browser console should show no error, and the floating button appears at the bottom right. Properties and events are the same as in the other integrations (see Properties and imperative API and Events).

Next.js

From a client component (the wrapper already carries 'use client'):

'use client'
import { SquadicoChatbot } from '@squadico/chatbot/react'

export function Assistant({ workspace, me }: { workspace: Workspace; me?: User }) {
  return (
    <SquadicoChatbot
      embedKey={process.env.NEXT_PUBLIC_SQUADICO_EMBED_KEY}
      context={{ workspace }}
      // Optional: names this visitor's turns in the transcript. A label, not a
      // login — leave it out and the conversation is anonymous.
      user={me ? { id: me.id, name: me.name } : undefined}
      onMessage={(detail) => analytics.track('chatbot_message', detail)}
    />
  )
}

Importing the main entry point is safe server-side too: registering the custom element is guarded by a typeof window check, so no ReferenceError: HTMLElement is not defined during SSR.

Vue 3

Declare the tag as a custom element so the compiler does not look for a Vue component:

// vite.config.ts
vue({
  template: {
    compilerOptions: { isCustomElement: (tag) => tag === 'squadico-chatbot' },
  },
})
<script setup lang="ts">
import '@squadico/chatbot'
import { ref, watchEffect } from 'vue'
import type { SquadicoChatbotElement } from '@squadico/chatbot'

const chatbot = ref<SquadicoChatbotElement | null>(null)
const props = defineProps<{ workspace: { id: string; name: string } }>()

watchEffect(() => {
  if (chatbot.value) chatbot.value.context = { workspace: props.workspace }
})
</script>

<template>
  <squadico-chatbot
    ref="chatbot"
    embed-key="sq_pub_paste_yours_here"
    @chatbot-message="(e) => console.log(e.detail)"
  />
</template>

Vue 2

// main.js
Vue.config.ignoredElements = ['squadico-chatbot']

The package exposes a CJS build, resolved by webpack 4, which ignores the exports.import field. The rest is identical to Vue 3: $refs to set context and user, @chatbot-message for the events.

Contract with the API

The widget talks directly to the Squadico API (FastAPI), at https://api.squadico.com — written {api} below — on the eight routes the public surface serves.

The API is not an option. There is no api-url attribute and no apiUrl prop: a page that could set one could point a Squadico panel at a server that is not Squadico's, and everybody embedding the widget talks to the same API anyway. The URL is written into the bundle at build time (config/api-url.ts); API_URL exports it for a page that wants to read it.

  • GET {api}/public/applications/{embed-key}?agent=sales — what the panel draws when it is shown, before anybody has typed anything: the answering agent's name and welcome message, the handle it answers on, the handles this application offers and the branding. Opens nothing — a visitor who clicks the launcher and leaves leaves no conversation behind. Same Origin check as opening
  • POST {api}/public/applications/{embed-key}/conversations — opens the conversation, on the first message or the first file. Body: { "user": { "id": "…", "name": "…" }, "agent": "sales" }, or {} for an anonymous visitor on the default agent. Answers the conversation's id, the visitor token, the answering agent's name and welcome message, the handle it opened on, the transcript as it stands, and the handles this application offers (empty until an organization ticks one). The browser's Origin decides whether the page may do this at all
  • POST {api}/public/conversations/{id}/messages — one turn, streamed. Body: { "content": "…", "context": { … }, "attachment_ids": ["…"] }. Header: X-Visitor-Token. A turn carries the files it names: anything else the conversation is still holding stays where it is. content may be empty when the turn names a file — a file on its own is a question about the file — and a turn carrying neither words nor a file is refused
  • GET {api}/public/conversations/{id} — the transcript, read back after a reload. Header: X-Visitor-Token. The open response minus the token, which the caller already holds
  • POST {api}/public/conversations/{id}/approvals — the decision on a paused tool call: { "tool_call_id": "…", "approved": true }, same header, same frames
  • POST {api}/public/conversations/{id}/attachments — one file, multipart/form-data under the field file, same header. Answers what was accepted: the id the message will name, and the kind and type read off the bytes on the server — never what the browser announced. Refusals are distinct on purpose: 415 the format, 413 the size, 409 this message already carries as many files as it may, 422 the file would not read
  • DELETE {api}/public/conversations/{id}/attachments/{attachment-id} — takes a file back out of the draft, bytes and all. 409 once it has been sent: a file that travelled with a turn is part of the transcript
  • GET {api}/public/conversations/{id}/attachments/{attachment-id}/content — the bytes, same header

The download route is why an attachment carries no URL. It is opened by the visitor token, which travels in a header — and a header is exactly what an <img src> cannot send, so the panel fetches the file itself and draws an object URL it revokes when the bubble goes. An integration reading the transcript has to do the same.

The done frame of a message that addressed a name nobody answers to also carries unknown_handle and the handles that do — beside the answer the default agent gave, never instead of it.

Both streamed routes answer text/event-stream with four named events:

event: token
data: {"text":"Le catalogue "}

event: done
data: {"id":"…","role":"assistant","content":"…","agent":{"handle":"support",…}}

event: approval_required
data: {"tool_call_id":"call-1","tool":"create_ticket","arguments":{…}}

event: error
data: {"detail":"The agent could not finish answering"}

done carries the stored turn — the one a reload would show — and agent when the application holds several. An error frame is a failure that happened after the 200 was on the wire: there is no status code left to fail with, so it travels in the stream.

An agent that leads a team adds three more:

event: handoff
data: {"to_agent_name":"Technique","reason":"Une panne technique."}

event: escalated
data: {}

event: held
data: {}

And while nothing can be read yet — the agent searching its knowledge, following a skill, asking a member of its team or using a tool — the stream says so:

event: progress
data: {"activity":"knowledge"}

activity is knowledge, skill, delegation or tool: a kind of work, never the tool's name nor what it was called with. One frame per tool call, before the answer starts; a client that does not know the frame skips it and loses nothing.

handoff comes before the answer of the agent the conversation was passed to, which has no handle on the application: the widget signs that answer with to_agent_name. escalated follows the answer of an agent that handed the conversation to a human of the organization; from then on a message is answered with held alone — it was kept for that human and no agent ran. The replay route says the same with "handling": "awaiting_human" or "human", and the widget reads the conversation again every five seconds until the agents have it back, showing the colleague's replies signed with their name ("kind": "human", "author_name").

Refusals before the stream starts are JSON: { "detail": …, "code": … }. Three codes a page reacts to rather than just logging:

| code | What happened | What to do | |----------------------------|------------------------------------------------------------|-----------------------------------| | origin_not_allowed | This page's origin is not on the application's allowlist | Ask for the domain to be added | | application_has_no_agent | The application is there and nothing answers on it yet | Nothing: it is being set up | | conversation_retired | The embed key was rotated after this conversation opened | Open a new conversation (the widget does this by itself, and asks the question again) | | identity_not_verified | The application verifies visitors and the claim had no valid digest | Fix the digest on your server (see Verified visitors) | | public_rate_limited | A budget is spent — 429, with a Retry-After header | Wait what the header says | | subject_token_needs_verified_identity | getSubjectToken returned a token on a conversation whose user was not verified | Send a digest with user (see Acting as your signed-in user) |

Three things to watch:

  • Auth: there is none to arrange. The embed-key is public and the visitor token is handed out by the API. The one bearer a page may hand over is its own user's, for connectors acting as them — see Acting as your signed-in user.
  • Origins: the page's origin has to be listed on the application in Squadico — the panel is a custom element rendered inline, so the browser sends the host page's own origin. Moving it into an iframe would break that check, and the open call then has to move back into the host-page script.
  • CORS: the host page's origin also has to be in the API's CORS_ORIGINS.
  • Context keys: the widget filters nothing and forwards the context as-is. It reaches the agent as data — a labelled block beside the question, never folded into its instructions — and the API bounds it rather than believing it. The only shaping: a named object is split before sending (workspace: { id, name } → workspaceId + workspaceName), the form the agent reads.

Verified visitors

An application can be switched to verified attribution in the Squadico back office. From then on a claim has to arrive with an HMAC of the id, computed under the identity secret that screen hands over once — and a claim without one, or with a wrong one, is refused with identity_not_verified rather than quietly recorded as a label.

Compute it on your server. A digest a browser can produce is a digest anybody can produce, and the secret would be sitting in the page's source:

// Node, wherever the page is rendered — never in the browser
import { createHmac } from 'node:crypto'

const digest = createHmac('sha256', process.env.SQUADICO_IDENTITY_SECRET)
  .update(user.id)
  .digest('hex')
<squadico-chatbot
  embed-key="sq_pub_…"
  user='{"id":"host-42","name":"Ada","digest":"a3f1…"}'
></squadico-chatbot>

The digest is over the id alone, so it can be computed once when the page is rendered. Nothing else changes: an anonymous visitor still opens a conversation on a verifying application, because requiring proof of an identity is not the same as requiring one.

Acting as your signed-in user

A connector (MCP server) can be set, in the Squadico back office, to act as the user signed in on your site: the API behind it then sees that user (sub), with their own rights and context, as if they had made the calls themselves. Your user never visits Squadico.

How it works — standard OAuth, no vendor assumed:

  1. Before each message, the panel calls getSubjectToken() and sends the token your site holds for the user (header X-Subject-Token).
  2. Squadico exchanges it at your authorization server for a token naming the same user and meant for the connector alone — OAuth 2.0 Token Exchange (RFC 8693), or the JWT bearer "on-behalf-of" grant (RFC 7523) for Microsoft Entra ID.
  3. The connector is called with that token. Your token itself is never sent to the connector, and never stored.
const chatbot = document.querySelector('squadico-chatbot')
// Called before every message: return the *current* token, refreshing it first
// if your auth library needs to. Return null when nobody is signed in.
chatbot.getSubjectToken = () => auth.getAccessToken()
// React
<SquadicoChatbot embedKey="sq_pub_…" user={user} getSubjectToken={() => auth.getAccessToken()} />

Requirements:

  • A verified user. The token is only accepted with a digest from your server (see Verified visitors); otherwise the message is refused with subject_token_needs_verified_identity.
  • An authorization server that can exchange tokens, and on it a confidential client for Squadico allowed to do so. Its id and secret go in the connector's OAuth settings in Squadico; how it exchanges is set beside them — grant, audience, scope, whether the connector's URL is sent as resource (RFC 8707), HTTP Basic or in-body client authentication. The defaults are plain RFC 8693 with HTTP Basic, which most servers accept as they are.
  • Optionally, the audience your token must carry. Set it in the connector's settings and Squadico refuses, before asking, any token whose aud does not name it — for authorization servers that exchange any token they issued.
  • On the connector, accept tokens addressed to it, and reach the API behind it with its own exchange rather than by forwarding the token as is.

Step-by-step setup for each identity provider: https://squadico.com/docs/token-exchange.

Where the usual servers differ:

| Authorization server | Grant | Typically set | |---|---|---| | Keycloak 26.2+ | RFC 8693 | Standard token exchange on the Squadico client; an audience mapper adding the Squadico client to your site's tokens; audience = the connector's client id | | Keycloak 23–26.1 | RFC 8693 (preview V1) | start with --features=token-exchange,admin-fine-grained-authz; token-exchange permission for the Squadico client on the connector's client; audience required; required token audience = the Squadico client id (V1 does not check it) | | Okta | RFC 8693 | scope required; audience = the authorization server's audience | | Microsoft Entra ID | On-behalf-of (RFC 7523) | scope = api://<connector app>/.default; untick resource | | Auth0, Ping, Curity, ForgeRock, Zitadel… | RFC 8693 | per the server's documentation; usually audience |

Context: named object or bare id

A host object can be named in two ways:

chatbot.context = { workspace: { id: 'WS-1', name: 'Acme' } } // named
chatbot.context = { workspaceId: 'WS-1' } // the id alone

The widget knows no domain entity: any key carrying a { id, name } object is displayed as a chip and split on the wire, and any key carrying a plain string is forwarded untouched. The named form should be preferred as soon as the page knows the name, which is the case as soon as it displays it: the panel chip then shows "Acme" instead of a UUID, and the agent can name the object without reading it back.

Development

The development server is the one place the API can be moved: it talks to http://localhost:8000 unless SQUADICO_API_URL says otherwise. A build ignores the variable — everything npm run build produces talks to https://api.squadico.com.

npm run dev         # minimal sandbox on :3010
SQUADICO_API_URL=https://staging.example npm run dev  # sandbox on another API
npm run build       # ESM + CJS + IIFE + .d.ts declarations
npm run size        # real gzip weight; budgets: 30 kB chatbot.global.js, 20 kB chatbot-widgets.global.js
npm run type-check  # tsc --noEmit
npm run test        # vitest run
npm run lint        # eslint

Publishing

.github/workflows/publish-chatbot.yml publishes the package to npm. Bump version in package.json, then run it by hand — Actions → Publish chatbot → Run workflow, on the branch to release from. Dry run packs without publishing. No tag is needed; pushing chatbot-v<version> publishes too.

The job runs the same checks as above — the chatbot job of ci.yml runs them on every pull request touching libs/chatbot — refuses a version already on the registry (and a tag that does not match package.json), and checks the bundle talks to the production API before publishing. It needs an NPM_TOKEN secret: an npm automation token allowed to publish @squadico/chatbot.

From a developer machine, make publish-chatbot runs the same checks and publishes with your own npm login (the account needs two-factor authentication for writes). make publish-chatbot DRY_RUN=true stops before the publish — the variable is spelled with an underscore; with a dash, make ignores it and publishes for real. make publish-chatbot-ci runs the workflow instead.

CDN

There is no separate CDN deployment: publishing to npm is what makes dist/chatbot.global.js available on jsDelivr and unpkg, through the jsdelivr and unpkg fields of package.json. Once a version is out, check it:

curl -I https://cdn.jsdelivr.net/npm/@squadico/chatbot@<version>/dist/chatbot.global.js

A new version can take a few minutes to show up. A published version is immutable on npm, so a mistake is fixed by publishing the next one.

The suite runs on vitest + jsdom against the real frame shapes: the HTTP client, the conversation's state machine, the composer's picker. type-check, lint and the size budget are guardrails beside it, not instead of it.