Telegram Bot template with aiogram for deployment on Deta Space.
The bot has several useful features, including logging of errors and events to Deta Base, preset CallbackAnswer middleware and automatic webhook setup.
- Python 3.9 or higher
- A Deta Space account
- Space CLI
- A Telegram Bot token from @BotFather
- Clone the repository:
git clone https://github.com/mamsdeveloper/AiogramDetaBot.git - Go to cloned repo's folder
- Run
space newto create a new Space project - Run
space pushto deploy the code to Deta Space - Go to Builder and open builder instance of your project
- Set up your Telegram Bot token in Develop - Configuration tab
- Return to Develop - Overview tab and click on
Open Builder Instancebutton. There will be information about your bot's webhook, if it is set up correctly. - Send
/startto your bot and check that it responds
To enable logging of errors and events, set ENABLE_ERRORS_LOGS and ENABLE_EVENTS_LOGS environment variables to True in Develop - Configuration tab. Logs will be stored in logs tables.
Additionally, you can set ERROR_LOGS_EXPIRE_AFTER and EVENTS_LOGS_EXPIRE_AFTER environment variables to set expiration time for logs in seconds. By default, logs will be stored forever.
CallbackAnswer middleware is used to automatically answer on all callback queries, so you don't need to do it manually.
The bot automatically sets webhook on startup.
You can find webhook info on /info page. Root page redirects to /info page.
You can find version tuned for my personal purposes in personal-tuned branch. I may have some additional features