Add an AI chat agent to your Statamic 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 addon adds it to every page of your Statamic site: no template editing.
Version 1.0.0 for Statamic 5 and 6. The Free plan includes 50 answers a month on one website, with no card, and stays free.
Works with Statamic 5 and 6, including static caching and multi-site.
What you need
- Statamic 5 (PHP 8.2 or later) or Statamic 6 (PHP 8.3 or later), installed with Composer.
- Someone who can run Composer for the site. If your agency looks after it, send them the steps.
- A Hazelchat account. The addon needs the hosted Hazelchat service; the Free plan includes 50 answers a month on one website, with no card.
Add Hazelchat to Statamic in five 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 Statamic
Install the addon
Run
composer require hazelchat/statamic-hazelchat. The addon is free and listed on the Statamic Marketplace. Installing it alone loads nothing on your site. -
In Statamic
Paste the code
Statamic 6: in the Control Panel open Tools → Addons → Hazelchat, paste the code into Installation code and save. Statamic 5: add
HAZELCHAT_INSTALLATION_CODE=with your 64-character key to the site's.envfile. If you use static caching, clear it (php please static:clear). If you pasted a Hazelchat script into a template before, remove it so the chat loads once. -
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.
Send this to your agency
Copy this message, put your installation code where it says so, and send it to whoever looks after your site.
Please add the Hazelchat chat to our Statamic site:
1. composer require hazelchat/statamic-hazelchat
2. Statamic 6: Control Panel → Tools → Addons → Hazelchat, paste this
into "Installation code" and save. Statamic 5: put its 64-character key
in .env as HAZELCHAT_INSTALLATION_CODE.
[our installation code from Hazelchat]
3. Clear the static cache if the site uses one.
Guide: https://hazelchat.co/integrations/statamic/
What the addon does
It adds one script to the pages of your site and nothing else. Your content, answers, enquiries and billing all stay in your Hazelchat workspace.
The addon adds https://app.hazelchat.co/widget.js, with your public key, just before </body> on the HTML pages of your site, including pages served from Statamic's static cache. It keeps only the key, never the pasted script. It has no database tables, adds no scheduled tasks and sends nothing from Statamic to Hazelchat. The Control Panel, live preview, redirects, JSON and other non-HTML responses never load the chat. If your site sets a CSP nonce through Laravel, the script carries it. Its settings are in English and German, and it is free software under the MIT licence.
Templates, .env and more sites
- Only on some pages: set
HAZELCHAT_AUTO_INJECT=falseand put{{ hazelchat }}(Antlers) or<s:hazelchat />(Blade) where the chat should load. A page with the tag is never given a second one. - Settings in .env:
HAZELCHAT_INSTALLATION_CODEandHAZELCHAT_WAIT_FOR_CONSENT=truework on Statamic 5 and 6. On Statamic 6 a code saved in the Control Panel wins. - More sites: every site uses the same code by default. To give one site its own code, or none, add the attribute
hazelchatto that site under Configure → Sites (or inresources/sites.yaml); an empty value turns the chat off there.
Visitor consent
Statamic has no cookie banner of its own. Usercentrics, CCM19 and consentmanager can allow the chat themselves when you add a service named "Hazelchat" there (see cookie banners). If your consent tool must allow the chat first in another way, turn on Wait for my consent manager (or set HAZELCHAT_WAIT_FOR_CONSENT=true). 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. If your site must block even the script download, let your consent tool block that script too.
If the chat does not appear
Clear the static cache
After you install, change the code or remove the addon, run
php please static:clear.Check the code
Paste the whole installation code, or only its 64-character key. Anything else, such as an API key, shows nothing; the settings page says so.
Check the layout
The chat goes before
</body>. A layout without that tag gets nothing; use{{ hazelchat }}there.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 your site sends a policy, allow
https://app.hazelchat.coinscript-src,connect-srcandframe-src.A second domain
The Free plan serves one website. A second site on another domain needs a plan with more websites.
Change or remove
New widget key
If you rotate the key in Hazelchat, paste the new code into the addon settings (or .env) and clear the static cache.
Pause the chat
Switch Hazelchat off in your workspace. It stops answering straight away, even on cached pages.
Remove it from the site
Run composer remove hazelchat/statamic-hazelchat and clear the static cache. Your Hazelchat account and plan are not affected.
Updates and changes
Update with composer update hazelchat/statamic-hazelchat; the Control Panel shows new versions under Tools → Updates.
1.0.0: adds the Hazelchat chat to the pages of your site from one installation code; the {{ hazelchat }} tag; a code per site; optional wait for your consent manager; English and German settings.
Hazelchat is an independent addon and is not affiliated with or endorsed by Statamic; the name is used here only to say which software the addon works with.
Let your Statamic site answer from its own pages.
Questions? Email hello@hazelchat.co. We answer within one business day. Not on Statamic? See all the ways to install Hazelchat.