aiohttp-ai-chatbot
Adds the Asyntai AI chat assistant to an aiohttp 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 Python 3.9 or newer and aiohttp 3.8 or newer
- Documentation: https://asyntai.com/documentation/integrations/aiohttp/
Install
pip install aiohttp-ai-chatbot
from aiohttp import web
from aiohttp_ai_chatbot import setup
app = web.Application()
app.router.add_get("/", index)
setup(app, widget_id="asyntai_ab12cd34")
web.run_app(app)
Or pass the middleware yourself:
from aiohttp_ai_chatbot import asyntai_middleware
app = web.Application(middlewares=[asyntai_middleware("asyntai_ab12cd34")])
You get the widget ID from the Install page of your Asyntai dashboard. You can paste the whole snippet; the package keeps only the ID.
That is all. The chat button appears on every HTML page of the site. JSON, files, streams, websockets and redirects pass through untouched.
Options
setup(
app,
widget_id="asyntai_ab12cd34", # without it: the ASYNTAI_WIDGET_ID environment variable
skip_paths=["/admin*"], # the default
)
- Leave out
widget_idto read theASYNTAI_WIDGET_IDenvironment variable. It is read on every request, so you can change it without a code change. An empty value switches the chat off. skip_pathslists paths that never get the widget. A path that ends in*also matches everything below it, so/admin*covers/adminand/admin/users, but not/administrator.
The middleware changes complete web.Response pages with status 200 and the
text/html content type. A response that uses enable_compression() still
gets the widget, because aiohttp compresses the body after the middleware.
Files from add_static or web.FileResponse and responses that you prepare
and stream yourself are sent as they are.
Placing the widget by hand
With aiohttp-jinja2, register the helper once:
import aiohttp_jinja2
from aiohttp_ai_chatbot import asyntai_widget
env = aiohttp_jinja2.setup(app, loader=...)
env.globals["asyntai_widget"] = asyntai_widget
Then put it before the closing body tag:
{{ asyntai_widget() }}
</body>
widget_snippet() returns the same HTML as a plain string. The middleware
never adds a second copy to a page that already has one.
How it loads
The widget script loads after the page has finished loading, so your page draws first and page speed does not change.
License
MIT
Metadata
Release files for aiohttp-ai-chatbot 1.0.0
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 |
|---|---|---|---|---|
| aiohttp_ai_chatbot-1.0.0.tar.gz | 11.8 kB | Without provenance | Details for aiohttp_ai_chatbot-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| aiohttp_ai_chatbot-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for aiohttp_ai_chatbot-1.0.0-py3-none-any.whl |
Total release size: 19.9 kB
Release files / aiohttp_ai_chatbot-1.0.0.tar.gz
| Download URL | aiohttp_ai_chatbot-1.0.0.tar.gz |
|---|---|
| Size | 11.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a31dafaa2511461102552183113b19a79e63ce3e1a5605185586ea8d89ada698
|
|
BLAKE2b-256 checksum How to use checksums |
80ddcca26e8e6d9dcd1170a590be57031cdde1cddf64102a37314907921c1b96
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.10
|
Release files / aiohttp_ai_chatbot-1.0.0-py3-none-any.whl
| Download URL | aiohttp_ai_chatbot-1.0.0-py3-none-any.whl |
|---|---|
| Size | 8.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cab72cb4e910aa4ad4a647202a20ab8034182411a6ea0d7f53cbb1fe2419c1e3
|
|
BLAKE2b-256 checksum How to use checksums |
d88bc43adc63f7153e302947553d7bcb8628858fe774ad09961fbde18130398d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.10
|
Security for aiohttp-ai-chatbot 1.0.0
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.