Skip to content

Frontend integration

DioscHub ships its chat as a single web component, <diosc-chat>. You load it onto a page, place it where you want, and control it from your app with one global function: diosc(). The widget code is served from your DioscHub instance at runtime. You embed a small loader, not the whole bundle.

The DioscHub chat widget open on a storefront page — a floating panel with the assistant's name, avatar, and greeting, docked in the bottom-right corner of the host site.

The <diosc-chat> widget embedded on a host page. It renders as a floating launcher that opens into this panel; you place and control it from your own app.

Pick the path that matches how your frontend is built.

Paste the loader script. It mounts <diosc-chat> for you and resolves everything else from your embed key server-side. You don’t pass an assistant ID or a backend URL.

<script src="https://your-hub.example.com/api/embed/YOUR_EMBED_KEY/loader.js"></script>

That’s the whole integration for a static page.

Once loaded, diosc() is how your app talks to the widget. You pass a command name and its arguments.

diosc('open'); // expand the widget
diosc('close'); // collapse it to the launcher
diosc('toggle'); // flip between the two

To react to what happens inside the widget, subscribe to its events:

diosc('on', 'session:upgraded', (session) => {
// the anonymous visitor just signed in, so refresh your UI
});

diosc('onAny', handler) receives every event if you’d rather route them yourself. The full event catalogue lives in the Web component API reference.

The widget has a built-in history UI — past conversations, rename, pin, and new-chat — gated by the sessionHistory and multipleSessions Role features (see Assistants & Roles). When those features are granted the visitor’s role, the history panel appears with no work on your part.

If you want to drive sessions from your own UI instead, diosc() exposes the same operations: startNewSession, loadSession(id), renameSession(id, name), pinSession(id, isPinned), fetchSessionList / fetchSessionListViaREST (returns the list via the session:list event), and searchSessions({ query }) / clearSessionSearch. Every command and its arguments are in the client command API reference.

The widget carries no credentials. It never asks the user to authenticate, and you never pass a token to diosc(). Instead, your backend hands DioscHub a scoped session for the already-signed-in user, and DioscHub forwards that opaquely to your MCP servers. It’s never placed in the model’s context. That binding is host-side and is covered in Identity & auth.

The defaults work out of the box. When you’re ready to tailor the experience, each of these is a self-contained how-to:


Next: expose one of your own endpoints to the assistant in MCP server development.