This repository is a template for Chatsky projects.
The bot presented here is fully-functional with a very simple script that should be overwritten with yours (more on that in the next section).
This bot uses SQLite to store dialog history. Refer to the context storage tutorials if you'd like to use a different DB engine.
This bot uses Telegram as an interface. Refer to the interface tutorials if you'd like to use different means of communicating.
- A unix system (e.g. Ubuntu 22.04) is recommended. Although both Chatsky and this template support other systems such as Windows, the instructions below are for unix systems.
- Git to clone this repository.
- |Option 1| Docker Engine and Docker Compose if you want to run the bot inside a docker container.
- |Option 2| Python 3.9+ if you don't want to use docker.
git clone https://github.com/deeppavlov/chatsky-template.git
cd chatsky-template
Alternatively, you can create a new repository using this one as a template via GitHub:
https://github.com/new?template_name=chatsky-template&template_owner=deeppavlov
- Write your custom functions (e.g. custom responses, custom services) into
services/bot/bot/custom
. - Edit Chatsky script at
services/bot/bot/script.py
. - Save Telegram bot token into
secrets/tg_token.txt
.
First, move to the bot directory:
cd services/bot
Next, install project dependencies:
pip install -r requirements.txt
Finally, run tests:
pytest test.py
docker build --target test services/bot
First, you need to be in the root directory of the project.
If you've done the previous step, run
cd ../..
to return from the services/bot
directory.
Next, install project dependencies (if you haven't done so yet):
(cd services/bot && pip install -r requirements.txt)
Deploy the bot to telegram with:
(export DB_URI="sqlite+aiosqlite:////$(pwd)/sqlite.db" TG_BOT_TOKEN_FILE="$(pwd)/secrets/tg_token.txt" && cd services/bot && python app.py)
docker compose up