Streamlit Component
Add the Asyntai AI chat assistant to your Streamlit app
Overview
Streamlit is a Python framework for data apps, dashboards and AI tools. The Asyntai package adds the chat bubble to your app with one line of Python. It works on your own server and on Streamlit Community Cloud.
The assistant answers your users from your own content, in more than 80 languages, day and night.
Requirements
- Streamlit 1.28 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 Streamlit 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 streamlit-ai-chatbot
On Streamlit Community Cloud, add streamlit-ai-chatbot to your requirements.txt.
Add One Line to Your App
Call chatbot() near the top of your app file:
import streamlit as st
from streamlit_ai_chatbot import chatbot
chatbot("asyntai_1a2b3c4d5e6f")
st.title("My app")
You can paste the whole snippet from the Install page. The package keeps only the ID.
Run Your App
streamlit run app.py
The chat bubble is in the corner of the page.
Keeping the ID in Secrets
Call chatbot() with no ID, and the package reads ASYNTAI_WIDGET_ID from st.secrets or from an environment variable:
# .streamlit/secrets.toml
ASYNTAI_WIDGET_ID = "asyntai_1a2b3c4d5e6f"
chatbot()
On Streamlit Community Cloud, add the same line in the app's Secrets settings.
Multipage Apps
With st.navigation, call chatbot() in your main file, before pg.run():
pg = st.navigation([st.Page(home), st.Page(pricing)])
chatbot("asyntai_1a2b3c4d5e6f")
pg.run()
The chat stays open when the user moves between pages. With a pages/ folder, call chatbot() at the top of each page.
Options
| Argument | Default | What it does |
|---|---|---|
widget_id | from secrets or environment | Your Asyntai widget ID |
script_url | the Asyntai CDN | Advanced. Change it only if Asyntai support asks you to |
chatbot() returns True when the chat is on the page.
How It Works
On Streamlit 1.52 and later, the package adds the widget script with st.html. On older versions it uses a hidden component. The empty block is hidden in both cases, so your layout stays the same.
Streamlit runs your script again after every click. The widget loads once per browser tab and stays open through these reruns.
Answering From Your Content
Add your documentation, website and files in the Asyntai dashboard. The assistant then answers questions about your app, your data and your product.
Removing It
Delete the chatbot() line and rerun 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].