Skip to content

Deeper Knowledge

If you have no problems with python and understanding examples from documentation, there is a chance that you are thinking about more complex projects. There are some useful things, that you might need.

Templates

Here is one of the simplest structures for your first project. Most of the module names are self-explanatory. I would suggest putting configuration settings in the utils module, along with any additional helper files.

├── bot/
|   ├── filters/
|   ├── handlers/
|   ├── keyboards/
|   ├── middlewares/
|   └── utils/
|   .env
└── main.py

There are some more complex community templates available for you to explore.

Latand/tgbot_template_v3 wakaree/aiogram_bot_template andrew000/aiogram-template

Databases

If you are planning to make somewhat complex bots you would most definitely use databases. There is also a CS50SQL course that teaches basic of SQL language. They mostly use SQLite to grasp the basics, but it's not recommended to use it with telegram bots (as any file database can be locked while working with async requests).

Look into PostgreSQL with SQLAlchemy ORM and Alembic if you want an SQL database or into MongoDB for NoSQL one.

APScheduler

If you are planning to have scheduled or intervaled tasks you should look into APScheduler.

Check out this part of Telegram Bot API FAQ before sending messages to all of your users

Redis

There is a lot of data in bots' memory storage that could be lost after restarting. To prevent it you should use Redis.

ngrok

If you are trying to localhost an aiogram bot using webhooks you definitely need to use ngrok to get the webhook link.

i18n

If you want to have several localizations and don't know how implement that - use aiogram i18n library.

Deploying

If you are ready to show off your bot you would need to host it somewhere. There are a lot of affordable hostings that you can choose from.

My experience

I have personally been using MVPS.net and have no complaints. However, it's important to understand the basics of SSH protocol usage.

To make the deployment as smooth as possible you'd better be familiar with Docker and Git (with, for example, GitHub).