Add AI to Discourse
Integrate the kapa.ai chat widget into your Discourse forum to enable users to ask natural language questions about your product, significantly enhancing user experience by providing quick and accurate answers.
Prerequisites
Before adding the widget to your Discourse forum, you'll need to:
- Ensure you have a kapa.ai project set up with your knowledge sources added
- Follow the general installation instructions to enabled your domain and obtain your
Website ID
- Have administrator access to your Discourse forum
Installation
1. Access Admin Panel
- Log in to your Discourse forum as an administrator
- Navigate to the admin panel by clicking the hamburger menu (☰) and selecting Admin
2. Configure Theme
- Go to Customize → Themes in the admin dashboard
- Select your active theme (marked with a green checkmark)
- Click Edit CSS/HTML
- Select the
</head>
tab
3. Add Widget Script
Add the following script to the bottom of the head section:
<script
defer
src="https://widget.kapa.ai/kapa-widget.bundle.js"
data-website-id="XXX-XXX-XXX"
data-project-name="PROJECT_NAME"
data-project-color="#HEX_COLOR_CODE"
data-project-logo="https://LINK_TO_LOGO.com/logo.png"
></script>
4. Update Content Security Policy
- Return to the main Admin dashboard
- Go to Settings
- Search for "Content Security Policy"
- Locate
content_security_policy_script_src
- Add the following domains (space-separated):
https://www.google.com
https://www.gstatic.com
https://widget.kapa.ai
- Save the changes
5. Verify Installation
Refresh your Discourse forum and confirm that the widget appears and functions correctly.
To tailor the widget to your brand and specific needs, visit our Configuration page. There, you'll find detailed instructions on how to adjust colors, logos, and other widget properties.
If you encounter any Content Security Policy (CSP) errors in your browser's console, double-check that you've properly added all required domains to the CSP settings in step 4.