Skip to main content

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.

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

hello@asyntai.com

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

wagtail_ai_chatbot-1.0.1.tar.gz (12.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

wagtail_ai_chatbot-1.0.1-py3-none-any.whl (11.9 kB view details)

Uploaded Python 3

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

Hashes for wagtail_ai_chatbot-1.0.1.tar.gz
Algorithm Hash digest
SHA256 4c5066d11b2cf413c8048807946b76bc77518de7d3a2ad80cdccec3fa90df6a6
MD5 1fead42db739866601a045b35429accf
BLAKE2b-256 d377421f04fe4e759041dcfc8fa6aa5064128c0e872535991054a503ffce4fa0

See more details on using hashes here.

File details

Details for the file wagtail_ai_chatbot-1.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for wagtail_ai_chatbot-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6c8f5b51160ef596ebb25bfbd8640a7736557da1d73ca880ef8c1e547155dccd
MD5 26dcfc481c14ab6a2b2e8ee1281da287
BLAKE2b-256 358f5ac45b8b2812ddaa0ef9431e5693d4ed6b237c29402adaf735c3e6ba01d3

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 files

1.0.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page