Skip to main content
The assistant answers questions on your Mintlify site. To embed the same capability on another site or web app, use the widget. With the widget, you can give your users access to AI chat trained on your content in your product dashboard, marketing site, support portal, or elsewhere. Add the widget to any website or web application with a hosted script. The widget owns its trigger and renders inside a closed Shadow DOM, which prevents your application styles from affecting the widget. The only required browser option is the public widget ID. Manage the enabled state, allowed origins, attachments, and bot protection in your dashboard. Set embed-specific starter questions, a support email, and retrieval filters in the browser configuration.

Prerequisites

Enable the widget

  1. Navigate to your deployment’s Widget page.
  2. Enable the widget.
  3. Add allowed origins where you embed the widget.
  4. Copy the widget ID.

Install and configure

Use the playground to configure the presentation, visual options, and observer hooks for your widget. The installation code block updates as you change each option.
Replace YOUR_WIDGET_ID in the generated code with the widget ID from the Widget page of your dashboard.
After you add the generated code to your site, reload the page. Confirm the trigger appears, then click it and send a test question to verify the connection.
Module scripts defer and run in document order. Keep the hosted loader before the initialization block when you install the widget with HTML, or the widget fails to mount.

Open on initialization

Set defaultOpen to true to open the widget immediately after its first mount:
defaultOpen defaults to false and only applies to the first initialization. Calling init() again with the same widget ID and API endpoint does not reopen a widget that a visitor closed. Use open() and close() to control it after initialization.

Use a custom trigger

Await init() before calling other methods. Keep the built-in trigger or open the configured presentation from any button in your application.
To open the widget and immediately send a question, call ask():
Event metadata and requests include the source value, which lets you distinguish built-in interactions from your custom entry points.

Update a mounted widget

Use update() to change appearance, labels, support email, starter questions, retrieval filters, or hooks without clearing the current conversation. Only the supplied fields change.
Pass null to restore a field or group to its default, remove the support email, or restore an empty starter-question list:
Changing identity starts a new conversation. Changing the widget ID or API endpoint requires calling destroy() before a new init(). You can supply supportEmail and starterQuestions during initialization and change them later with update(). These values apply to the current embed and do not inherit from your Mintlify dashboard.

Configuration reference

AssistantConfig

Pass this object to init().

AssistantAppearance

Arbitrary CSS and neutral-palette overrides are not supported. The closed Shadow DOM protects both your application and the widget from cross-site style regressions.

AssistantLabels

AssistantHooks

The event hook receives lifecycle and interaction metadata for init, open, close, ask, update, reset, navigate, and destroy. Events do not include question text, identity, session, or CAPTCHA tokens. The error hook receives a stable code, a retryable boolean, and an optional HTTP status. Exceptions thrown by either hook do not interrupt the widget.

AssistantOpenOptions

Pass this optional object to open().

AssistantAskOptions

Pass this optional object after the question string in ask().

AssistantUpdate

Pass this object to update(). Every field is optional, and null restores its default.

Browser API

Conversation snapshots remain private to the widget. Each method resolves to void.

Analytics and privacy

The widget loads Mintlify’s internal analytics client in a separate lazy chunk from the widget CDN after initialization begins, then sends events to https://ph.mintlify.com. Initialization does not wait for analytics, and an analytics import, initialization, or capture failure does not affect widget behavior. Mintlify collects:
  • Installation and open or closed state transitions
  • Question submission origin, attachment count, request duration, and outcome
  • Opaque widget-session, open-session, and request IDs
  • Server-issued thread and message IDs
  • Successful starter-question, option, source, suggestion, copy, and support-link interactions using indexes or destination categories
  • Feedback polarity, widget ID and versions, presentation surface, anonymous-versus-signed identity mode, and the embedding hostname
Mintlify does not collect prompts, answers, starter-question or option text, support email, identity tokens, thread keys, CAPTCHA values, raw identities, full URLs, referrers, query parameters, campaign parameters, or error messages. The analytics client uses memory-only persistence. It does not create person profiles or identify visitors, and it disables automatic capture, page views, page leave, session replay, surveys, feature flags, performance collection, heatmaps, exception capture, campaign storage, referrer storage, and geolocation enrichment. Analytics events are internal to Mintlify, are not part of the public widget configuration, and do not change hooks.event.

Content Security Policy

If your site uses a Content Security Policy, allow the origins required by your enabled widget features: A strict script-src policy must still authorize both the loader and initialization script. Passing nonce to init() propagates it only to resources the widget creates after initialization. https://api.mintlify.com remains required when you use the hosted endpoint because the browser sends configuration, message, and feedback requests to it. If you set a custom endpoint, allow that origin instead. The CSP frame-ancestors directive controls which sites may embed a document. It does not authorize outgoing browser requests and is unrelated to the widget, which renders in Shadow DOM instead of an iframe. CAPTCHA providers can embed their own frames and separately require the frame-src sources in the table.