You’re already seeing the widget in action! Click the “Ask AI” button on
this page to try it out.
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
- Go to Gurubase platform
- Click the Guru you want to add the widget to
- Click “Integrations” and then “Web Widget”
- Click “New Widget ID”, enter your website’s domain and click “Generate”
- The widget settings open. Adjust them, click Save, then copy the Widget ID or the script from the Install section
- A Widget ID created for
https://www.example.comwill 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
- It won’t work on subdomains like
- 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.comwill match any subdomain ofexample.comhttp://localhost:*will match any port oflocalhost*will match any domain, so be careful with this option! Anyone who knows your Widget ID can send requests to your Guru.
* 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.
- The value saved on the Widget ID
- The matching
data-*attribute on the page’s script tag, if any (see Configuration Options) - The default shown in grey
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.
- 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.
- 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-infoanddata-user-email-source, the newer name ofdata-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, exceptdata-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.

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

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 viawindow.chatWidget:
-
switchTheme(lightMode = null)Sync the theme of the widget with your website’s theme. Accepts an optionallightModeparameter:switchTheme(): Toggle the themeswitchTheme(true): Force light modeswitchTheme(false): Force dark mode
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.
- Go to your Guru’s settings page
- Scroll to Advanced Settings
- Add up to 3 example questions (100 characters max each)
- Save your changes
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, passdata-example-questions to override the list for that page:
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 asexternal_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
Whendata-pass-user-info="true" is set, the widget:
- Checks for Zendesk’s
HelpCenter.user.emailfor user identification (automatic, no extra config needed) - Falls back to reading from localStorage via
data-user-info-sourceif HelpCenter is not available - Sends the extracted value as
external_user_idto the backend - 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-sourcevalue from localStorage- “You” (default if none of the above are available)
- 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. Nodata-user-info-source is needed:
localStorage (Other Sites)
For non-Zendesk sites, configuredata-user-info-source to read from localStorage. Supports dot notation for nested JSON objects.
Common Use Cases
Segment Analytics: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.):
- The
isDocsPath()helper matches both/docsand/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
Docusaurus Plugin Example
Docusaurus Plugin Example
For Docusaurus, you can wrap this in a plugin. Create Then register in
plugins/gurubase-widget.js:docusaurus.config.js:Platform-Specific Integrations
Archbee
To add the Gurubase widget to your Archbee documentation:- Go to Space Settings > Custom Code
- 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.

GitBook
GitBook offers an official integration that makes it easy to add Gurubase to your documentation:- In your GitBook space, go to Integrations and search for Gurubase
- Click Install to add the integration
- Click Install on a docs site and select a site to install
- Enter your Widget ID from Gurubase platform
- Configure additional options (optional)

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:
.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 yourdocusaurus.config.js:
/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.- Add the widget script to your
mkdocs.yml:
- 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.
Option A: Static JavaScript File (Recommended)
Use this approach for a cleaner setup with all widget configuration in a single JavaScript file.- Create
_static/gurubase-widget.js:
- 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.- Create or edit
_templates/layout.html:
- Make sure your
conf.pyincludes 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):
_templates/layout.html):
Zendesk Knowledge Base
For Zendesk Help Center themes (like Copenhagen), add the widget to your theme’sscript.js file.
- Navigate to your Zendesk Help Center (e.g.,
https://<your-subdomain>.zendesk.com/hc/en-us) - Open Knowledge Admin
- Select Customize design from the left sidebar (Eye icon)
- Click Customize on the Live theme
- Click Edit code to open the theme editor
- Open the
script.jsfile - Add the following code just before the closing
})();at the end of the file:

- 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, edittemplates/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.- Add
data-end-user-auth="zendesk-hc"to the widget script in your theme (or setendUserAuth: "zendesk-hc"in thescript.jsexample above) and publish the theme. Nothing changes for visitors yet.
- In Gurubase, open your Guru’s Integrations > Web Widget page and click Show </> next to the Widget ID for your Help Center.
- Under Sign-in, turn on Require signed-in Zendesk Help Center users and enter your Zendesk subdomain, the part before
.zendesk.com(forhttps://acme.zendesk.comit isacme). Use it even if your Help Center has its own domain. Click Save. From now on only signed-in visitors are answered.
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 theX-End-User-Tokenheader. 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_idfor analytics, per-user rate limits and End-User Memory. Their Zendesk primary email, as the token carries it, reaches Custom Actions asGURUBASE_USER_EMAILand 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'.Option A: Component Approach (Recommended for Theme Sync)
Use this approach if you need automatic theme synchronization with Starlight’s dark/light mode. Createsrc/components/GurubaseWidget.astro:
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 toastro.config.mjs:
GurubaseWidget.astro component if using this approach.
Retype
For Retype documentation: Add the widget script to yourretype.yml:
Troubleshooting
Widget not appearing
Widget not appearing
- Check domain configuration: Ensure your Widget ID was created for the
exact domain where you’re testing. Remember that
www.example.comandexample.comare 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 ensurewidget.latest.min.jsloads successfully. - Check for ad blockers: Some ad blockers may prevent the widget from loading.
Widget appears twice
Widget appears twice
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.Theme not syncing with website
Theme not syncing with website
- Ensure you’re using
data-light-mode="auto"for automatic detection - For custom theme sync, verify yourMutationObserveris watching the correct element and attribute - Check thatwindow.chatWidget.switchTheme()is being called after the widget loads
Widget not working on localhost
Widget not working on localhost
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