Skip to content

Latest commit

 

History

History
36 lines (26 loc) · 4.04 KB

README.md

File metadata and controls

36 lines (26 loc) · 4.04 KB

yandex-serverless-aiogram-bot

Supported python versions Aiogram Yandex.Cloud

Simple Telegram bot example on aiogram framework using Yandex Cloud with Webhook

Steps

  1. First create a bot with telegram "BotFather" and copy TOKEN to your notes

  2. Go to Yandex Cloud Console

  3. Create Yandex Service account in Yandex Cloud with roles editor and serverless.functions.invoker

  4. 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 file index.py in Yandex Cloud Function Editor
    • create file requirements.txt in Yandex Cloud Function Editor
    • copy and paste data from requirements.txt to file requirements.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
  5. 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
  6. You need to create Webhook:

    • put your TOKEN and PUBLIC_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"}
  7. Send /start message to your bot. Everything should work 🙂