Skip to main content
You’re already seeing the widget in action! Click the “Ask AI” button on this page to try it out.
You can add your Guru directly to your website using our widget. The widget adds an “Ask AI” button that opens a chat interface when clicked.

Prerequisites

Before adding the widget, make sure you have:
  • A Guru on Gurubase (either on Gurubase Cloud or self-hosted with Enterprise plan)
  • A Widget ID from your Guru’s settings

Getting Your Widget ID

  1. Go to Gurubase platform
  2. Click the Guru you want to add the widget to
  3. Click “Integrations” and then “Web Widget”
  4. Click “New Widget ID”
  5. Enter your website’s domain
  6. Click the “Show” button to configure and preview your widget
  7. Copy the generated widget script
Each Widget ID is restricted to work only on the specific domain it was created for. For example:
  • A Widget ID created for https://www.example.com will only work on that exact domain.
    • It won’t work on subdomains like https://docs.example.com
    • It won’t work on different domains like https://example.org
  • For local development, you need to create a separate Widget ID using your development URL (e.g., http://localhost:3000)
  • Domain input supports wildcard (*) expression:
    • *.example.com will match any subdomain of example.com
    • http://localhost:* will match any port of localhost
    • * will match any domain, so be careful with this option! Anyone who knows your Widget ID can send requests to your Guru.
Make sure to create Widget IDs for each domain where you want to use the widget.

Per-Widget Settings

Each Widget ID has an Attachments toggle displayed below the domain. When enabled, users can attach files (images, logs, PDFs) in the widget chat via the paperclip button, drag-and-drop onto the input, or paste. When disabled (default), the attachment button is hidden and any file upload requests are rejected by the backend. Supported attachment file formats Default per-question limits (configurable per guru): Compressed archives (.gz, .zip, .bz2) are not supported; decompress before uploading.

Text & Display Customization

Inside the widget configuration panel (click “Show”), you can customize the widget’s text labels and control what elements are displayed. These settings are saved per-widget and take effect immediately. Text overrides - Leave empty to use defaults. You type the exact text you want displayed: Display toggles - Control which elements appear in the widget:
The Button Text is configured separately in the appearance section via the data-text HTML attribute.

Widget Configuration & Live Preview

After creating a Widget ID, click “Show” button to open the configuration panel. This allows you to customize your widget’s appearance and behavior with a live preview that shows exactly how it will look on your website.
Widget Configuration with Live Preview
The configuration panel includes:
  • Button Text: Customize the text displayed on the widget button
  • Theme: Choose between Light, Dark, or Auto (syncs with your website’s theme)
  • Window Mode: Select Sidebar or Floating display mode
  • Button Color & Shimmer: Customize the button’s primary color and shimmer effect
  • Margins: Adjust the button’s position from the bottom and right edges
  • Tooltip: Add an optional tooltip with customizable position
  • Icon URL & Custom Name: Override the default Guru icon and name
  • Text & Display: Override widget text labels and toggle sources, trust score, and branding visibility (see Text & Display Customization)
The Live Preview on the right side shows your widget in real-time as you make changes. You can interact with the preview to test the widget’s functionality before deploying it to your website. Once you’re satisfied with the configuration, copy the generated widget script from the “Widget Script” section.

AI Assistant Integration

If you’re using AI coding assistants like Cursor, Claude Code, or similar tools, click the “Show Prompt” button next to “Using Cursor, Claude Code, or AI assistants?” to get a ready-to-use prompt.
AI Assistant Prompt
This prompt includes:
  • Instructions to detect your website’s framework (Next.js, Docusaurus, MkDocs, etc.)
  • Guidance to check framework-specific setup from Gurubase docs
  • Your widget script with all configured options
Simply copy the prompt and paste it into your AI assistant to get framework-specific integration instructions tailored to your project.

Basic Installation

Add this script to your website’s HTML:

Configuration Options

Window Modes

The widget supports two display modes for the chat window:

Sidebar Mode (Default)

The traditional sidebar experience where the chat window slides in from the right edge of the screen.
Sidebar Mode

Floating Mode

A modern modal-style experience where the chat opens as a centered floating window.
Floating Mode

Floating Mode Example

Self-hosted Installation (Enterprise Only)

Self-hosted installations are exclusively available under the Enterprise plan. To request access, contact us at [email protected].If you’re using self-hosted Gurubase, you must set the Gurubase instance URL using the data-base-url attribute. The default URL of Self-hosted Gurubase instance is http://localhost:8029/api/.

Customization Examples

Custom Button Text and Position

Light Mode with Custom Colors

Exposed Functions

The widget exposes the following functions via window.chatWidget:
  • switchTheme(lightMode = null) Sync the theme of the widget with your website’s theme. Accepts an optional lightMode parameter:
    • switchTheme(): Toggle the theme
    • switchTheme(true): Force light mode
    • switchTheme(false): Force dark mode
    Example: window.chatWidget.switchTheme(true); See the MkDocs example for theme syncing implementation.
  • destroy() Remove the widget from the DOM and clean up all event listeners. Useful for SPAs where you want to conditionally show/hide the widget based on the current route. Example: window.chatWidget.destroy(); See Path-Based Widget Loading for a complete example.

Example Questions

You can display custom example questions in your widget to help guide users on what they can ask. These questions appear when users open the widget, providing helpful prompts to get started.
Example Questions on Gurubase Widget
To configure example questions:
  1. Go to your Guru’s settings page
  2. Scroll to Advanced Settings
  3. Add up to 3 example questions (100 characters max each)
  4. Save your changes
When users click an example question in the widget, it populates the input field so they can submit it directly or modify it first.

Learn More

See the full Example Questions guide for best practices and tips

User Identification

The widget can automatically identify users and include their information in API requests as external_user_id. It also displays the user’s name in chat messages instead of the default “You” label. This supports two methods: automatic detection on Zendesk Help Center pages and manual configuration via localStorage.

How It Works

When data-pass-user-info="true" is set, the widget:
  1. Checks for Zendesk’s HelpCenter.user.email for user identification (automatic, no extra config needed)
  2. Falls back to reading from localStorage via data-user-info-source if HelpCenter is not available
  3. Sends the extracted value as external_user_id to the backend
  4. Displays the user’s name in chat messages using this fallback order:
    • HelpCenter.user.name (Zendesk only)
    • HelpCenter.user.email (Zendesk only)
    • data-user-info-source value from localStorage
    • “You” (default if none of the above are available)
  5. Fails silently if data is unavailable (won’t break widget functionality)

Zendesk Help Center (Automatic)

On Zendesk Help Center pages, the widget automatically detects the logged-in user’s email for identification and their name for display. No data-user-info-source is needed:

localStorage (Other Sites)

For non-Zendesk sites, configure data-user-info-source to read from localStorage. Supports dot notation for nested JSON objects.

Common Use Cases

Segment Analytics:
Extracts email from Segment’s user traits object stored as:
Mixpanel:
Custom User Data:
Top-level localStorage key (no nesting):

Path-Based Widget Loading

If you want to load the widget only on specific paths (e.g., only on /docs/ pages), you can use a conditional loading approach. This is especially useful for Single Page Applications (SPAs) where you need to handle client-side navigation. The following script can be adapted to any SPA framework (Docusaurus, Next.js, Remix, etc.):
Key points:
  • The isDocsPath() helper matches both /docs and /docs/* paths (modify this function to match your desired paths)
  • The initWidget() function checks the current path before loading the widget
  • The destroyWidget() function cleans up all widget-related DOM elements when navigating away
  • History API hooks (pushState, replaceState, popstate) handle SPA navigation
For Docusaurus, you can wrap this in a plugin. Create plugins/gurubase-widget.js:
Then register in docusaurus.config.js:

Platform-Specific Integrations

Archbee

To add the Gurubase widget to your Archbee documentation:
  1. Go to Space Settings > Custom Code
  2. Under the “Include Headers” text area, paste the Gurubase widget script that you received from the Gurubase platform:
For security reasons, scripts are only included on a custom domain in Archbee. Make sure you have set up a custom domain for your documentation to use the widget.
Archbee Custom Code Integration

GitBook

GitBook offers an official integration that makes it easy to add Gurubase to your documentation:
  1. In your GitBook space, go to Integrations and search for Gurubase
  2. Click Install to add the integration
  3. Click Install on a docs site and select a site to install
  4. Enter your Widget ID from Gurubase platform
  5. Configure additional options (optional)
GitBook Integration Configuration
After a few minutes, you will see the “Ask AI” button in your GitBook documentation.

Mintlify

To add the Gurubase widget to your Mintlify documentation with automatic theme syncing, create a JavaScript file (e.g., gurubase.js) in your docs content folder with the following content:
Any .js file in your Mintlify content directory is automatically included on every page - no additional configuration needed. The widget will automatically sync its theme (light/dark) with your Mintlify documentation.

Docusaurus

Add the widget to your docusaurus.config.js:
For path-based loading (showing the widget only on specific pages like /docs/), see Path-Based Widget Loading.

MkDocs (Material)

For MkDocs with the Material theme, you can add theme syncing so the widget matches your documentation’s light/dark mode.
  1. Add the widget script to your mkdocs.yml:
  1. Create docs/js/gurubase-widget.js:

Sphinx / Read the Docs

For Sphinx documentation (including Read the Docs), you can add the widget using either a static JavaScript file or a template override.
Important: Choose only ONE of the following approaches. Using both will cause the widget to load twice.
Use this approach for a cleaner setup with all widget configuration in a single JavaScript file.
  1. Create _static/gurubase-widget.js:
  1. Add the script to your conf.py:

Option B: Template Override

Use this approach if you prefer to add the widget directly in HTML templates.
  1. Create or edit _templates/layout.html:
  1. Make sure your conf.py includes the templates path:

Theme Sync for Dark Mode

For themes with dark mode support (like Furo or PyData), add theme syncing to automatically match the widget theme with your documentation. Using static JS file (_static/gurubase-widget.js):
Using template override (_templates/layout.html):

Zendesk Knowledge Base

For Zendesk Help Center themes (like Copenhagen), add the widget to your theme’s script.js file.
  1. Navigate to your Zendesk Help Center (e.g., https://<your-subdomain>.zendesk.com/hc/en-us)
  2. Open Knowledge Admin
  3. Select Customize design from the left sidebar (Eye icon)
  4. Click Customize on the Live theme
  5. Click Edit code to open the theme editor
  6. Open the script.js file
  7. Add the following code just before the closing })(); at the end of the file:
Zendesk Help Center Customize
  1. Click Save and then Publish to make the changes live
Make sure to create a Widget ID for your Zendesk Help Center domain (e.g., yourcompany.zendesk.com or your custom domain) in the Gurubase platform.

Alternative: Using document_head.hbs Template

If you prefer to add the widget via the template, edit templates/document_head.hbs and add the script tag:
For self-hosted Gurubase (Enterprise plan), add data-base-url="https://gurubase.yourcompany.com/api/" to point to your instance.

Astro / Starlight

For Astro with Starlight documentation theme:
Important: Choose only ONE of the following approaches. Using both will cause the widget to load twice since both methods add a script with the same id='guru-widget-id'.
Use this approach if you need automatic theme synchronization with Starlight’s dark/light mode. Create src/components/GurubaseWidget.astro:
Then import and use this component in your layout. Do not add the widget to astro.config.mjs head if using this approach.

Option B: Config Approach (Simpler Setup)

Use this approach for a simpler setup without theme synchronization. Add to astro.config.mjs:
Do not create or use the GurubaseWidget.astro component if using this approach.

Retype

For Retype documentation: Add the widget script to your retype.yml:

Troubleshooting

  • Check domain configuration: Ensure your Widget ID was created for the exact domain where you’re testing. Remember that www.example.com and example.com are different domains. - Check for JavaScript errors: Open your browser’s developer console (F12) and look for any errors. - Verify script loading: Check the Network tab to ensure widget.latest.min.js loads successfully. - Check for ad blockers: Some ad blockers may prevent the widget from loading.
This usually happens when the widget script is included multiple times. Common causes: - Using both the config approach AND component approach (e.g., in Astro/Starlight) - Script included in both layout template and page template - SPA navigation re-initializing without proper cleanup Solution: Ensure you only use ONE method to add the widget, and check that document.getElementById('guru-widget-id') guard is in place.
  • Ensure you’re using data-light-mode="auto" for automatic detection - For custom theme sync, verify your MutationObserver is watching the correct element and attribute - Check that window.chatWidget.switchTheme() is being called after the widget loads
Create a separate Widget ID for your local development URL (e.g., http://localhost:3000 or http://localhost:* for any port).

Next Steps

Example Questions

Configure example questions for your widget

API Reference

Explore our API documentation