Skip to content

01 · Basic

The shortest possible integration: one <script> tag with data-* attributes. SDK reads its own dataset, registers the Custom Element, and mounts a floating chat bubble in the corner of the page. Your Ranch API key stays on the server — only a short-lived JWT reaches the browser via data-token.

Snippet

html
<script
  src="https://bridle.cleanslice.org/sdk/latest.js"
  data-api-url="https://hub.example.com"
  data-agent-id="agent-31a6fbd1-…"
  data-token="<jwt>"
></script>

Optional knobs

Everything below works on the script tag with zero extra integration code — pure data-* attributes:

AttributeWhat it doesReference
data-greetingPre-seeds the first assistant bubble after a typing-indicator delay on an empty chatWelcome message
data-greeting-delayMilliseconds before the greeting appears (default 3000)
data-empty-avatar / data-empty-title / data-empty-subtitleAvatar + headline + sub-line shown on the empty-state screenEmpty state
data-suggestionsPipe-separated suggestion chips on the empty state — click to send
data-promptFree-form context forwarded to the agent on every message — page URL, plan, locale, A/B cohortPage Context
data-fab-iconURL of an image to replace the FAB's built-in glyphTheming › Custom FAB icon
data-custom-cssInline CSS injected into the shadow root to restyle internal classesTheming › Overriding internal classes
data-stylesheetOne or more <link> URLs loaded into the shadow root
data-color-modeauto / light / dark — overrides the page's color scheme
data-themedefault / cleanslice — built-in palette

Image attachments (paperclip / drag / paste) and mobile full-bleed panel are on by default — no flags. See 03 · Styles for theming the attachment strip.

What the agent can render

Beyond plain text, the SDK renders rich parts[] the agent runtime sends back. None of this needs new integration code — just emit the right part type:

Part typeRenders asUse it for
textMarkdown bubble (lists, code, links, tables)The default reply.
imageInline image inside the bubbleScreenshots, generated charts, photo replies.
uiA form (radio / checkbox / select / input / textarea) right inside the bubble, with one-shot SubmitOnboarding flows, collecting structured info mid-conversation — see 07 · Interactive forms.

The SDK advertises its capabilities (['streaming', 'images', 'files', 'ui']) on the WebSocket handshake; the hub forwards them on every message so the agent runtime can decide which part types it's safe to emit for this peer. Older SDKs and non-Bridle channels (Telegram, email) just don't get a capabilities field — agents should fall back to text when it's missing.

A bulkier example with all the knobs at once:

html
<script
  src="https://bridle.cleanslice.org/sdk/latest.js"
  data-api-url="https://hub.example.com"
  data-agent-id="agent-31a6fbd1-…"
  data-token="<jwt>"
  data-greeting="Hi! 👋 What brings you here?"
  data-greeting-delay="2500"
  data-prompt="URL: https://shop.example.com/pricing · Plan: free"
  data-fab-icon="/icons/chat.svg"
  data-theme="cleanslice"
  data-color-mode="auto"
></script>

What this does

StepResult
Script loadsIIFE runs, sets window.Bridle = { init, BridleClient, … }
Auto-mountReads data-agent-id / data-token / data-api-url from its own script tag
Custom Element<bridle-chat> registered once, instantiated in the DOM
ConnectionWebSocket opened to apiUrl/ws/client with the JWT
UIFloating FAB renders bottom-right; click to open the panel

Live demo

When to use it

  • Static sites — WordPress, Webflow, Shopify, plain HTML.
  • You can render the JWT server-side into the markup (template engine, SSR).
  • Default chat position (floating) works for your layout.

Next

If the JWT must be fetched at runtime, or you need more than one widget on the page, switch to Inline or Authenticator.

Released under the MIT License.