Changes:
- Escape characters
-
=>\-
https://core.telegram.org/bots/api#markdownv2-style
This is a Checkmk plugin to send notifications via Telegram.
The initial version of this plugin was posted in 2016 on my blog: Monitoring Notifications via Telegram
The latest version can always be found under Releases.
The plugin is also available at Checkmk Exchange but it may take some time to see new releases.
Sending messages via a Telegram bot requires two pieces of information:
- The
token
of a Telegram Bot to send messages with - The
chat id
for any user to send notifications to
The instructions for talking to
BotFather (the Telegram bot used
to create a new bot) should be straightforward to follow. The resulting token
will be needed for all following steps.
To send messages to a Telegram user, one needs to know the internal chat id
for the chat/conversation between the user and the bot.
To find out the chat id
, open a private conversation with the bot and send
at least one message. Afterwards query the list of incoming messages via the
getUpdates
function of the Telegram Bot API by fetching
https://api.telegram.org/botTOKEN/getUpdates
(replacing TOKEN
with the
actual bot token).
For example using curl
and jq
(opening the URL in a web browser will work
as well):
curl --silent "https://api.telegram.org/bot${TOKEN}/getUpdates" | jq '.result[].message.chat'
Output:
"chat": {
"id": 144553322,
"first_name": "Stefan",
"type": "private"
}
In the above example the chat id
would be 144553322
.
With both the bot token
as well as the chat id
being known one can now
create a notification rule in Checkmk.