Wagtail Integration
An AI assistant that answers questions on your Wagtail site
Overview
The Wagtail package puts an AI assistant on your site. A chat button sits in the corner of every page, visitors ask a question in their own words, and the answer comes from your own content: your website, your uploaded documents and your help centre articles.
AI disclaimer: Answers on your website are generated by AI. They may sometimes be inaccurate or incomplete and should be verified before you rely on them, especially for important decisions.
How It Works
The package adds a middleware that puts one small script just before the closing body tag of every page. That script waits for the page to finish loading, then fetches the chat widget from Asyntai, so your site draws first and page speed is unchanged. Your server never talks to Asyntai; only the visitor's browser does.
You change nothing in your templates. The middleware leaves the Wagtail admin alone, and it leaves alone anything that is not an HTML page.
Requirements
- An Asyntai account. The free plan is enough to start.
- A Wagtail site, version 5.2 or newer, on Django 4.2 or newer and Python 3.9 or newer.
- Access to the code of that site, because you install a Python package.
Installation
Follow these steps to add Asyntai to your Wagtail site:
Install the package
Install it from the Python Package Index, in the same environment as your site:
pip install wagtail-ai-chatbot
Add it to your settings
Add the app and the Wagtail settings module to INSTALLED_APPS, and the middleware at the top of MIDDLEWARE:
INSTALLED_APPS = ["wagtail_asyntai", "wagtail.contrib.settings", ...]
MIDDLEWARE = ["wagtail_asyntai.middleware.AsyntaiWidgetMiddleware", ...]
Run the migration
This creates the table that holds your settings:
python manage.py migrate wagtail_asyntai
Paste your widget ID
In the Wagtail admin, open Settings and then Asyntai chat assistant. Paste your widget ID and select Save. You find the ID in your Asyntai Dashboard under Setup & Integration. You can paste the whole snippet; the package keeps only the ID.
Tip: Add your documents, questions and answers, and your instructions in the Asyntai Dashboard before you publish, so the assistant answers properly from the first visitor.
Settings
- Widget ID: the chat is on while this holds a valid ID, and off when it is empty.
- Show the chat to signed out visitors only: signed in users never see the chat. Useful when the assistant is there to answer people who have not signed up yet.
- Widget script address: leave this as it is unless Asyntai support asks you to change it.
The settings are per site, so a project that serves several sites from one Wagtail install can give each site its own assistant.
Settings in Your Settings File
A project that keeps its configuration in environment variables can skip the admin and set the values in code. The admin wins when both are filled in.
ASYNTAI_WIDGET_ID = "asyntai_ab12cd34"
Three more values are optional: ASYNTAI_SHOW_TO_ANONYMOUS_ONLY, ASYNTAI_SCRIPT_URL, and ASYNTAI_SKIP_PREFIXES. The last one names the paths the widget never touches, which you need when your admin does not live at /admin/.
Placing the Widget by Hand
If you would rather choose the place yourself, leave the middleware out and put the tag in your base template instead. The tag and the middleware never both fire, so it is safe to keep both.
{% load asyntai %} ... {% asyntai_widget %}
What the Assistant Can Do
- Answer visitor questions instantly, 24/7, on every page
- Respond in more than 80 languages, automatically detected from the question
- Stay open while the visitor moves from page to page
- Use your own uploaded docs, FAQs, and instructions to give accurate answers
Privacy
The package publishes exactly two values to the page: the widget ID and the script address. Nothing about your pages or your users is sent to Asyntai. Only the visitor's browser talks to Asyntai, and only when the visitor opens the chat.
Plans & Pricing
The Wagtail integration is available on all Asyntai plans, including Free. Each plan includes a monthly message allowance shared across all your channels and integrations. View pricing.
Uninstalling
Clear the widget ID field to switch the chat off. To remove the package, take the middleware and the app out of your settings and uninstall it with pip.
Source Code
The package is free and open source, under the MIT licence. You can read every line on GitHub.
Need Help?
If you have any questions or run into issues, contact us at [email protected].