AI Moderator for a 4,000-Member Telegram Community
The owner of a niche 4,000-member Telegram community (organized into forum topics with active daily discussions) was dealing with constant spam, prohibited offers, and toxicity. Manual moderation could not keep up.
Challenge
Build a bot that:
- automatically detects rule violations and deletes offending messages
- enforces escalation: warning, mute, and ban
- posts an evening digest so members do not have to scroll through 300+ messages
AI Moderation
Every message is evaluated by Claude Haiku. The model is fast and inexpensive: roughly ~$0.001 per 1,000 messages with 1–2 second latency.
The bot filters four violation categories:
- buying or selling prohibited items
- spam and unauthorized advertising
- toxicity and personal insults
- dangerous advice without proper disclaimers
Sharing personal experience, expressing emotions, and asking questions are explicitly whitelisted in the system prompt so Haiku does not over-moderate legitimate discussions.
Escalation Flow
First offense: the message is deleted and a warning is posted in chat (auto-deleted after 30 seconds). Second offense: 24-hour mute. Third offense: permanent ban.
Owner Control Panel
Whenever a violation triggers, the owner receives a private DM with the user, the exact message, and the matched category, along with inline buttons to mute (1 hour, 24 hours, 7 days), ban, or unban in one tap.
Daily Digest
Every evening at 21:00, the bot reads the past 24 hours of messages and publishes a structured summary in a dedicated topic: broken down by forum thread, highlighting key discussions, direct links to specific messages, and active contributors.
The digest uses Claude Sonnet, where coherent synthesis matters more than fast binary classification.
Tech Stack
Python, python-telegram-bot, SQLite, running in Docker on a VPS with automatic restart.
Results
First week in production: zero false positives on normal member messages, violations removed in under 3 seconds, and members actively reading the daily digest instead of scrolling hundreds of messages.