Add an AI chat agent to your Drupal site
Hazelchat answers your visitors from the pages and documents you approved, shows the sources under every answer and passes enquiries on to you. A free module adds it to every public page of your Drupal site: no theme editing.
Version 1.0.0 for Drupal 10.3 and later and Drupal 11. The Free plan includes 50 answers a month on one website, with no card, and stays free.
What you need
- Drupal 10.3 or later, or Drupal 11, with PHP 8.1 or later. No other modules.
- Access to Composer for your site (or someone who has it, such as your agency), and a Drupal account with the "Administer site configuration" permission.
- A Hazelchat account. The module needs the hosted Hazelchat service; the Free plan includes 50 answers a month on one website, with no card.
Add Hazelchat to Drupal in six steps
-
In Hazelchat
Prepare your agent
Add your content, check the details and try your agent. Under Website → Install on your website, add your website's domain.
-
In Hazelchat
Copy the installation code
Copy the installation code. It holds your public widget key, which is not a password.
-
In Drupal
Install the module
Run
composer require drupal/hazelchatin your site's folder, then turn on Hazelchat under Extend (or rundrush en hazelchat). Installing it alone loads nothing on your site. -
In Drupal
Paste the code
Go to Configuration → Web services → Hazelchat, paste the code into Installation code and click Save configuration. Only the key is kept. Drupal clears its own page caches for you.
-
In Drupal
Remove old snippets
If you pasted a Hazelchat script into your theme or a block before, remove it so the chat loads once. If a proxy or CDN caches your pages, clear it too.
-
On your site
Switch it on and test it
Back in Hazelchat, click Publish and switch on (or Switch on if your published agent is unchanged). Hazelchat checks that the script is on your website before the agent goes live. Then open your website, ask a question in the chat, return to Hazelchat and click Yes, I saw this answer.
What the module does
It adds one script to your public pages and nothing else. Your content, answers, enquiries and billing all stay in your Hazelchat workspace.
The module adds https://app.hazelchat.co/widget.js, with your public key, to the head of your public HTML pages. It stores only that key and one consent setting, has no database tables and no JavaScript of its own, and sends nothing from Drupal to Hazelchat. Administration pages and feeds never load the chat. Its settings page is in English and German, and it is free software under the GPL, version 2 or later.
Visitor consent
Klaro! If your site uses the Klaro! module (Drupal CMS includes it), the Hazelchat module adds a Hazelchat service to it, under Live chat. Klaro then holds the chat back until a visitor accepts it, and nothing loads from Hazelchat before that. Klaro only does this for roles with its Use Klaro! UI permission, so give that permission to anonymous users, as Klaro's own setup asks.
Other consent tools. Turn on Wait for my consent manager on the Hazelchat settings page. The chat then stays closed and sends no chat requests until your consent tool tells it to start:
window.dispatchEvent(new CustomEvent('hazelchat-consent', { detail: true }));
Send detail: false when a visitor withdraws consent. With Wait for my consent manager on, the small script still downloads before consent. See also cookie banners for the consent tools Hazelchat follows by itself.
Caching and security headers
Page caches
Drupal's own caches update when you save the settings. Clear any proxy or CDN in front of the site yourself.
Leave the script alone
Exclude
https://app.hazelchat.co/widget.jsfrom script combining, rewriting or delayed loading. The script must keep its own address and key.Content-Security-Policy
If you send one (for example with the CSP module), allow
https://app.hazelchat.coinscript-src,connect-srcandframe-src.
Change or remove
New widget key
If you rotate the key in Hazelchat, paste the new code on the Hazelchat settings page and save.
Pause the chat
Switch Hazelchat off in your workspace. It stops answering straight away, even on cached pages. Emptying the Installation code field removes the chat from your pages.
Remove it from the site
Uninstall the module under Extend → Uninstall (or drush pmu hazelchat), then composer remove drupal/hazelchat. Uninstalling removes its settings too. Your Hazelchat account and plan are not affected.
Updates and changes
New versions are published on drupal.org. Drupal's Update Status module tells you about them, and composer update drupal/hazelchat installs them.
1.0.0: adds the Hazelchat chat to every public page with one installation code; works with Klaro!; optional wait for your consent manager; English and German.
Drupal is a registered trademark of Dries Buytaert. Hazelchat is not affiliated with or endorsed by Dries Buytaert or the Drupal Association; the name is used here only to say which software the module works with.
Let your Drupal site answer from its own pages.
Questions? Email hello@hazelchat.co. We answer within one business day. Not on Drupal? See all the ways to install Hazelchat. Other guides: add an AI chat agent to any website and cookie banners.