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.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file wagtail_ai_chatbot-1.0.1.tar.gz.
File metadata
- Download URL: wagtail_ai_chatbot-1.0.1.tar.gz
- Upload date:
- Size: 12.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.10.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4c5066d11b2cf413c8048807946b76bc77518de7d3a2ad80cdccec3fa90df6a6
|
|
| MD5 |
1fead42db739866601a045b35429accf
|
|
| BLAKE2b-256 |
d377421f04fe4e759041dcfc8fa6aa5064128c0e872535991054a503ffce4fa0
|
File details
Details for the file wagtail_ai_chatbot-1.0.1-py3-none-any.whl.
File metadata
- Download URL: wagtail_ai_chatbot-1.0.1-py3-none-any.whl
- Upload date:
- Size: 11.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.10.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6c8f5b51160ef596ebb25bfbd8640a7736557da1d73ca880ef8c1e547155dccd
|
|
| MD5 |
26dcfc481c14ab6a2b2e8ee1281da287
|
|
| BLAKE2b-256 |
358f5ac45b8b2812ddaa0ef9431e5693d4ed6b237c29402adaf735c3e6ba01d3
|