TradingView
Trendoscope
Nov 14, 2021 4:59 AM

How to create simple web-hook to send alerts to Telegram Education

Ether / United States DollarCoinbase

Description

Hello Traders,

In this video, I have demonstrated how to create a simple web-hook which can send your Tradingview alerts to Telegram channel or group for zero cost.

⬜ Tools Used
Telegram Messenger
Replit - Cloud platform for hosting small programs
Postman - To test web-hooks before going live (Optional)
Cronjob - To set health-check and keep bot alive


⬜ Steps

Create Telegram Bot
  • Find BotFather and issue command /newbot
  • Provide bot name
  • Provide bot username - which should be unique and end with _bot
  • Once bot is created, you will get a message with token access key in it. Store the token access key.




Prepare Telegram Channel
  • Create new telegram channel
  • Add the bot @username_to_id_bot to it as admin and issue /start to find chat id
  • Store the chat id and dismiss @username_to_id_bot from channel
  • Find the bot created in previous step using bot username and add it to channel as admin




Setup replit
  • Create a free Replit account if you do not have it already.
  • Fork the repl - Tradingview-Telegram-Bot to your space and give a name of your choice.
  • Set environment variables - TOKEN and CHANNEL which are acquired from previous steps.
  • Run the REPL




Test with postman
  • Use the URL on repl and create web-hook post request URL by adding /webhook to it.
  • Create post request on postman and send it.
  • You can see that messages sent via postman appearing in your telegram channel.
  • append ?jsonRequest=true if you are using json output from alerts.




Json request example:


Set alerts from tradingview to web-hook
  • Use web-hook option and enter the webhook tested from postman in the web-hook URL




And that's all, the webhook for Telegram Alerts is ready!!

Thanks for watching. Hope you enjoyed the video and learned from it :)

PS: I have made use of extracts from the open github repo: github.com/fabston/TradingView-Webhook-Bot

Comment

Just realized that there is issue with hyperlink of repl I posted.

Just copy paste the URL instead of clicking on it. (Tradingview seems to be replacing @ with %2540:

"replit.com/@trendoscope/Tradingview-Telegram-Bot?v=1"

Comment

Please check the latest version with few more updates.

Comments
TradingView
Massive.
Trendoscope
@TradingView, That's a pleasant surprise. Thanks very much. :)
WicktatorFX
Brilliant!
Trendoscope
@WicktatorFX, Thanks very much for your support :)
MarxBabu
Very nicely done !
i remember those days ,i wrote 100 lines of python code to receive the the webhook alert using the local host .
Trendoscope
@MarxBabu, Thanks very much :)
Gaspesy_xxx
Dear,
Your post is amazing !! I could set it up easily. But when it comes to the integration of the chart's snapshot, I got a little problem with the authentication. My TV Account is linked to my Google account. Then the environment variables don't work. Is it possible to get a clue for the integration of google account authentication?
thank you and cheer up !! Really nice job, here !!
Trendoscope
@Gaspesy_xxx, Even with SSO, you can set password and use it right? I haven't explored if we can get SSO.

There was an article from another user about using pipedream(an integration product) to do the same. Need to explore there possibly.

I need some time to check the possibility of getting screenshots in different way - using session id. Will explore that and get back soon.
Gaspesy_xxx
@HeWhoMustNotBeNamed, I tried to get in but it always refuses to log in. Thus, I can’t use my indicators with the snapshot. If I use email button, it states that it is an google account and I should try signing in with the google button. If I try with the google button and enter the information, it refuses it. Security issue about the browser. I would like to try “twitter account” but now with the 2FA it’s a pain in the back too!!
I will check the pipedream ;) thank you and have a great day.
Trendoscope
@Gaspesy_xxx, you can goto your profile settings and set your password and login via username password.
More