Website Widget Integration
Add Gurubase AI assistant to your website
You can try the widget live on getanteon.com to see how it works in a real-world setting.
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.io or self-hosted)
- A Widget ID from your Guru’s settings
Getting Your Widget ID
- Click “My Gurus” under the profile
- 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
- Copy the generated Widget ID
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’ll need to create a separate Widget ID using your development URL (e.g.
http://localhost:3000
)
Make sure to create Widget IDs for each domain where you want to use the widget.
Basic Installation
Add this script to your website’s HTML:
For more examples like Astro - Starlight, Docusaurus, Mintlify, MKDocs, Next.js, JS, React, Remix, Sphinx, see our demo projects.
Configuration Options
Option | Description | Default |
---|---|---|
data-widget-id | Your widget ID (required) | - |
data-text | Button text | ”Ask AI” |
data-margins | Button positioning | {"bottom": "1rem", "right": "1rem"} |
data-light-mode | Light mode toggle | "true" |
data-bg-color | Primary color | Fetched from Gurubase |
data-icon-url | Custom logo URL | Fetched from Gurubase |
data-name | Custom name | Fetched from Gurubase |
Self-hosted Installation
If you’re using self-hosted Gurubase, you must set the backend URL using the data-baseUrl
attribute. The default backend URL of Self-hosted Gurubase is http://localhost:8029/api/
.
Customization Examples
Custom Button Text and Position
Light Mode with Custom Colors
Exposed Functions
-
switchTheme(lightMode = null)
You can use this function to sync the theme of the widget with the theme of your website. It accepts an optional
lightMode
boolean parameter to force the widget to be in light/dark mode. 3 possible usages of this function:switchTheme()
: Toggle the themeswitchTheme(true)
: Force light modeswitchTheme(false)
: Force dark mode
This function can be accessed with
window.chatWidget.switchTheme();
An example usage is shown in the MKDocs example in the
theme-switch.js
script. It toggles the theme of the widget based on the MkDocs website by listening for changes in the theme and using this function with each change.
Source Code
The widget is open-source and available on GitHub where you can report issues, suggest features, and contribute improvements.