Skip to content

This is an example of a simple echo bot using webhooks technology.

Notifications You must be signed in to change notification settings

lixelv/simple_aiogram_webhook

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

INSTALLATION

NGROK

To work with this bot, and generally to work with webhooks on aiogram, we need to download ngrok for your PC or VPS. After that, open Windows PowerShell and navigate to the folder with the installed file (Type in Windows PowerShell:

set-location 'path to folder'

). Obtain the authtoken from the website, then run the following command:

chmod +x ngrok
./ngrok authtoken (your_token). 

After entering the authentication code, we need to start ngrok by running the following command:

./ngrok http (port)

You can choose any port you like, but for the bot to work, I used port 8080. Then a window with the running ngrok will appear. Copy the first URL after the Forwarding line, it should look something like this: https://6ec8-78-37-108-80.ngrok-free.app. You need to paste this URL when you start the bot (I set it up in the webhook_polling method). If you want to run this bot, replace the parameter YOUR_TELEGRAM_API_TOKEN with your API token, which you can obtain from the BotFather bot, and change the parameter YOUR_USER_ID to your user_id. However, this is optional. If you don't want to receive a message about the start and stop of the bot, simply do not enter the admin_list parameter in the last line of code. Here is a link to the bot for getting your user_id in Telegram: username_to_id_bot. Launch and try it out.

LIBRARIES

To install libraries which I am using in my repository, just run this command

pip install путь_до_файла/requests.txt

.ENV

In my repository you can see file .env, there I am storing my telegram token, link and my telegram id. Just replace these parameters on yours.

WEBHOOK_POLLING

If you are creating your own aiogram bot, instead of the line executor.start_polling(dp, skip_updates=True), use the line webhook_pooling(dp, port, link) these 3 parameters are mandatory, the rest are optional. Here is a list of additional parameters:

  • admin_list: Pass a list of your bot admins or a list with a single element - your id.
  • startup_message and shutdown_message: Specify what you want to send to the admin_list when the bot starts and stops.

If you have any issues or questions, contact simeonlimon.

About

This is an example of a simple echo bot using webhooks technology.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages