Skip to main content

Telegram Admin Bot

Get new-listing, lead and claim alerts in Telegram with inline approve buttons, and run moderation commands like /pending and /approve_listing from your phone.

Why this matters

Moderation shouldn't require opening the admin panel. The Telegram bot pushes new listings, leads and claims to your phone with inline approve buttons, and lets you run moderation commands from a chat — so you can keep a directory clean from anywhere. It's completely optional and a no-op until you set a token.

Turn it on

1. Create a bot with @BotFather and copy the token.

2. Find your admin chat id(s). Message your bot, then read the chat id (e.g. via @userinfobot). Multiple admins are comma-separated.

3. Set the env vars:

# .env.local (and your host's env)
TELEGRAM_BOT_TOKEN=123456:ABC-DEF...
TELEGRAM_ADMIN_CHAT_ID=11111111,22222222   # comma-separated allowlist

4. Register the webhook so Telegram delivers commands to your app:

curl "https://api.telegram.org/bot$TELEGRAM_BOT_TOKEN/setWebhook?url=https://yourdomain.com/api/telegram/webhook"
Fails closed

With no TELEGRAM_ADMIN_CHAT_ID allowlist set, the bot refuses all commands. Only chat ids on the allowlist can run anything — a stranger who finds the bot can't moderate your site.

What it does

Outbound notifications (hooked into webhookEvents): new listing, new lead and new claim, each with an inline approve button.

Inbound commands (authorized against the allowlist):

CommandAction
/statsQuick site stats.
/pendingList items awaiting moderation.
/approve_listing <id>Approve a submitted listing.
/approve_lead <id>Approve a quote lead.
/delete_user <id>Remove a user.
It's genuinely off until configured

Without TELEGRAM_BOT_TOKEN the integration is a complete no-op — no calls, no errors. You can ship without it and add it later.