wagtail-ai-chatbot
Adds the Asyntai AI chat assistant to a Wagtail site. The assistant answers visitor questions from your own content, day and night, in more than 80 languages.
Free and open source. Works on every Asyntai plan, including the free plan.
- Requires Wagtail 5.2 or newer, Django 4.2 or newer, Python 3.9 or newer
- Documentation: https://asyntai.com/documentation/integrations/wagtail/
Install
pip install wagtail-ai-chatbot
Add the app and the settings module to INSTALLED_APPS:
INSTALLED_APPS = [
"wagtail_asyntai",
"wagtail.contrib.settings",
# ...
]
Add the middleware, first in the list:
MIDDLEWARE = [
"wagtail_asyntai.middleware.AsyntaiWidgetMiddleware",
# ...
]
Run the migration:
python manage.py migrate wagtail_asyntai
Then open the Wagtail admin, go to Settings → Asyntai chat assistant, and paste your widget ID. You get the ID from your Asyntai dashboard, under Setup & Integration. You can paste the whole snippet; the package keeps only the ID.
That is all. The chat button appears on every page of the site.
Settings in the Wagtail admin
| Field | What it does |
|---|---|
| Widget ID | The chat runs while this holds a valid ID. Clear it to switch the chat off. |
| Show the chat to signed out visitors only | Signed in users never see the chat. |
| Widget script address | Leave this alone unless Asyntai support asks you to change it. |
The settings are per site, so a multi-site project can give each site its own assistant.
Settings in your settings file
A project that keeps configuration in environment variables can skip the admin. The admin wins when both are filled in.
ASYNTAI_WIDGET_ID = "asyntai_ab12cd34"
ASYNTAI_SHOW_TO_ANONYMOUS_ONLY = False # optional
ASYNTAI_SCRIPT_URL = "https://widget.asyntai.com/static/js/chat-widget.js" # optional
ASYNTAI_SKIP_PREFIXES = ["/admin/", "/django-admin/", "/cms/"] # optional
ASYNTAI_SKIP_PREFIXES names the paths the widget never touches. Set it when
your admin lives somewhere other than /admin/.
Placing the widget by hand
Leave the middleware out and put the tag where you want it instead:
{% load asyntai %}
...
{% asyntai_widget %}
</body>
The tag and the middleware never both fire, so it is safe to keep both.
How it works
The middleware inserts a small script just before the closing body tag of every HTML 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.
The widget ID and the script address travel to the browser on a data
attribute, never inside the script, so a pasted value cannot break out and
run. Only an https address is accepted.
The middleware leaves alone: the Wagtail admin, anything that is not
text/html, any status other than 200, a streaming response, a body another
middleware has compressed, a page with no closing body tag, and a page that
already carries the widget.
Tests
pip install wagtail
PYTHONPATH=src:. python -m django test --settings=tests.settings
50 tests. They cover reading a stored value, the settings screen in the
Wagtail admin, the middleware on ten kinds of response, the template tag, and
a node --check of the script on the rendered page.
Support
Licence
MIT. See LICENSE.
Metadata
Release files for wagtail-ai-chatbot 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| wagtail_ai_chatbot-1.0.1.tar.gz | 12.9 kB | Without provenance | Details for wagtail_ai_chatbot-1.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| wagtail_ai_chatbot-1.0.1-py3-none-any.whl | Python 3 | none | any | Details for wagtail_ai_chatbot-1.0.1-py3-none-any.whl |
Total release size: 24.8 kB
Release files / wagtail_ai_chatbot-1.0.1.tar.gz
| Download URL | wagtail_ai_chatbot-1.0.1.tar.gz |
|---|---|
| Size | 12.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4c5066d11b2cf413c8048807946b76bc77518de7d3a2ad80cdccec3fa90df6a6
|
|
BLAKE2b-256 checksum How to use checksums |
d377421f04fe4e759041dcfc8fa6aa5064128c0e872535991054a503ffce4fa0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.6
|
Release files / wagtail_ai_chatbot-1.0.1-py3-none-any.whl
| Download URL | wagtail_ai_chatbot-1.0.1-py3-none-any.whl |
|---|---|
| Size | 11.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6c8f5b51160ef596ebb25bfbd8640a7736557da1d73ca880ef8c1e547155dccd
|
|
BLAKE2b-256 checksum How to use checksums |
358f5ac45b8b2812ddaa0ef9431e5693d4ed6b237c29402adaf735c3e6ba01d3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.6
|
Security for wagtail-ai-chatbot 1.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.