Plotly Dash
Add the Asyntai AI chat assistant to your Dash app
Overview
Plotly Dash is a Python framework for data apps and dashboards. The Asyntai package adds the chat assistant to a Dash app with one line of code. On Dash 3 and later it also works with no code change at all.
The assistant answers your users from your own content, in more than 80 languages, day and night. It can explain your dashboard, your data sources and your product.
Requirements
- Dash 2.0 or later (the no-code mode needs Dash 3 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 Dash app:
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_.
Install the Package
pip install dash-ai-chatbot
Add One Line to Your App
Call init_app after you create the app:
from dash import Dash, html
import dash_ai_chatbot
app = Dash(__name__)
app.layout = html.Div("Hello")
dash_ai_chatbot.init_app(app, widget_id="asyntai_1a2b3c4d5e6f")
if __name__ == "__main__":
app.run()
You can paste the whole snippet from the Install page. The package keeps only the ID.
Open Your App
Restart the app and open it. The chat bubble is in the corner of every page, including every page of a multi-page app.
No Code Change (Dash 3 and Later)
On Dash 3 and later you can skip step 3. Install the package and set one environment variable:
ASYNTAI_WIDGET_ID=asyntai_1a2b3c4d5e6f
Every Dash app that runs with this variable shows the chat. Without the variable, the package does nothing.
Options
| Option | Environment variable | What it does |
|---|---|---|
widget_id | ASYNTAI_WIDGET_ID | Your Asyntai widget ID. Leave it empty to switch the chat off |
script_url | ASYNTAI_SCRIPT_URL | Advanced. Change it only if Asyntai support asks you to |
If you call init_app(app) with no widget ID, the package reads ASYNTAI_WIDGET_ID each time the page is built. So you can keep the ID out of your code.
How It Works
Dash serves one HTML page for the whole app. The package adds a small loader to that page, just before </body>. The loader waits for the page's load event, so your app always renders first.
It works with a custom index_string, with url_base_pathname, and with apps that override interpolate_index. It never adds the widget twice.
Tip: Running several Dash apps? Pass a different widget_id to each init_app call, and each app gets its own assistant.
Answering From Your Content
Asyntai reads your published pages. Add your site URL in the dashboard, and the assistant answers from those pages. You can also add documents, and question and answer pairs, for example about the metrics in your dashboard.
Removing It
Remove the init_app line, or clear ASYNTAI_WIDGET_ID, and restart the app. 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].