Access Controller manual Download PDF

Chapter 04

Alerts (Telegram)

The panel can send a Telegram message to your staff the moment a door is forced (opened without a fob, exit button or remote unlock) or held open longer than the time you set on the door. The message arrives on the phones of whoever is in the chat within a couple of seconds of the door reporting it, so a propped fire door or a forced back door is noticed while somebody can still do something about it.

Each tenant (each gym, site or customer) has its own bot and its own destination chat, so one site never sees another site's alerts. Every alert is always written to the Log (chapter 11) whether or not Telegram is set up; Telegram is a second copy that reaches people who are not looking at the panel.

What is alerted

AlertRaised whenMessage looks like
Door forcedThe door position sensor sees the door open with no grant, exit-button press or remote unlock in the last few seconds (the relay pulse plus 10 seconds).DOOR FORCED: Anytown Gym: Front Entrance opened without a grant or exit press (controller esp32-3f9a1c)
Door held openThe door stays open longer than the Alert if held open for N seconds value on that door's page (chapter 3). 0 switches the alert off for that door.Anytown Gym: Front Entrance open for over 60s (controller esp32-3f9a1c)

Both need a door position sensor (reed switch or door contact) wired to the controller; without one the controller cannot tell that the door is open, and neither alert is ever raised. Chapter 5 covers the wiring.

Nothing else is sent to Telegram in the current release: denied scans, offline controllers, failed firmware updates and system events stay in the Log only.

You need two things, both from Telegram itself:

  1. A bot token: a long string that identifies your bot.
  2. A chat ID: the number of the chat, group or channel the bot should post into.

Both are pasted into Settings > Alerts (Telegram) in the panel. The whole job takes about five minutes and needs no technical knowledge; follow the parts below in order.

Part A: create the bot with @BotFather

  1. Open Telegram (phone or desktop) and, in the search box at the top, type BotFather. Pick the one with the blue verified tick and the name BotFather. Press Start if you see a Start button.
  2. Type /newbot and send it.
  3. BotFather asks for a name. This is the display name people will see, for example Anytown Gym Doors. Send it.
  4. BotFather asks for a username. It must end in bot and contain no spaces, for example anytowngym_doors_bot. If it says the username is taken, try another one. Send it.
  5. BotFather replies with a message that starts "Done! Congratulations on your new bot" and contains a line like:
Use this token to access the HTTP API:
123456789:AAH4kZ9yq2f_ExampleExampleExample

The part after "HTTP API:" (numbers, a colon, then letters) is the bot token. Tap it once in Telegram to copy it.

Warning: keep the token private. Anyone with the token can send messages as your bot. Do not paste it into group chats or tickets; if it leaks, send /revoke to BotFather for that bot and paste the new token into the panel.

You can get the token again at any time by sending /mybots to BotFather, choosing your bot, then API Token.

Part B: get the chat ID

Telegram does not show chat IDs anywhere in its normal screens, which is why this step trips people up. There are three ways, easiest first.

  1. Decide where alerts should go:
    • A private chat with one person: that person opens Telegram, searches for the bot's username (for example @anytowngym_doors_bot), opens it and presses Start, then sends any message, for example hello.
    • A group (several staff): create the group (or use an existing one), add the bot as a member (Group info > Add member > search for the bot's username), then send any message in the group, for example hello.
    • A channel (announcement style, nobody replies): open the channel's info > Administrators > Add administrator > search for the bot's username and add it. Then post one message in the channel.
  2. In the panel go to Settings, open the Alerts (Telegram) section, paste the bot token into Bot token and click Find my chat ID.
  3. A table headed Chats this bot can see appears listing every chat the bot has noticed, with its name, type (private, group, supergroup or channel) and ID, most recent first. Click Use this next to the right one. The chat ID is saved and the panel confirms with "Chat ID ... saved - tick Enable, then Send test message".
  4. If the panel says the bot has not seen any chats yet: send another message to the bot, or in the group or channel, wait a few seconds, and click Find my chat ID again. If it is a group, also read "Privacy mode" below.

Way 2: read it from the bot's update feed in a browser

  1. Send a message to the bot (or in the group or channel it is in) as above.
  2. In a web browser open this address, replacing TOKEN with your bot token (keep the word bot directly in front of the token, no space):
https://api.telegram.org/botTOKEN/getUpdates

For example https://api.telegram.org/bot123456789:AAH4kZ9yq2f_Example/getUpdates.

  1. You will see a block of text. Look for "chat":{"id": and the number right after it is the chat ID, for example:
"chat":{"id":987654321,"first_name":"Sam","type":"private"}

or, for a group:

"chat":{"id":-1001234567890,"title":"Front desk","type":"supergroup"}
  1. Copy that number (including the minus sign if there is one) into Chat ID in the panel.

If the page shows {"ok":true,"result":[]} the bot has not received anything yet: send a message and refresh the page.

Way 3: rules of thumb for groups and channels

Privacy mode: why a bot in a group may see nothing

By default a bot added to a group only sees messages that are commands (starting with /) or that mention it. That means Find my chat ID and getUpdates may show nothing even though you have been chatting in the group. Two fixes; either works:

Alternatively just type a command in the group, for example /start, which the bot always sees.

For sending alerts none of this matters: the bot can always post into a group it is a member of. Privacy mode only affects what it can read, which is only needed to discover the chat ID.

Part C: put it in the panel and test

Open Settings and expand the Alerts (Telegram) section (it shows a green on badge once alerts are enabled). Viewers cannot see Settings; admins and custom roles with the Settings permission can (chapter 12). A super admin sets it up per tenant after switching in.

FieldMeaning
Enable Telegram alertsThe master switch. Nothing is sent while it is unticked, whatever else is filled in.
Bot tokenThe token from Part A. Once saved, the field shows a green set badge and stays blank on purpose: the panel never shows the token again. Leave it blank to keep the stored token, or paste a new one to replace it. Until a token is saved the badge reads not set.
Forget the stored tokenAppears once a token is saved. Tick it and save to erase the token from the panel (for example when the bot is retired or the token was leaked).
Chat IDThe destination from Part B: a positive number for a private chat, negative for groups and channels.
Door forcedSend a message when a door is forced. On by default.
Door held openSend a message when a door is held open longer than its own held-open time. On by default.
Save alert settingsSaves everything above.
Find my chat IDSaves, then asks the bot which chats it has seen and lists them with a Use this button each (Part B, way 1).
Send test messageSaves, then posts "Test from Access Controller (your site name)" to the chat ID using the stored token.

All three buttons save what is typed first, so nothing you entered is lost when you click one of the helpers.

Step by step:

  1. Paste the bot token into Bot token.
  2. Put the chat ID in Chat ID, or use Find my chat ID and click Use this on the right row.
  3. Tick Enable Telegram alerts, and check that Door forced and Door held open are ticked as you want them (both are on by default).
  4. Click Send test message. Within a couple of seconds the message "Test from Access Controller (your site name)" should appear in the chat. The panel shows a green "Test message sent - check Telegram", or a red "Test message NOT sent:" followed by the reason (see the troubleshooting table below).
  5. Click Save alert settings.

Then open Doors, click each door that has a door sensor, and set Alert if held open for N seconds to suit that door (chapter 3). The default is 60; 0 switches the held-open alert off for that door. The value is sent to the door's controller automatically within seconds.

Tip: test the real thing once, not just the test button. Open a sensor-equipped door with the exit button and hold it past its held-open time; the Door held open message should arrive and the Log should show the same alert. Then open it from outside without a fob (with the relay pulse long finished) to see Door forced.

Cooldown and what is logged

The panel host needs outbound HTTPS to api.telegram.org (chapter 16). Controllers do not talk to Telegram; only the panel does.

Troubleshooting

The exact message shown in red after Send test message or Find my chat ID is the best thing to pass on to whoever supports your panel. The common ones:

What you seeWhat it meansWhat to do
401 Unauthorized / "rejected the bot token"The token is wrong, has a typo, or was revoked.Send /mybots to BotFather, pick the bot, API Token, copy it fresh and paste it again. Make sure there are no spaces at either end.
404 Not Found / "could not find that bot"The token is incomplete (usually cut off when copying).Copy the whole token, including the numbers before the colon.
400 chat not foundThe chat ID is wrong, or the bot has never been in that chat.Run Find my chat ID and pick from the list. For groups, check the bot is still a member; for channels, that it is an administrator. Remember the minus sign.
"bot was blocked by the user"The person blocked or never started the bot.That person opens the bot in Telegram and presses Start (or unblocks it).
"bot was kicked from the group"Someone removed the bot.Add it back to the group.
"not enough rights" / "no permission to post there"The bot is in a channel but not an administrator.Channel info > Administrators > add the bot.
"webhook is active" / getUpdates shows nothing even after messagingSomeone set a webhook on this bot (a different integration). Telegram then refuses getUpdates.Open https://api.telegram.org/botTOKEN/deleteWebhook once in a browser (replace TOKEN), then try Find my chat ID again. Sending alerts works regardless.
Find my chat ID finds nothing for a groupPrivacy mode: the bot cannot read normal group messages.See "Privacy mode" above: make the bot an admin or turn privacy off, or type /start in the group.
"Saved, but no bot token is set" / "no chat ID is set"You pressed a helper button before filling the field it needs.Paste the token first for Find my chat ID; both token and chat ID for Send test message.
"That chat ID does not look right"The value is not a whole number.Chat IDs are digits only, with an optional leading minus sign.
Test works but real alerts never arriveAlerts are not enabled, or the type is unticked, or the door has no sensor, or its held-open time is 0.Check the Enable tick box and the two alert tick boxes, then the door's held-open time and the controller's door sensor wiring. Look at the Log: if Door held open or Door forced rows are there, the panel saw the alert and the problem is on the Telegram side; check the panel's server log for "telegram send failed".
"could not reach Telegram"The panel's server cannot reach the internet (firewall, proxy, DNS).Allow outbound HTTPS from the panel host to api.telegram.org.
Alerts arrive once and then stop for a minuteNormal: repeats for the same door and type are rate-limited to one per minute.Nothing to do.
Alerts stopped after the group was reorganisedThe group became a supergroup and its ID changed.Run Find my chat ID again and pick the new ID.