Setting Up Telegram Notifications

Page Contents

Create Telegram Bot

Download Files From Github

Launch Telegram Bot On Heroku

Test Setup

Here, you will create your own Telegram bot, which will receive notifications of successful or failed trades from the Trading View alert. The trading function of the Bot is not fully finished. For now, you can trade Spot Binance tickers on the Binance Testnet.

Create Telegram Bot With @BotFather

  1. Add @BotFather to Telegram

  2. Send message "/newbot"

  3. Enter a name (this appears as the name in bold in your list of Telegram chats)

  4. Enter a username (this appears after the "@")

  5. You will be given an access token

    1. Store it somewhere safe. The token can be used to take full control of your bot.

Download Files From Github

Assumes you have Git and NodeJS installed.

  1. cd into folder where you want the repo folder downloaded

Launch Telegram Bot On Heroku

  1. Upload files to Heroku

    1. Create a Heroku account

    2. Create a new app on Heroku

      1. Go to New (top right) > Create new app

      2. Enter a name, choose region, and click Create app

    3. Install the Heroku CLI (linkarrow-up-right)

      1. verify installation with heroku --version

      2. heroku update // updates heroku CLI

      3. heroku login

        1. press any key to continue

        2. Web browser should popup prompting login

    4. cd into the "telegram-trading-bot" folder

    5. git remote add heroku <yourHerokuGitURL> // adds a remote called "heroku", which is an alias for the URL that follows

      • Find the HTTPS URL in the your Heroku account > project page > Settings tab (top center). Look in the App Information category for the Heroku git URL. It looks like https://git.heroku.com/example-app.git

      • git remote -v // check if remote is added

    6. push files to Heroku git URL with git push heroku main

      1. macOS may show a prompt for additional authentication. If so, type "blank" into username field and enter API Key into the password field. You can generate API Key withheroku auth:token

    7. Code is uploaded if you see various logs appearing for 10-15s

  2. Set environment variables

    1. In your Heroku account, go to Settings > Config Vars > click Reveal Config Vars

    2. Enter the environment variables:

  3. To view logs, go to More (top right) > View logs to see bot status and logs

Test Setup

Test if the bot is up:

Be sure to add the TG_BOT_TOKEN and TG_CHAT_ID env vars in your server environment (see Setting Up Env Vars). On your Telegram App, search for and start talking to the Telegram bot. To test if the bot is up, send a "/start" message. A menu should appear.

Test notifications:

Every time you make a successful or failed trade with the Trading View alert bot, a message should show. Use sendAlert.js or a real Trading View alert to make a trade.

Test trading features:

The "trading" features on the Telegram bot is only experimental. So far, you can only do trades on Binance Testnet. Add your Binance Testnet API keys into Heroku. Then enter "/start" and follow the keyboard buttons to make a market buy order of 100 DOGE, using USDT as the quote token.

Last updated