Simple Telegram bot example on aiogram framework using Yandex Cloud with Webhook
-
First create a bot with telegram "BotFather" and copy
TOKEN
to your notes -
Go to Yandex Cloud Console
-
Create Yandex Service account in Yandex Cloud with roles
editor
andserverless.functions.invoker
-
Create Yandex Cloud Function in Yandex Cloud:
- choose programming language, in our case it will be Python
- copy and paste the code from
index.py
to fileindex.py
in Yandex Cloud Function Editor - create file
requirements.txt
in Yandex Cloud Function Editor - copy and paste data from
requirements.txt
to filerequirements.txt
in Yandex Cloud Function Editor - select below Yandex Service account you created earlier
- add variable
TOKEN
and put your token data there - click
Create function
-
You are back to your Yandex Cloud Function view:
- check the box
Public function
✅ - copy the link
PUBLIC_FUNCTION_URL
to your public function in notes
- check the box
-
You need to create Webhook:
- put your
TOKEN
andPUBLIC_FUNCTION_URL
in template below 👇 - template:
https://api.telegram.org/botTOKEN/setWebhook?url=PUBLIC_FUNCTION_URL
- put this link to your browser and press
enter
- you will get this message:
{"ok":true,"result":true,"description":"Webhook was set"}
- put your
-
Send
/start
message to your bot. Everything should work 🙂