Before this, I had never built a notification system. I just had a PC, a free Telegram bot, and a simple problem: alarms were firing on the plant floor, and by the time someone noticed on a dashboard, the downtime clock had already been running for minutes.
So I asked myself a dumb question: what if the alarm just... texted someone?
Turns out, it's a lot easier than it sounds.
Let me set the scene
Industrial alarms are usually built to be seen, not heard. A light turns red on an HMI. A tag flips in a SCADA system. If nobody's staring at that screen at that exact moment, the alarm just sits there, quietly costing minutes.
Meanwhile, everyone on a maintenance team already has a phone in their pocket.
So instead of building (or paying for) a bigger dashboard, I built something dumber and faster: a Python script that watches tag states and pings a Telegram group the second something goes wrong — and logs everything so there's a report waiting at the end of the shift, no manual tally required.
No database server. No new dashboard software. No licenses.
How it's wired together
[ PLC / data source ]
|
| tag values
|
[ Python script — polling loop ]
|
├── detects state change (off → on, on → off)
|
├── sends message ──► [ Telegram group ]
|
└── logs event ──► [ alarms_YYYY-MM-DD.json ]
|
└── end of shift ──► [ Shift report: top 5 + downtime ]
Step 1 — Get the bot talking
Telegram bots are free and take two minutes to set up via @botfather. Once you have a token, sending a message is one HTTP call:
That's the entire notification layer. One function, reused for every alert.
Step 2 — Don't alert on values, alert on changes
My first instinct was to just check "is this tag true?" every second and fire a message. Bad idea — that spams the same alarm every second while it's active.
The fix: track the previous state, and only fire when it changes.
Output (in the Telegram chat):
🔴 ALARM: Tank1_Level triggered
🟢 CLEARED: Tank1_Level back to normal
Two lines of chat, zero minutes of someone staring at a screen to catch it.
Step 3 — Log everything, automatically
Every trigger and clear event gets appended to a JSON file for the day. No database setup, no schema — just a growing list of events with timestamps.
Step 4 — The part that actually saves time: the shift report
This is where it clicked for me. By shift end, that JSON file already has everything needed to answer the question every supervisor asks: "what actually happened today?"
Output:
No spreadsheet. No handover notes scribbled on paper. Just python report.py at the end of the shift.
Why this actually matters
This isn't a groundbreaking piece of engineering — that's the point. The value isn't in complexity, it's in closing three gaps that most plants quietly live with:
- Detection lag: alarms sitting unnoticed on a dashboard
Notification friction: nobody wants another app, but everybody already has Telegram/WhatsApp on their phone
Reporting overhead: someone manually reconstructing "what broke today" from memory at shift change
Three Python functions, one free API, and a JSON file closed all three.
Where to go from here
If you want to build something similar:
- Start read-only. Just alert and log — don't touch write commands until you fully trust the polling logic.
- Batch alerts if things get noisy. If ten tags fire in the same second, group them into one message instead of flooding the chat.
- Outgrowing JSON? Swap the file for SQLite — same logic, just a different storage layer.
- Add more context to alerts. A tag name is fine, but a tag name + last known good value + how long it's been active is a lot more useful at 3 AM.
You don't need a SCADA overhaul to get real-time visibility. Sometimes it's just a bot, a loop, and a JSON file.
Built something similar with Slack, WhatsApp, or email instead of Telegram? I'd love to compare notes — drop a comment below.






Top comments (0)