# Send alerts to Telegram

Get downtime alerts in a Telegram group. Create a bot with BotFather, find your group's chat ID, and connect both to StatusCheck.

Connect a Telegram group or chat to get a message there when a monitor goes down, when it recovers, and when you post a status update. Messages come from a bot you create, and nobody in the group needs a StatusCheck seat.

Telegram is available on every plan. A workspace has one Telegram connection, which posts to one chat.

StatusCheck needs two values from Telegram:

- a **bot token**, the password for a bot account that you create in Telegram;
- a **chat ID**, the number Telegram uses for your group. The app does not show it, so the steps below show you how to find it.

**Before you start**

- You need the **Owner**, **Admin** or **Editor** role in the StatusCheck workspace.
- You need permission to add members to the Telegram group.
- Create the group first, or use an existing one.
- Use a computer for the steps that open a web address. Telegram itself can be on your phone or computer.

## Create a bot and copy its token

1. In Telegram, search for `@BotFather` and open the chat. Choose the account with the blue verified check mark; other accounts with similar names are not official.

2. Send `/newbot`.

3. Send a display name when BotFather asks for one, for example `Acme Status`.

4. Send a username that ends in `bot` when BotFather asks for one, for example `acme_status_bot`. If it is taken, try another.

5. Copy the bot's token from BotFather's reply. It looks like `123456789:AAH...`.

Keep the token private: anyone with it can control the bot.

## Add the bot to the group and find the chat ID

Group chat IDs are negative numbers, for example `-1001234567890`.

1. Open the group and select its name at the top.

2. Select **Add members** (on some devices, **Add**).

3. Search for the bot by its username, for example `acme_status_bot`, and add it.

4. In the group, send a command addressed to the bot, for example `/start@acme_status_bot`. Bots in groups only see commands and messages addressed to them, so a plain message may not show up in the next step.

5. On a computer, open the following address in a web browser, with your token in place of `<token>`. Keep the word `bot` directly in front of the token, with no space.

   ```txt
   https://api.telegram.org/bot<token>/getUpdates
   ```

   The page shows plain text in JSON, a format apps use to exchange data. You only need one number from it.

6. Find the word `"chat"` in the text (use your browser's find command, Ctrl+F or Cmd+F). Copy the `id` that follows it, including the minus sign:

   ```json
   "chat": { "id": -1001234567890, "title": "Production alerts", "type": "supergroup" }
   ```

   Check that the `title` is your group's name.

If the page does not show what you expect:

- `{"ok":true,"result":[]}` means Telegram has nothing new for the bot yet. Send the command in the group again and reload the page.
- `{"ok":false,"error_code":404,"description":"Not Found"}` means the address has a typo. Check that you copied the whole token, with `bot` directly in front of it.
- `{"ok":false,"error_code":401,"description":"Unauthorized"}` means the token is no longer valid. Get the current token from BotFather with `/token`.

To send alerts to yourself instead of a group, open a private chat with the bot, send it any message, and use the `chat` `id` from that update. A private chat ID is a positive number.

## Connect the chat in StatusCheck

1. In StatusCheck, open **Integrations** in the sidebar and choose **Telegram**.

   ![The Telegram integration page in StatusCheck, with three setup steps, the Bot token and Chat ID fields and the Connect button, and a Details card showing All plans.](https://www.statuscheck.io/_astro/integration-telegram.CFvwU1hD.png)

2. Paste the token into **Bot token**.

3. Enter the ID into **Chat ID**, including the minus sign for a group.

4. Select **Connect**. The status reads **Connected**.

5. Select **Send test alert**. A test message from your bot appears in the Telegram chat within a few seconds. If it does not, see [Troubleshooting](#troubleshooting).

StatusCheck encrypts the token and does not show it again. To post to a different chat, select **Disconnect** and connect again with the new chat ID.

## Choose which events the chat receives

A new connection receives all three events. To change that, open the integration's page in StatusCheck, clear the events you do not want under **Events**, and select **Save events**.

| Event | When it is sent |
| --- | --- |
| **Monitor down** | A failure has been confirmed from a second location and an incident has opened. Reminders follow if the monitor's **Resend while down** is set. |
| **Monitor recovered** | The recovery has been confirmed. Includes the outage duration. |
| **Status updates** | Someone posts an update to a status page, including the one that resolves it. |

## Send a monitor's alerts to the chat

Connecting Telegram does not change any monitor. A monitor's alerts go only to the channels you select on it.

1. In StatusCheck, open **Monitors** in the sidebar and select the monitor.

2. Open the **Notifications** tab.

3. Under **Channels**, select the Telegram connection.

4. Select **Save changes**. The monitor's next down alert goes to the chat.

Status updates go to the connection whenever **Status updates** is selected, whatever monitors it is attached to.

## What the Telegram message contains

- A bold title that names the monitor and what happened.
- One line each for the location that detected the failure, the status code (the number your server answered with, such as `503`) and failure reason, when it started, and for a recovery when it ended and how long it lasted.
- The monitor's URL, if **Show URL in notifications** is on for that monitor.
- A **View incident** link that opens the incident in StatusCheck.

Times are in UTC.

## Troubleshooting

**StatusCheck rejects the bot token.** Copy the whole token from BotFather: digits, a colon, then at least 30 letters, digits, dashes or underscores. Leave out the word `bot` you used in the `getUpdates` address.

**The test fails with "chat not found".** The chat ID is wrong or the bot is not a member of the group. Check that you kept the minus sign, and that the bot is still in the group.

**Alerts stopped after the group was upgraded.** When Telegram turns a group into a supergroup, the chat ID changes to a new number starting with `-100`. Find the new ID with `getUpdates`, then disconnect and connect again.

**The test fails with an unauthorized error.** The token is no longer valid, usually because someone revoked it in BotFather. Get the current token from BotFather with `/token`, then disconnect and connect again.

## Related

- [How alerts work](/docs/alerts/) explains delays, reminders and muting.
- [Respond to an incident](/docs/incidents/) covers acknowledging and resolving.
- [Post a status update](/docs/status-pages/status-updates/) explains the updates this chat can receive.
- [Slack](/docs/alerts/slack/), [Microsoft Teams](/docs/alerts/microsoft-teams/), [Discord](/docs/alerts/discord/) and [Google Chat](/docs/alerts/google-chat/) connect the same way. [Webhooks](/docs/alerts/webhooks/) reach any other tool.
