Skip to main content
A feature for embedding Cloosphere chat into external websites like internal portals, customer support pages, and groupware. With a single script tag, provide AI chat on any web page.

Why You Need It

Existing ApproachEmbed Widget
Users must directly access CloosphereAI chat directly inside the work system
Separate sign-in neededToken forwarding or in-widget self sign-in
No external system integrationSupports UI bridge where AI reads and fills host page forms
Use scenarios:
  • Place an AI assistant in internal groupware to compose leave requests by chat
  • Embed a FAQ chatbot on customer support pages
  • Mount an operations support AI on the management console

Creating Widgets

Manage widgets in Admin > Settings > Embed Widgets.
1

Add widget

Click the + button to create a new widget.
2

Enter basic info

FieldDescription
NameWidget identifier (also used as default header title)
DescriptionAdmin-side memo (not externally exposed)
Model/AgentPick Agent, Flow, or Model for the widget
System PromptWidget-specific system prompt (optional)
3

Edit design

Click the Design button to customize appearance (details below).
4

Activate

Set the toggle to Active in the widget list. Inactive widgets aren’t loaded externally.

Display Modes

How the widget appears on the host page — 6 modes supported.
ModeBehaviorDefault SizeHost Layout Impact
BubbleBottom-right (or bottom-left) floating button → chat panel popup on click400×600pxNone (overlay)
Side RightFixed panel on the right of the screen380px widthAuto-applies margin-right to body
Side LeftFixed panel on the left of the screen380px widthAuto-applies margin-left to body
Side BottomFixed full-width panel at the bottom of the screen320px heightReduces html height by panel size → content reflows upward naturally
InlineInserted inside a specified HTML element100%×500pxNone (within specified container)
FullscreenFull screen overlay100vw×100vhHost page is hidden
Bubble mode is the most common choice. Used only when the user clicks, with auto-responsive sizing on mobile (≤480px).Side modes auto-shift host page content without separate CSS/JS. To opt-out of this, add the data-cloosphere-no-shift attribute to the host page’s root element.
Bubble mode’s Bubble Open Style also supports 4 options: popup / side-right / side-left / side-bottom. Start as Bubble and specify how to expand on click.

Resizable Panel

Toggle on Resizable Panel in widget settings to let users adjust panel size.
ModeGrip PositionAdjustable
Popup (Bubble)Diagonal grip on top corner of panel (opposite to bubble)width / height both directions
Side Right / LeftVertical edge inside panelwidth only (height stays 100vh)
Side BottomHorizontal edge on top of panelheight only (width stays 100vw)
Adjusted size is saved in localStorage per widgetId, so previous size is restored when the user revisits the same site.
When panel size changes in Side modes, the following occurs:
  • CSS variable updates: --cloosphere-side-panel-width, --cloosphere-side-panel-height
  • Event published to host page: cloosphere:side-resize (payload includes width/height)
Subscribe to this event if you need to sync host page positions like sidebars or fixed headers with the panel.

Design Customization

Fine-tune widget appearance in the Design editor. See changes immediately with real-time preview.

Layout

SettingDescription
ModeDisplay mode (pick from 5)
PositionBubble mode button position (bottom-right / bottom-left)
Width / HeightWidget size (CSS values, e.g., 400px, 100%)
Bubble SizeBubble button size (default 56px)
Bubble DraggableAllow bubble button to be dragged
Bubble Open StyleBehavior on bubble click (popup / side-right / side-left)
Show Header Close ButtonShow header close (X) button

Icons

SettingDescription
Bubble IconFloating button icon (7 presets + custom upload)
Send Button IconSend button icon (7 presets + custom upload)
Presets: Chat, Sparkles, Message, Robot, Support (Headset), Help (Question), Bolt
SettingDescription
Show HeaderShow header
Header TextHeader title (uses widget name if empty)
Show AvatarShow AI avatar
Avatar URLCustom AI avatar image
Bot NameAI name (shown above messages)

Colors

SettingApplies To
Primary ColorBubble button background
Bubble Icon ColorBubble button icon
Header ColorHeader background
Header Text ColorHeader text
Background ColorChat area background
Message Text ColorMessage text
Send Button ColorSend button background
Send Button Icon ColorSend button icon

Theme Presets

12 theme presets to apply all colors at once. Light, Dark, Slate, Midnight, Ocean, Aurora, Sunset, Forest, Rose, Cyberpunk, Ember, Mono After picking a preset, individual colors can be further customized.

Chat Settings

SettingDescriptionDefault
ThemeTheme (auto / light / dark). auto follows OS settingauto
Welcome MessageWelcome message AI auto-sends at chat start
Max Messages Per SessionMax messages per session. 0 = unlimited0

Feature Toggles

SettingDescriptionDefault
File UploadAllow file attachmentoff
MarkdownMarkdown renderingon
Code HighlightCode block highlightingon
Web SearchWeb search featureoff

Embed Code

Once a widget is created, a script tag to embed in the host page is provided.
<script
  src="https://your-cloosphere.com/static/embed/embed.js"
  data-widget-id="WIDGET_ID">
</script>
This single line auto-loads the widget. Override settings with additional data-* attributes:
AttributeDescription
data-widget-idWidget ID (required)
data-tokenPre-authenticated user token (optional — skips sign-in if present)
data-modeOverride display mode
data-themeOverride theme (light / dark / auto)
data-positionOverride button position (bottom-right / bottom-left)
data-primary-colorOverride Bubble button color
data-targetTarget CSS selector for Inline mode
data-width / data-heightOverride size
<div id="my-chat-container" style="height: 600px;"></div>
<script
  src="https://your-cloosphere.com/static/embed/embed.js"
  data-widget-id="WIDGET_ID"
  data-mode="inline"
  data-target="#my-chat-container">
</script>
<!-- Inject user token from host page -->
<script
  src="https://your-cloosphere.com/static/embed/embed.js"
  data-widget-id="WIDGET_ID"
  data-token="eyJhbGciOiJIUzI1NiIs...">
</script>
Don’t hardcode tokens directly in HTML. Render server-side dynamically or inject via JavaScript.

JavaScript API

Control the widget via JavaScript in Bubble mode:
// Open chat panel
window.CloosphereEmbed.open();

// Close chat panel
window.CloosphereEmbed.close();

// Replace token at runtime
window.CloosphereEmbed.updateToken("new-jwt-token");
open() / close() only work in Bubble mode. They’re ignored in Side, Inline, and Fullscreen modes since the widget is always visible.

Authentication Methods

The widget authenticates users via one of three modes. Pick the mode in the Auth tab of widget settings.

Login Mode (default)

Sign in directly with a Cloosphere account.
PriorityMethodDescription
1Token forwardingJWT injection via data-token attribute or updateToken() API
2Session restorationAuto-uses tokens from previous widget sign-in saved in sessionStorage
3In-widget sign-inSign-in screen shown when neither above is present
The sign-in screen auto-shows OAuth provider buttons (Google, Microsoft, etc.) configured in Cloosphere.

SSO Mode

Exchange the host site’s existing SSO token for a Cloosphere JWT. Use the existing auth system without a separate sign-in screen. Supported Providers:
ProviderToken Validation
Microsoft Entra IDOIDC JWKS + id_token signature verification
GoogleOIDC JWKS
GitHubaccess_token → GitHub API verification
Generic OIDCDiscovery URL → JWKS auto-discovery
SSO Settings:
SettingDescriptionDefault
ProvidersList of allowed Providers
Auto SignupAuto-create unregistered usersoff
Default RoleRole for auto sign-uppending
ProviderSettingDescription
MicrosoftTenant IDSingle-tenant lock (empty = multi-tenant)
MicrosoftTrusted AudiencesAllowed client_id list
GoogleTrusted AudiencesAllowed client_id list
Generic OIDCTrusted IssuersAllowed issuer URL list
Generic OIDCTrusted AudiencesAllowed audience list
Host site integration example:
// Get Cloosphere JWT from host site using existing SSO token
const response = await fetch(
  'https://your-cloosphere.com/api/v1/embed-widgets/id/WIDGET_ID/auth/sso-exchange',
  {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({
      provider: 'microsoft',
      id_token: 'eyJhbG...',    // Existing SSO id_token
      access_token: 'eyJhbG...' // (optional) for additional profile info
    })
  }
);
const { token } = await response.json();
// Pass the obtained token to the widget via data-token

Guest Mode

Non-signed-in users can use the widget with simple info entry (or auto). Suitable for unrestricted-audience scenarios like customer support chatbots. Guest Settings:
SettingDescriptionDefault
Collect InfoShow name/email entry formon
Required FieldsRequired input fieldsname
Optional FieldsOptional input fieldsemail
Auto ProceedSkip info collection and start session immediatelyoff
JWT Expires InGuest JWT expiration24h
Enabling Auto Proceed starts chat immediately without info collection. Suitable for anonymous FAQ chatbots.
Login / SSO / Guest are mutually exclusive. Only one can be activated.

Domain Allowlist

For security, restrict which domains can load the widget. Register allowed domain patterns in widget settings’ allowed_domains:
PatternMatches
example.comExactly example.com
*.example.comsub.example.com, portal.example.com, etc.
(empty)All domains allowed
In production, always set the allowlist explicitly. Empty list is for testing only.

UI Manipulation Bridge

The most powerful feature of the embed widget — the AI directly manipulates the host page DOM. For example, when a user says “submit a leave request for today”, the AI can auto-fill the host page’s leave request form.

Available Tools

UI manipulation tools auto-attach to the agent, enabling:
ToolFunction
fill_formFill multiple fields in a form at once
fill_form_fieldSet value on individual input field
read_formRead the form’s current values as JSON
click_elementClick a button or link
highlight_elementHighlight an element with blue border + scroll (auto-clears after 2.5s)
get_page_infoGet current page URL, title, form list
navigate_toNavigate the host page

Security: Selector Allowlist

Restrict the HTML elements the AI can manipulate using allowed_selectors in widget settings.
SettingBehavior
["*"] (default)All elements manipulable
["form#leave-form *"]Only elements within a specific form
["#name", "#date", ".btn-submit"]Only specified selectors
In production, explicitly restrict allowed_selectors. The default ["*"] lets the AI manipulate any page element, which can cause unintended behavior.
After navigate_to is called, host page navigation reloads the iframe and loses conversation context. Include guidance like “Don’t use additional tools after navigate_to” in the AI prompt.Within the same origin, soft navigation is attempted first. In SPAs (Single Page Applications), handling the cloosphere:navigate event enables routing without page transition.

Limitations

ItemDetail
Session persistenceClosing and reopening the widget starts a new session (previous conversation isn’t restored)
Chat titleAuto-title/tag generation is off, so chat appears as Embed: {widget-name} in Cloosphere chat list
UI bridge timeoutTool fails when host page response isn’t received within 15 seconds
Mobile responsiveOnly Bubble mode is auto-responsive. Other modes need manual width/height adjustment
sessionStorageToken storage may be blocked in Private/Incognito mode

Agents

Create and configure AI agents to connect to widgets

Flows

Connect flows for complex multi-step tasks

Guardrails

Safety rules applied to widget responses