sahilrajput.com

Exercise 11.18 Alternative version for Telegram

The Telegram version of this exercise is provided by Sahil Rajput

NB: In case you end up having a lot of workflows running simultaneously (when you push a commit) in your github actions tab, you can disable all workflows except the one you are currently working on, as shown in the figure.

Any bot needs a chat id to send any sort of message to a user, group or channel. In telegram, chat id is a unique identifier for any user/group/channel and our bot will use it to send message to the group we just created. Since we added our bot to the group, the backend api of telegram has recorded the event for it and we can see that event’s details to fetch the chat id of our group.

To fetch the chat id of the group we can use either of below ways:

11.18: Deliver worflow report messsage directly to user/client’s telegram account:

Add another step to your job in existing TelegramNotifcation.yml workflow file to deliver message directly to yourself by using chat id associated with your own account. To do this add another secret say TELEGRAM_TO_ME to your github repo settings. Probably doing this exercise, you would see an error which would break your workflow saying chat not found, this is a security concern made by telegram, so you would first need to send a message to bot first and instantly after that your new workflow events will succeed. This security concern ensures that any chatbot might not end up sending spams to any unauthorized user otherwise any hacker could easily spam you in a variety of way using his/her bot.

Tip: You can get the chat id of your personal telegram account by sending a “Hello” message to @userinfobot simply. You can also use @userinfobot link to message the bot directly from mobile or using web version of telegram on your desktop to send the “Hello” message.