Use case

AI moderation for Telegram groups, in any language

Large Telegram groups attract spam, scams and fights, often in several languages at once. A small bot with VigiMod checks each message against the usual categories and against your group's own rules, and deletes what breaks them.

What makes it hard

Spam and scam waves

New accounts post the same crypto or adult links again and again. With user_id and the group as scope, repeated messages push the spam score to 1.

Groups in many languages

Telegram groups mix Italian, Spanish, Ukrainian, Portuguese and more. The model was trained on 26 languages.

Topic rules

“Only questions about the course”, “No buying or selling”: VigiMod checks rules written in plain words, in any language.

How it works with VigiMod

  1. 1

    Create a bot with BotFather and add it to the group as an admin with the “Delete messages” permission.

  2. 2

    For each text message, the bot sends VigiMod the text, the last ten messages of the group, the author's id and your rules.

  3. 3

    When the answer is flagged, the bot deletes the message; after several flags it can mute or remove the user.

Rules you can copy

Send them in the rules field: each one comes back with its own score, like a built-in category.

{
  "rules": {
    "no-ads": "No advertising or links to other groups or channels",
    "no-trading": "No buying, selling or trading",
    "on-topic": "Only messages about learning Spanish",
    "no-crypto": "No crypto investment offers or trading signals"
  }
}

Example

A Python bot with python-telegram-bot: it keeps the last ten messages of each group and deletes flagged ones.

Python

# pip install python-telegram-bot httpx
# The bot must be an admin of the group with the "Delete messages" permission.
import os
from collections import defaultdict, deque

import httpx
from telegram import Update
from telegram.ext import Application, ContextTypes, MessageHandler, filters

RULES = {"no-ads": "No advertising or links to other groups or channels"}
history = defaultdict(lambda: deque(maxlen=10))   # last messages of each group, sent as context
vigimod = httpx.AsyncClient(base_url="https://api.vigimod.com", timeout=3,
                            headers={"X-API-Key": os.environ["VIGIMOD_KEY"]})

async def check(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
    msg, chat = update.effective_message, str(update.effective_chat.id)
    text = msg.text[:2000]
    try:
        r = await vigimod.post("/moderate", json={
            "text": text, "context": list(history[chat]), "rules": RULES,
            "user_id": str(msg.from_user.id), "scope": chat,
        })
        flagged = r.is_success and r.json()["flagged"]
    except httpx.HTTPError:
        flagged = False                     # slow or down: let the message through
    history[chat].append(text)
    if flagged:
        await msg.delete()

app = Application.builder().token(os.environ["TELEGRAM_TOKEN"]).build()
app.add_handler(MessageHandler(filters.TEXT & ~filters.COMMAND & filters.ChatType.GROUPS, check))
app.run_polling()

Tips

  • Telegram bots see every group message only as admins (or with privacy mode off in BotFather).
  • Check new members' first messages more strictly: lower the spam and advertising thresholds for them.
  • Log deleted messages for the group admins to review: a quick check keeps the group's trust in the bot.

Questions

Does the bot need to be an admin?
Yes. To read every message and delete them, the bot must be an admin of the group with the “Delete messages” permission.
Can it moderate Telegram channels too?
Channels are written by their admins; what usually needs moderation is the discussion group linked to the channel, which works like any group.
Are the messages stored?
No. VigiMod checks each message and discards it; only hourly usage counters per API key are kept.
How much does it cost?
It is free during the beta, with 120 messages per minute per API key, which is enough for most groups.

Try it on your community

Create a free API key in two minutes. No card, no trial period.