Imagine administering a Telegram chat with 40,000 members. At that scale, a chat becomes a living organism pulsing with its own rhythm: morning bursts of activity, waves of new joins after every mention in another chat, background noise of reposts and reactions. Somewhere in that bloodstream, spammers and ad bots are hiding – and every now and then a coordinated raid rolls in, one you don’t always see coming.
Against all that, your arsenal comes down to this: a dictionary filter, a handful of static rules, and a few moderators who were never going to read it all. And that is enough, for a while. Your chat grows, the rules get patched and re-patched – and the system holds together. The moderators have seen it all before and can keep up. Until they can’t.
Then something goes wrong. The dictionary starts flagging news reposts as spam, since both contain links. Static rules treat a two-year veteran the same as an account registered yesterday morning. During a serious raid, one of your moderators receives a couple hundred messages in the first three minutes – and simply cannot cope. What worked for a thousand members starts cracking at forty thousand – not because it was broken, it simply was never built for this.
The issue runs deeper than that: a dictionary filter is a database of what has already happened. A spammer reads the results – what got through, what got banned, and within a few days knows your rules better than you do. A content filter is a dead end by design, and the attacker always has a head start.
I’ll walk you through a three-layer architecture built to answer exactly that – what signals reliably catch bad actors, why member reputation beats any dictionary, and where automation hits its hard limit.
## Why legacy moderation fails
A dictionary filter is, in essence, a database of the past.
You add a word, a phrase, a pattern – everything you’ve seen in real attacks. The system remembers and blocks on triggers. While the threat stays stable, it works. But threats are never stable for long: spammers iterate fast, and what was a reliable trigger yesterday catches nothing useful tomorrow – they simply reworded it, or slipped a space into the middle of a word.
Static rules work differently, but hit the wall too. A rule has no idea who it's dealing with: a trusted veteran or an account created three hours ago just for a raid. Both get an identical response from the system – and that's the fundamental flaw, because member context often matters more than the message itself. A link from someone who's been active in the chat for six months and a link from a silent account with no message history are not the same thing, even if the content is identical.
Manual moderation patches some of these gaps – but only up to a point. A moderator reads context and picks up the tone; when things are quiet, this works well. A raid tells a different story: in the first few minutes, messages arrive faster than any one person can process them. By the time the moderator reacts, the wave has already passed.
These are all symptoms of one problem: traditional moderation is always one step behind by design. At a small scale, that delay is invisible. At a large scale – it becomes a vulnerability.
This is where moderation ends and community operations begin. You run the chat as a managed system, with metrics and policy automation.
**
Threat model
**
Before you can design a defense, you need to know what you are defending against.
The word “spam“ covers an entire zoo of threats – each with its own signature, its own tempo, its own goal. A defense built for one type is often useless against the other, and that is exactly a place for universal solutions to fall apart.
Let’s start with the most visible.
Raids
A raid is a coordinated incursion: dozens of accounts join the chat in a short window and flood it with messages almost simultaneously. The danger lies in the dynamics – many sources hitting a narrow window in near-synchrony. In essence, it is a DDoS against live moderators, and the exhaustible resource is their attention.
While a dictionary filter falls short – not because of volume: it will trigger on a banned word across a million messages just fine. The catch is different: a well-executed raid usually comes as clean text – copy-paste or a wall of emoji, simply nothing to match against. And when raiders do use actual banned content and every message gets dutifully deleted, the dictionary loses in a different way: it sees a thousand separate events, one by one, and has no idea this is a single massive attack. It has no memory of forty fresh accounts doing one thing at once within ninety seconds. So it is always one step behind the wave – and rising to the level of the only useful decision – to lock the chat temporarily and throttle the influx of new members entirely. It is simply beyond its design.
*Link flooding *
Looks simple: an account with no message history joins and starts dropping links. Seems like an ideal target for a straightforward rule – “new account plus link equals restriction.“ This is the first trap. Regular people post links too: someone reposts a news story, someone drops a GitHub link in answer to a question. If the chat is at all tied to a news agenda, a rule this crude will start restricting real people in batches. At this point, the sender's context becomes more important than the link itself – but that's a topic for the next section.
*Sleeper accounts
*
A far more patient threat.
An account joins in advance, texts nothing, makes no noise, and sits quietly in the member list for weeks. It activates later – during a coordinated attack, or after being resold to someone who needs a “warmed-up“ account with age and a plausible join history. In its dormant state, such an account looks identical to an ordinary lurker – and lurkers make up the majority in any large chat. The only clue is the absence of activity: zero messages, zero participation – and then a sudden burst of activity when someone flips the switch.
_*Human-like spam
*_Messages written to pass as normal human speech. No trigger words at all – just a solid, coherent reply in the flow of conversation. Not long ago this required a real person and effort; today, text of this quality is generated by AI in seconds, practically for free. While the dictionary approach surrenders completely – there is nothing to grab onto, not a single marker that could be added to a list. The only source of information left is the account's behavior – the speed of writing, and the history behind it. By this point, the text alone tells you nothing.
_*Stories spam
*_And finally – a threat that did not exist a couple of years ago.
Telegram rolled out Stories, and spammers immediately recognized a blind spot:does not expose Stories to moderation bots the way it exposes regular messages. Which means an automated moderator physically cannot see a portion of the content that all live members see perfectly well. A spammer publishes via Stories and walks past every layer of defense, because from the bot's perspective the message simply does not exist. This is a platform-level gap, and it cannot be closed on the bot's side. To be upfront: at the time of writing this is unsolved, and we will return to it when we get to Telegram's limitations.
All five threats share one trait: the content of the message settles almost nothing. What matters is behavior – how fast an account moves, and the history behind it. A dictionary loses before it even starts: it parses text when what needs to be examined is the action.
**
Which signals actually work
**
If message content settles nothing, behavior is what remains. The question is which behavioral signals actually carry information – and which merely look smart. The difference between those two categories is the difference between a system that catches spam and one that bans ordinary people.
Send rate is a baseline signal.
A human physically cannot produce ten messages in five seconds – for a bot that is a warm-up. But rate has a well-known drawback: lag. Telegram delivers messages unevenly; under server load, a batch of messages from a real person can arrive all at once – and from the system’s perspective that’s a bot. The signal is good, but it cannot be trusted alone.
Link count has the same mechanism.
An informative signal: spam almost always contains a link, because without one there is no conversion. But news reposts generate links in batches, and a chat built around a news agenda looks like a spam farm by this criterion. Again: useful, but not enough on its own.
Pattern repetition.
The same text from different accounts, repeated actions at identical intervals – this is the signature of automation that does not appear in human behavior. Human behavior is noisy; machine behavior is regular. That regularity is what gives it away.
**
Member history.**
The most underrated signal. An account with six months of activity and an account created yesterday are two different objects, even if they sent the identical message. History provides context that the moment alone cannot: how the person normally texts, which threads they show up in. A sharp deviation from one's own pattern is a warning sign even for an old account – it may have been hijacked.
Now the key point. Each of these signals says little on its own. Rate catches lag, links catch news people, and spammers have long learned to randomize patterns. That is why modern anti-spam does not pick one signal – it weighs a combination. This is where the AI score comes into play: a model trained on real spam evaluates the message and the account's behavior as a whole and outputs a probability. In ChatKeeper's practice this turned out to be the most useful layer – it picks up what slips through every rule, including human-like spam, dictionaries here don't work at all.
What did not make it into the system is also significant. Time to the first message after joining – seems logical (“normal people read first“); in practice it's too noisy: plenty of real people post immediately. Invite chains – a neat theory about the invitation graph; in practice the signal proved unreliable. This is a normal engineering process: hypothesis, test, discard. The signal set evolves just like the rules do: constantly rebuilt to match the actual attack picture.
Good anti-spam knows exactly where each of its signals lies.
**
Architecture: three layers
**
Signals on their own do nothing. Between “the system noticed an anomaly“ and “the spammer got banned“ lies the entire real architecture – and the boundary between a filter bot and a community management system runs there.
There are three layers: the rules engine, the behavioral layer, and the retention layer.
Layer one – the rules engine, policy automation.
A conventional anti-spam bot is a set of toggle switches: “delete links,“ “ban for language,“ “CAPTCHA for newcomers.“ The rules engine works differently: an administrator assembles policy from primitives – event, condition, action, exception, priority. Each primitive is boring; the combinations are anything but. A rule can look at the sender's history, check time windows, hold state across events, and launch action chains with escalation.
Three examples follow. Fair warning: these rules are illustrative. Real configurations of production systems are not published – by the end of the article it will be clear why this is a deliberate security policy.
_
Rule number one – “Links from new users“_
If a user sends a message with a link, has fewer than 5 messages in history, and has been in the chat less than 48 hours – the message is deleted and media is restricted for 24 hours. The rule does not fire for domains on the whitelist or for members with a reputation rating above threshold.
Rule number two – “Violation escalation“
If the AI score exceeds the spam threshold, the system checks the sender's violation count over the past 7 days. First violation – message deleted. Second – 24-hour mute. Third – ban. For members with a high reputation rating, the ladder shifts one step lighter.
Rule number three – “Raid defense“
If 15 or more users join within 2 minutes and the share of new accounts among active senders exceeds threshold – slow mode (a built-in Telegram feature that limits message frequency) kicks in, new members get a CAPTCHA, and admins receive an alert. This rule carries the highest priority and overrides all message-level rules.
The three rules operate at fundamentally different scales. The first looks at a message; the second tracks a member's state over time; the third operates on the chat as a whole. A set of toggle switches cannot do any of this: a toggle has no memory of yesterday and no view of the chat as a single entity.
Layer two – the behavioral layer, behavioral anti-spam.
The engine executes decisions; the behavioral layer makes them. Signals from the previous section flow into a composite score, and here the mechanism that proved to be the main defense against false positives kicks in – the member's reputation rating.
Every action in the chat moves the reputation: activity and normal communication push it up, violations push it down. When a rule fires on someone with a long positive history, the system reads their rating and picks a lighter response – accumulated trust buys out a single lapse. A fresh account with no history has no such cushion and runs the full escalation ladder from the harshest end.
Rating transforms the binary question “spam or not spam“ into an economic one: how much trust has the member accumulated, and what mistake can that trust cover?
The escalation ladder always runs from soft to hard: message deletion, capability restriction, mute, ban. Going straight to a hard measure is almost always a design error – the cost of a false positive on a long-standing member is higher than the cost of a missed spam message.
Layer three – retention analytics.
The youngest layer, and the only one I will speak about carefully. Here’s the thing: moderation is hygiene – it removes reasons to leave, but it does not drive growth on its own. The data a moderation system already collects – who is active, who goes quiet, how tone shifts after incidents – is a ready-made foundation for community health. This layer is built precisely for that: member segmentation, activity dynamics, audience response to events. I have no measured data on churn impact and I will not invent figures – I will note only that architecturally moderation and retention feed on the shared data set, and splitting them into two independent products means collecting the unchanged telemetry twice.
**
The quiet compromises
**
On paper, the three-layer architecture looks complete. In reality it operates in an environment that actively resists it – and that changes everything.
First, the core of it.
Anti-spam rules go stale. A spammer who hits a wall does not walk away, but probes: they adjust wording, shift timing, try new entry points, and watch what gets through. Every rule that fires simultaneously teaches the attacker where the boundary is. After a while they go around it, engineers adjust the threshold, spammers adapt again – and the cycle repeats. In ChatKeeper's practice this is exactly how it plays out: rules tighten then loosen, because yesterday's setting today either lets a wave through or starts snagging real people. This is the normal operating mode of a system in an adversarial environment, not an emergency. Accuracy here is a process with no final version.
This gives rise to a decision that runs counter to all the current fashion for explainable AI. When the system restricts a member, the admin sees one fact in the log: spammer removed. The reason the rule fired – which rule, with what weight – the system does not show. Deliberately. The admin reads – and so does the spammer; the difference is that the spammer reads more carefully: every explanation is a ready-made instruction on what exactly to change next time.
> Every explanation the system surfaces is a labeled training example for the attacker. Banking anti-fraud systems reached the same conclusion long ago: a transaction is declined without stating a reason, and this frustrates honest customers, but the alternative is worse – a fraudster told why they were declined returns an hour later with a corrected scheme. This decision has a price worth naming: it is harder for an admin to trust a system they cannot inspect, and debugging false positives means going back to the developers instead of figuring it out yourself.
This is a conscious tradeoff – a little admin trust in exchange for slowing down attacker adaptation. The same reasoning, incidentally, explains why the rules in this article are illustrative: real production configurations are the last line of defense.
Then there is the ceiling nobody chose. Telegram's Bot API does not give bots the full picture. Deleted messages vanish without a trace: if the evidence is gone before the system looks at it, there is nothing to investigate. And since the summer of 2023, the platform has had Stories – which for moderation bots simply do not exist. Live members see the content; automation does not. Spammers found this hole quickly and are exploiting it right now: publishing via Stories passes all three layers, because not a single event reaches the system. I promised to return to this from the threat section – I return with bad news: on the bot's side this hole cannot be closed. This is a platform limitation, and the only honest thing to do is name it out loud. There is no all-seeing eye in Telegram – well, perhaps except its founder Pavel Durov himself.
And the final boundary is human.
Automation handles the bulk cases: standard spam, raids, clear violations – everything that repeats and can be formalized. The tail of ambiguous situations stays with people: conflicts between long-standing members, sarcasm on the edge, a complaint about an unfair ban. Plus the arms race itself eats engineering time continuously – rules are not “set and forget,“ someone has to keep tuning them, and that someone is always a human. The system cuts the human workload dramatically, but zero is not reachable here – and promising otherwise would be a lie.
**
How it works in production
**
Everything described above is not a concept. This article is built on the practice of ChatKeeper, a Telegram community management system – and it is worth showing what the principles from the previous sections look like in a working system.
The rules engine – with whitelists, priorities, and escalation – is available to admins as a no-code constructor. The behavioral layer maintains a reputation rating for every member and uses a neural network score as its primary detector: this is what catches human-like spam, where dictionary-based approaches fail entirely. Responses follow the escalation ladder from deletion to ban, and every system decision lands in the chat log – the fact, without the reason: we covered why in the previous section.
Straight to the numbers – and first, the frame in which to read them. The team does not publish precision and recall as benchmarks, and this is a principled position: formal measurement in an adversarial environment is nearly impossible – the boundary between spam and not-spam shifts with every attack, and manual labeling goes stale faster than it can accumulate. What exists are the team's operational estimates from the live system. Around 80% of spam is detected automatically, and the team openly acknowledges that the remaining portion covers types of spam not yet caught – including the Stories blind spot discussed above. Around 70% of spam waves are suppressed on the first message. Full suppression time ranges from seconds on known patterns to an hour on new types the system is seeing for the first time. By the team's estimate, automation now handles roughly half the actions that previously required a live moderator.
An estimate of “80% with an honest acknowledgment of what's still getting through“ from an engineer who tunes the rules themselves is worth more than “99.9% accuracy“ on a landing page with no methodology attached.
**
Conclusion
**
Basic moderation did not become obsolete because it was badly built. It was solving a problem that no longer exists. The challenge used to be “remove bad words from the chat“ – it became “manage a living system under constant, adapting attack.“ That is a different class of problem, and the tools for it look different: a policy engine instead of toggle switches, behavior instead of a dictionary – and a member's reputation rating in place of a binary verdict of spam/not spam. And above all of it – the understanding that moderation data and community health data are the same data.
A community of tens of thousands is an asset. Assets are managed: with metrics, automation, and an honest understanding of where the system hits its ceiling. This approach already has a name – community operations – and the three-layer stack of policy automation, behavioral intelligence, and retention analytics is increasingly called next-gen Community CRM. The gap between this stack and a “bot with filters“ will only grow, because the attacking side has already moved on to the next generation of tools.



