Prerequisites
Before you begin, ensure you have the following installed:- Python 3.12 or higher
- PostgreSQL database server
- pip (Python package manager)
- Git (to clone the repository)
Installation steps
Create a virtual environment
Create a new Python virtual environment to isolate the bot’s dependencies:This creates a
.venv directory containing the isolated Python environment.Activate the virtual environment
Activate the virtual environment based on your operating system:Your terminal prompt should now show
(.venv) indicating the virtual environment is active.Install dependencies
Install all required Python packages from the requirements file:This installs the following core dependencies:
aiogram(v3.6.0) - Telegram Bot frameworkaiogram_dialog- UI dialog systemasyncpg(v0.29.0) - PostgreSQL async driversqlalchemy(v2.0.30) - Database ORMapscheduler(v3.10.4) - Background task scheduleraiohttp(v3.9.5) - HTTP client for VBB APIgeopy(v2.4.1) - Geolocation parsingtoml(v0.10.2) - Configuration file parser
Configure the bot
Copy the example configuration file and edit it with your details:See the Configuration page for detailed information on all configuration options.
Set up the database
Ensure your PostgreSQL server is running and create a database for the bot:Update the
database_url in your config.toml file with your PostgreSQL connection string.Verifying the installation
Once the bot is running, you should see log output indicating successful startup. Test the bot by:- Opening Telegram and searching for your bot by username
- Sending the
/startcommand - Verifying you receive a response from the bot
Troubleshooting
Database connection errors
If you encounter database connection errors, verify:- PostgreSQL is running on the expected host and port
- The database specified in
config.tomlexists - The database credentials are correct
- The database user has appropriate permissions
Module import errors
If you see import errors when running the bot:- Ensure the virtual environment is activated
- Verify all dependencies installed correctly with
pip list - Try reinstalling dependencies with
pip install -r requirements.txt --force-reinstall
Bot token errors
If the bot fails to connect to Telegram:- Verify your bot token in
config.tomlis correct - Ensure there are no extra spaces or quotes in the token
- Confirm the bot hasn’t been deleted in BotFather
Next steps
- Configure the bot’s settings in Configuration
- Set up automated deployment with Docker
- Learn about the bot’s features in the user guide