As a developer I always need as complete logs as I can get for the current version of my software. But the logs are another topic, probably I will talk about once in a future, for now I want to concentrate on some specific kinds of logs: critical points notifications. Before all the major messengers got the ability to create and use bots — the most obvious decision to notify yourself or your team was to send an email. The drawbacks were a messy interface, slow search, not available until you open your mail client. Telegram is one of the most advanced messengers nowadays with nice and simple bot API with which you can do a lot of things like automating tasks or manage simple ones. The bot is: NOTHING, just a registered bot and that’s all, without even single line of code in it. Why? Because the main purpose of the bot will be to show some critical log parts in private chat and that’s all, it will just FORWARD them to proper chats.
So the algorithm will be:
- Create the bot
- Open chat/group chat(add the bot to the chat, this case is better when you have several developers to get the messages simultaneously) with the newly created bot
- Write something in that chat (this is needed to properly find the chat ID in the next step)
- https://api.telegram.org/botXXXXTOKEN/getUpdates — get updates to get chat ID
- Send message (with some proper #-tag for even faster search) via bot to the proper chat ID. For this sender you will need some service that can get requests and forward them to the bot.
And that’s all, you get the messages on all the devices with ability to fast search and grouping. Also, in case you have some other bots prepared, you can forward the log to other bot for analysis, for example to recheck some specific details ;)
Tips on creating bots