Telegram alerts

Sartar can post its alerts in Telegram: in a private conversation with you, in a group, or in a channel. The messages are sent by a bot that you create and that belongs to you. Sartar only needs two values from you: the bot's token, and the id of the chat it posts in. It takes about ten minutes the first time.

You need a Telegram account. If you do not have one, install the Telegram app on your phone and sign up with your phone number. Telegram Desktop (desktop.telegram.org) works too, once linked to the phone.

1. Create the bot

  1. In Telegram, open a conversation with @BotFather. It is Telegram's official bot, with a blue check mark; beware of look-alikes.
  2. Send /newbot.
  3. Give the bot a display name, for example Sartar alerts.
  4. Give it a username. It must be unique on Telegram and end with bot, for example acme_sartar_bot.
  5. BotFather answers with a link to your bot, t.me/acme_sartar_bot, and with the token, which looks like 123456789:AAHk3vOq2-ZzTSq….

The token is a secret: whoever holds it can post as your bot. Keep it out of tickets and chat messages. If it leaks, send /revoke to BotFather to get a new one, then update the channel in Sartar.

2. Let the bot reach you

A bot can never write first. Choose where the alerts go.

A private conversation, for you alone, and the simplest to test with:

  1. In the BotFather conversation, tap the link t.me/acme_sartar_bot. A new bot does not always show up in Telegram's search for a while; the link always works.
  2. Tap START at the bottom of the screen.
  3. Send it any message, for example hello. The bot does not answer: that is expected.

A group, for a team:

  1. Create a group (on Android the pencil button, then New group; on an iPhone the new-message icon in Chats, then New group; on a computer the ☰ menu, then New group), and add the bot to it like any member, along with your colleagues.
  2. In the group, send /start@acme_sartar_bot, with your bot's username. By default a bot only sees the commands addressed to it in a group; this one makes the group visible in step 3.

If Telegram refuses to add the bot to a group, send /setjoingroups to BotFather, choose your bot, then Enable.

A channel: add the bot as an administrator of the channel, with the right to post messages, then publish a message in the channel. For a public channel, you can skip step 3: its @username is its id.

3. Find the chat id

Open this address in a browser, with your token in place of <TOKEN>:

https://api.telegram.org/bot<TOKEN>/getUpdates

Look for "chat":{"id": in the answer. The number that follows is the chat id:

"chat":{"id":123456789,"first_name":"Ada","type":"private"}

If the answer is {"ok":true,"result":[]}, the bot has not seen any message yet: send one again (step 2) and reload the page. Telegram keeps these messages for 24 hours only.

Do not confuse it with the id that getMe returns: that one is the bot's own id, not a chat.

4. Create the channel in Sartar

  1. Open Notification channels and click New Channel.
  2. Choose Telegram.
  3. Fill in a Notification name, the Bot token and the Chat id.
  4. Click Test: a test message must arrive in the chat.
  5. Click Save.

The channel can then be chosen as the notification of a monitor, a folder, a scenario or the whole account, as an escalation target, or as a member of a notification list. The messages are written by Sartar, in your account's language: the monitor's name in bold, its url as a link, the cause of the failure.

With the CLI:

sartar channel create --name "Telegram ops" --type telegram \
  --set bot_token=123456789:AAHk3vOq2-ZzTSq... --set chat_id=-1001234567890

With Terraform, type = "telegram" and config = { bot_token, chat_id } on a sartar_notification_channel.

When it does not work

The test, and the notification failures shown on the channel, repeat the reason Telegram gave:

Message Cause
401: Unauthorized the token is wrong, or was revoked
400: Bad Request: chat not found the chat id is wrong, or the bot is not in that chat
403: Forbidden: bot was kicked … / bot is not a member … the bot was removed from the group or the channel
403: Forbidden: bot can't initiate conversation with a user in a private conversation, nobody tapped START
400: Bad Request: group chat was upgraded to a supergroup chat see below

When a group becomes a supergroup, which Telegram does by itself, for instance when some options are turned on, its id changes to a number starting with -100. Read the new id with getUpdates and update the channel.