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”, enter your website’s domain and click “Generate”
  5. The widget settings open. Adjust them, click Save, then copy the Widget ID or the script from the Install section
The copy icon next to each Widget ID on the Web Widget page copies the ID without opening its settings. 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. The domain can be changed later in the widget’s settings, for example to narrow a * widget to your production domain, and the Widget ID keeps working.

Widget Settings

Click Settings next to a Widget ID to open its settings. Everything here is saved on the Widget ID itself, so a change applies to every page that embeds it as soon as you click Save, with no change to the page or redeploy. This is what lets platforms that cannot edit script attributes use the full set of options; on SharePoint this needs package 1.7.0 or later.
Widget settings with live preview
Edits are a draft until you click Save. The Preview on the right already shows the draft, and you can open the widget there and try it. Discard returns to the saved settings, and closing the panel with unsaved changes asks before throwing them away. An empty field means “not set”. The grey text inside it is what the widget will show in that case, in the selected language. A setting is resolved in this order:
  1. The value saved on the Widget ID
  2. The matching data-* attribute on the page’s script tag, if any (see Configuration Options)
  3. The default shown in grey
Click Default next to a field to clear it. Supported attachment file formats Default per-question limits (configurable per guru): Compressed archives (.gz, .zip, .bz2) are not supported; decompress before uploading. Default texts, with {name} being the Display name or else the Guru name:

Install

The Install section has the Widget ID and the script to add to your website. The script carries only the Widget ID (and, on self-hosted, your backend address), because everything else comes from the settings above.
Install section with the Widget ID and script
  • Copy ID: the Widget ID alone, for SharePoint, Zendesk and other packaged installs that ask for it.
  • Copy script: the script tag for your site’s HTML.
  • Copy prompt for AI coding assistants: a prompt for Cursor, Claude Code and similar tools that detects your framework, follows its guide in these docs and adds the script.
Options only the page can set adds attributes that belong to one page rather than to the Widget ID, so they change the copied script and are not saved:
  • Full screen (data-window-mode="embedded"): the widget fills the page and opens at once, with no close button. For pages that exist only to host the assistant, such as one opened inside a mobile app.
  • Open on load (data-auto-open="true"): opens the chat when the page loads.
  • Pass user email (data-pass-user-info and data-user-email-source, the newer name of data-user-info-source; both work): see User Identification.

Basic Installation

Add this script to your website’s HTML:

Configuration Options

Settings saved on the Widget ID take precedence over these attributes. An attribute applies only where the Widget ID leaves that setting empty, except data-window-mode="embedded", which only the page can request.

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.

Per-page example questions

Example questions are configured on the Guru, so every page that embeds the widget shows the same list. If you embed the same Guru on pages in different languages or sections, pass data-example-questions to override the list for that page:
The value is a JSON array of strings. Pair it with data-language so the interface and the questions are in the same language. If the value is missing, empty, or not valid JSON, the widget logs a warning and falls back to the questions configured for the Guru.

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.

Require signed-in Help Center users

A Widget ID and the page’s address are public. On a Help Center that requires sign-in they do not stop someone from calling the assistant directly and reading your knowledge base. Turn on this setting to answer only visitors who are signed in to your Help Center.
  1. Add data-end-user-auth="zendesk-hc" to the widget script in your theme (or set endUserAuth: "zendesk-hc" in the script.js example above) and publish the theme. Nothing changes for visitors yet.
  1. In Gurubase, open your Guru’s Integrations > Web Widget page and click Show </> next to the Widget ID for your Help Center.
  2. Under Sign-in, turn on Require signed-in Zendesk Help Center users and enter your Zendesk subdomain, the part before .zendesk.com (for https://acme.zendesk.com it is acme). Use it even if your Help Center has its own domain. Click Save. From now on only signed-in visitors are answered.
The Widget ID’s domain must be exact, not a wildcard: Gurubase refuses to turn the setting on for a wildcard Widget ID. If your Help Center has its own domain, use exactly that domain (for example https://help.example.com). A token is accepted only when it was issued for https://<subdomain>.zendesk.com or for the Widget ID’s exact domain. How it works:
  • The widget asks your Help Center for a token for the signed-in user (/api/v2/help_center/integration/token.json) and sends it as the X-End-User-Token header. The token is a short-lived JWT that Zendesk signs.
  • Gurubase checks the signature against your account’s public keys, the expiry, and that the token was issued for this Help Center. Every widget endpoint refuses a request without a valid token, including direct calls with only the Widget ID.
  • Follow-up suggestions and answer votes are shared with the Gurubase web app and API. They require the token when the call carries the Widget ID; without it they apply their usual rules (for example, anonymous votes on a public Guru, which need the answer’s slug).
  • Signed-out visitors see Sign in to use the assistant in the widget instead of an error.
  • The Zendesk user from the token is the external_user_id for analytics, per-user rate limits and End-User Memory. Their Zendesk primary email, as the token carries it, reaches Custom Actions as GURUBASE_USER_EMAIL and is the requester of tickets filed from the widget. Anything the page itself claims about the user is ignored.
  • A Custom Action that makes authorization decisions should use external_user_id (the stable Zendesk user id), not the email.
  • “Signed in” means whatever your Help Center allows: with open sign-up, anyone who registers counts as signed in. Restrict sign-up in Zendesk if the assistant is for existing customers only.
  • The live preview in Gurubase keeps working without a Help Center session.
Help Center tokens are available on Zendesk Guide Enterprise and Suite Enterprise plans. Publish the script change before turning the setting on: a widget without data-end-user-auth sends no token, so every visitor would see the sign-in message.
Self-hosted behind a CDN or proxy (for example Amazon CloudFront): the origin request policy must forward the X-End-User-Token header to Gurubase, and the browser’s OPTIONS preflight must reach Gurubase rather than be answered from cache. Otherwise the header is dropped and every visitor reads as signed out.

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