Prerequisites
- A Pro or Enterprise plan. The widget uses the same credits as the assistant.
Enable the widget
- Navigate to your deployment’s Widget page.
- Enable the widget.
- Add allowed origins where you embed the widget.
- 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.Open on initialization
SetdefaultOpen 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
Awaitinit() before calling other methods. Keep the built-in trigger or open the configured presentation from any button in your application.
ask():
source value, which lets you distinguish built-in interactions from your custom entry points.
Update a mounted widget
Useupdate() to change appearance, labels, support email, starter questions, retrieval filters, or hooks without clearing the current conversation. Only the supplied fields change.
null to restore a field or group to its default, remove the support email, or restore an empty starter-question list:
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
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 tohttps://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
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.