Telegram Integration - pattertj/LoopTrader GitHub Wiki

Telegram is a cloud-based mobile and desktop messaging app with a focus on security and speed. It can be integrated into LoopTrader for notifications and interactions with your Bot from your phone.

Setting up your Bot

1) Create your Bot

Using @BotFather, create a new bot using the instructions from Telegram.

Make sure to save the generated Token. The token is a string along the lines of 110201543:AAHdqTcvCH1vGWJxfSeofSAs0K5PALDsaw that is required to authorize the bot and send requests to the Bot API. Keep your token secure and store it safely, it can be used by anyone to control your bot.

2) Connect to your Bot

Using Telegram on your mobile device, start a new group chat with your bot and send it a message. Your bot won't do much yet, but it will confirm your bot is created!

3) Configure your Bot's settings

It is highly recommended to ensure the following settings are configured:

  • /setjoingroups - Disabled
  • /setprivacy - Enabled

You can do so by chatting with @BotFather, entering the commands above, and following the instructions. Make sure you do not enable /setjoingroups before connecting with your bot or it won't work.

Optionally, you can also enable a few quality-of-life features on your bot:

  • /setuserpic - This will let you change your bot's profile picture.
  • /setcommands - This will give you type-ahead suggestions suggestions when you type / in the chat with your bot.

Configuring LoopTrader

The Telegram notifier in LoopTrader uses the python-telegram-bot for communicating with Telegram. To use it, you must install the module and then configure it.

The required configuration parameters should be setup in LoopTrader's .env file using the documented Environment Variables.

# Telegram Notifier Variables
TELEGRAM_TOKEN= ""
TELEGRAM_CHATID= ""

The token was issued when you created your bot in Step 1. The Chat ID can be retrieved by visiting https://api.telegram.org/botXXX:YYYYY/getUpdates (replace the XXX: YYYYY with your Token you got from the Telegram BotFather)