Telegram notifications

D2HA can send a Telegram message when a new version is out, when a container stops with an error and when it becomes unhealthy.

Set it up

  1. Create a bot with @BotFather and copy its token.
  2. Send your bot a message, then read your chat id, for example with @userinfobot. For a group, add the bot to it and use the id of the group.
  3. Give both to D2HA and restart it:
    environment:
      D2HA_TELEGRAM_TOKEN: "123456:ABC..."
      D2HA_TELEGRAM_CHAT_ID: "123456789"
  4. In Settings โ†’ Telegram notifications, choose what you want to receive and the language, then press Send a test message.

For several chats, separate the ids with commas. Keep the token in an .env file rather than in the compose file.

The messages

MessageWhen
๐Ÿ†• Updates availableA check finds a new version of an image you run. Once per version, with all the new updates of that check in one message, the release-notes link and a warning for breaking changes.
๐Ÿšจ Stopped with an errorA container exits with a code other than 0 and 143 (the normal stops). When it ran out of memory, the message says so.
โš ๏ธ UnhealthyThe health check of a container fails.

What does not send a message:

  • a stop you asked for: docker stop, docker kill, docker rm -f, docker compose down;
  • the old container during an update by D2HA;
  • the same alert for the same container within 15 minutes, so a crash loop does not flood the chat.

If Telegram cannot be reached, the update message is sent again at the next check.

Leave a container out

A container with the label d2ha.notify=false never sends crash or unhealthy alerts: for example a job that is expected to fail. Its updates are still announced.

services:
  nightly-job:
    image: example/job:latest
    labels:
      d2ha.notify: "false"

Crash and health alerts need Docker events

D2HA learns about stopped and unhealthy containers from the Docker events. With the socket proxy, keep EVENTS: 1, as in the example compose. If the stream drops, D2HA reconnects and asks for what happened meanwhile.

Language

Messages are in English or Italian: Settings โ†’ Telegram notifications โ†’ Language of the messages. Without a choice they are in English.

Something wrong or missing on this page? Open an issue.