Skip to main content

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:

  1. Ensure you have a kapa.ai project set up with your knowledge sources added
  2. Follow the general installation instructions to enabled your domain and obtain your Website ID
  3. 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

  1. Go to CustomizeThemes in the admin dashboard
  2. Select your active theme (marked with a green checkmark)
  3. Click Edit CSS/HTML
  4. 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

  1. Return to the main Admin dashboard
  2. Go to Settings
  3. Search for "Content Security Policy"
  4. Locate content_security_policy_script_src
  5. Add the following domains (space-separated):
    • https://www.google.com
    • https://www.gstatic.com
    • https://widget.kapa.ai
  6. Save the changes

5. Verify Installation

Refresh your Discourse forum and confirm that the widget appears and functions correctly.

Customization Options

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.

Troubleshooting

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.