Developer docs
Build Live Chat into your site and admin panel
One script tag for the widget, a small JavaScript API for your own buttons, single sign-on from your admin panel, and an MCP server so your AI assistant can do the wiring.
Add the widget
Paste this tag before </body> on every page that should show the chat. Find your Workspace ID in Settings › General, or copy the whole tag from Settings › Widget.
The script is small and loads nothing else until a visitor opens the chat. It works on any site: plain HTML, WordPress, Shopify, Next.js or a single-page app.
<script src="https://chat.hibira.io/w/v1.js"
data-workspace="ws_..." async></script>Add each site's address under Settings › Widget › Sites the widget may run on. The widget refuses other sites.
Widget options
Set these attributes on the script tag.
<script src="https://chat.hibira.io/w/v1.js"
data-workspace="ws_..."
data-color="#0f766e"
data-lang="ja"
async></script>| Attribute | What it does |
|---|---|
data-workspace | Required. Your Workspace ID (ws_...). |
data-color | The button and header colour as a hex value, such as #0f766e. Default #4f46e5. |
data-lang | The widget's language: en, ja, ko, zh-TW, zh-CN, th or vi. Default: the visitor's browser language. |
data-launcher="none" | Leaves out the round chat button, so your page opens the chat with its own buttons (see JavaScript API). |
nonce | On a page with a strict Content-Security-Policy, the widget puts the script tag's nonce on the styles and scripts it adds. |
JavaScript API
Once the script has loaded, window.HibiraLiveChat lets your page open and close the chat. Listen for the hibira-livechat:ready event if your code may run before the widget loads.
<button type="button" id="talk-to-sales">Talk to sales</button>
<script src="https://chat.hibira.io/w/v1.js"
data-workspace="ws_..." data-launcher="none" async></script>
<script>
document.getElementById("talk-to-sales").addEventListener("click", function () {
if (window.HibiraLiveChat) window.HibiraLiveChat.open({ topic: "sales" });
});
window.addEventListener("hibira-livechat:ready", function () {
// The widget is loaded: HibiraLiveChat.open() and .close() work now.
});
</script>| Call or event | What it does |
|---|---|
HibiraLiveChat.open() | Opens the chat panel. |
HibiraLiveChat.open({ topic: "sales" }) | Opens the chat and marks a new conversation as a sales inquiry, so your team sees it as one in the inbox. |
HibiraLiveChat.close() | Closes the chat panel. |
hibira-livechat:ready | A window event fired once the widget has loaded. |
hibira_chat_open, hibira_chat_start, hibira_chat_message, hibira_chat_rating | Google Analytics events sent to the gtag or Tag Manager already on your site, when you turn analytics on in Settings › Widget. Nothing personal is sent. |
Content-Security-Policy
If your site sends a strict Content-Security-Policy, allow the hosts below and put your page's nonce on the script tag. The widget passes that nonce on to everything it adds.
challenges.cloudflare.com runs the spam check on a new visitor's first message.
script-src 'nonce-R4nd0m' https://chat.hibira.io https://challenges.cloudflare.com;
style-src 'nonce-R4nd0m';
connect-src https://chat.hibira.io wss://*.hibira.io;
img-src https://chat.hibira.io data:;
frame-src https://challenges.cloudflare.com;
<script src="https://chat.hibira.io/w/v1.js" nonce="R4nd0m"
data-workspace="ws_..." async></script>Agent single sign-on (JWT) Starter and up
Let your staff go from your own admin panel straight into the Live Chat inbox, without a separate password. Your server signs a short-lived token for the signed-in staff member and sends them to Live Chat.
- Turn on single sign-on in Team › Single sign-on and copy the secret.
- Store the secret on your server only, for example in the HIBIRA_LIVECHAT_SSO_SECRET environment variable. Never put it in browser code.
- Add a link in your admin panel to a route of yours that checks the user is staff, signs the token below and redirects to /sso/jwt.
- The first time someone signs in, Live Chat adds them as an agent if a seat is free. Their role follows the token on every sign-in.
import crypto from "node:crypto";
const b64 = (v) => Buffer.from(JSON.stringify(v)).toString("base64url");
// Build a new URL on every click, behind your admin panel's own login.
export function liveChatSsoUrl(user) {
const now = Math.floor(Date.now() / 1000);
const head = b64({ alg: "HS256", typ: "JWT" });
const body = b64({
iss: "ws_...", // your Workspace ID
sub: String(user.id), // the user's ID in your system
email: user.email,
name: user.name,
role: user.isAdmin ? "admin" : "agent",
jti: crypto.randomUUID(), // single use
iat: now,
exp: now + 120, // 5 minutes at most
});
const sig = crypto
.createHmac("sha256", process.env.HIBIRA_LIVECHAT_SSO_SECRET)
.update(head + "." + body)
.digest("base64url");
return "https://chat.hibira.io/sso/jwt?" + new URLSearchParams({
jwt: head + "." + body + "." + sig,
return_to: "/inbox",
});
}| Claim | Meaning |
|---|---|
iss | Required. Your Workspace ID. |
sub | Required. The user's ID in your system (up to 200 characters). It links the agent across sign-ins, even if the email changes. |
email | Required. The user's email address. |
name | Optional. The name shown to visitors and teammates. |
role | Optional. agent (default) or admin. |
jti | Required. A unique ID for this token (up to 128 characters). Each token works once. |
iat | Optional. When the token was signed, in Unix seconds. |
exp | Required. When the token expires, in Unix seconds: at most 5 minutes from now. |
- Sign with HS256 and send the token as ?jwt= to /sso/jwt. Add return_to with a path such as /inbox to choose where the agent lands.
- Clocks may differ by up to 30 seconds.
- After you rotate the secret, the previous one keeps working for 24 hours, so you can deploy the new one without downtime.
- Turn on "Only single sign-on" once it works: agents can then only sign in through your admin panel, while the owner can still use email.
Ready-made code for Node.js, Laravel, PHP, Python, Django, Rails, Go, Java and .NET is available through the MCP server below.
AI assistants (MCP)
The Live Chat MCP server lets an AI assistant such as Claude, Cursor or VS Code set up single sign-on in your own codebase. The assistant signs in with your Live Chat account in the browser; only the workspace owner and admins can approve it.
The SSO secret never passes through MCP. The assistant reads the setup, writes the code for your stack and checks a token it signed, without signing anyone in.
# Claude Code
claude mcp add --transport http hibira-live-chat https://chat.hibira.io/mcp
# Any client with remote MCP servers (Cursor, VS Code, ...)
{ "mcpServers": { "hibira-live-chat": { "url": "https://chat.hibira.io/mcp" } } }| Tool | What it does |
|---|---|
get_sso_setup | Whether single sign-on is on, the Workspace ID, the sign-in URL, the token's claims and limits, and free seats. |
get_sso_snippet | Server code for your stack that signs the token and redirects the staff member, with your Workspace ID filled in. |
check_sso_token | Checks a token exactly as the real sign-in would, and lists every problem, without using it up. |
list_agents | The workspace's agents, their roles, how they were added and when they were last seen. |
set_sso_only | Turns "Only single sign-on" on or off. Owner only. |
The Hibira plugin for Claude Code, Cursor, Codex and Gemini CLI already includes this server. To disconnect every AI app at once, use Team › Single sign-on › Disconnect AI apps.
REST API and webhooks Coming soon
A REST API for conversations, messages and ratings, and webhooks for new conversations, messages and ratings, are coming to the Team plan and above. These docs will cover them when they are ready.
Until then, export conversations as CSV or JSON from the inbox, or your whole workspace from Settings › Data & privacy.
For AI tools
Plain-text summaries of Live Chat for AI assistants and answer engines: /llms.txt is the short version, /llms-full.txt includes these docs and every feature page in full.
curl https://chat.hibira.io/llms.txt
curl https://chat.hibira.io/llms-full.txtBe first in line
Leave your email and we'll send your invite as soon as your spot opens.
Join the waitlist