Back to Dashboard

Documentation

Learn how to use Asyntai

Django Package

Add the Asyntai AI chat assistant to your Django site

Create Account

Overview

Django is a Python web framework. The Asyntai package is a small Django app. Install it, add one setting, and the chat bubble is on every page of your site. You edit no template and run no migration.

The assistant answers your visitors from your own content, in more than 80 languages, day and night.

Requirements

  • Django 4.2 or later
  • Python 3.10 or later
  • An Asyntai account. The Free plan is enough to try the widget

Installation

Follow these steps to add Asyntai to your Django site:

1

Get Your Widget ID

Sign in to Asyntai and open the Install page. The widget ID is the value of data-asyntai-id in the snippet shown there. It starts with asyntai_.

2

Install the Package

pip install django-asyntai-ai-chatbot
3

Update Your Settings

Open your settings.py. Add the app, add the middleware at the end of the list, and add your widget ID:

INSTALLED_APPS = [
    # ...
    "django_asyntai",
]

MIDDLEWARE = [
    # ...
    "django_asyntai.middleware.AsyntaiWidgetMiddleware",
]

ASYNTAI_WIDGET_ID = "asyntai_1a2b3c4d5e6f"

You can paste the whole snippet from the Install page. The package keeps only the ID.

4

Open Your Site

Restart the server and open any page. The chat bubble is in the corner of every page.

Settings

SettingDefaultWhat it does
ASYNTAI_WIDGET_IDemptyYour Asyntai widget ID. Leave it empty to switch the chat off
ASYNTAI_SHOW_TO_ANONYMOUS_ONLYFalseSet it to True to hide the chat from signed-in users
ASYNTAI_SKIP_PREFIXES["/admin/"]Paths where the chat never shows. Change it if your admin is at another path
ASYNTAI_SCRIPT_URLthe Asyntai CDNAdvanced. Change it only if Asyntai support asks you to

The settings are read on every request, so you can keep the widget ID in an environment variable:

import os
ASYNTAI_WIDGET_ID = os.environ.get("ASYNTAI_WIDGET_ID", "")

Placing the Widget by Hand

If you prefer to choose where the widget goes, leave the middleware out and put the template tag just before </body> in your base template:

{% load asyntai %}
...
{% asyntai_widget %}
</body>

The tag and the middleware never both add the widget, so it is safe to keep both.

How It Works

The middleware adds a small loader to every HTML page, just before </body>. The loader waits for the page's load event, so your own content always renders first.

The middleware leaves alone the admin, JSON and other non-HTML responses, error pages, streaming responses, and pages that already have the widget.

Tip: If you use GZipMiddleware, put the Asyntai middleware below it in the list. python manage.py check warns you when the order is wrong, or when the widget ID has the wrong format.

Answering From Your Content

Asyntai reads your published pages. Add your site URL in the dashboard, and the assistant answers from the same pages the widget sits on. You can also add documents, and question and answer pairs.

Removing It

Remove the middleware line, or clear ASYNTAI_WIDGET_ID, and restart the server. The chat bubble is gone.

Plans & Pricing

The package is free. View pricing.

Need Help?

If you have any questions or run into issues, contact us at [email protected].