Skip to content

πŸ“­ Telegram alerts

coccoinomane edited this page Jun 14, 2023 · 3 revisions

Use w3 subscribe --tg to receive Telegram alerts every time something happens on the blockchain. But, first, you need to create a Telegram bot.

1. Create the Telegram bot

  1. Open Telegram and enter @Botfather in the search tab, then select the Botfather bot.
  2. Click on START, then type /newbot. You will need to choose a name and a username for your bot.
  3. Take note of your token value and store it in web3cli: w3 config set telegram_api_key 11112222:AAASBBBSDASD. Do not share your token with anybody!
  4. Enter @your_newly_created_bot_username in the search tab and select your bot. Then click on START to subscribe to the bot.

2. Send notifications to yourself

  1. First, you need to find your Telegram user ID. To do so, enter @username_to_id_bot in the search tab and select the IDBot.
  2. Click on START. The IDBot will print your ID. Take note of it and save it in web3cli: w3 config set telegram_chat_id 1234567890.
  3. Run w3 debug telegram to send a test message.

If everything worked fine, you should receive a Telegram message on your newly created bot.

3. Notify multiple users at once

To send Telegram notifications to more than one user, using same bot:

  1. Create a group chat with the other person.
  2. Add the bot to that chat group.
  3. Configure web3cli with the chat ID of the chat group: w3 config set telegram_chat_id 1234567890

Credits

  • Thanks to @yigitest for the first implentation of the TG notifications in Crabada.py πŸ’ͺ
  • Thanks to @nikohd12 for the chat group trick