Webhook Telegram Bot - AI-Powered Discourse Notifications

:information_source: Summary Professional Telegram bot for automatic notifications about new posts from Discourse forums with AI-generated summaries using OpenAI GPT-4.1-nano
:hammer_and_wrench: Repository Link GitHub - DigneZzZ/webhook_tg_bot
:open_book: Install Guide README_EN.md

Webhook Telegram Bot - AI-Powered Discourse Notifications

Note: While this is not a traditional Discourse plugin but rather an external integration service, I couldn’t find a more appropriate category to share this useful tool with the Discourse community. This bot works alongside your Discourse forum to provide enhanced notification capabilities.

Features

:link: Discourse Integration

  • Processes webhooks for topic and post creation events

  • Supports all types of Discourse content

  • Combines topic and post data into unified messages

  • Webhook signature verification for security (HMAC-SHA256)

:robot: AI Content Analysis

  • OpenAI GPT-4.1-nano integration for intelligent post summaries

  • Context-aware content analysis with HTML cleanup

  • Special templates for different content types

  • Automatic content filtering and processing

:mobile_phone: Advanced Telegram Delivery

  • Send notifications to main chat or specific forum topics

  • Category mapping - route different Discourse categories to different Telegram topics

  • User role emoji prefixes (:crown: Admin, :shield: Moderator, :star: Staff, etc.)

  • Smart HTML message formatting

:bullseye: Flexible Filtering & Control

  • Monitor specific categories or all categories

  • Ignore unwanted categories with priority system

  • Block bot users (discobot, chatbot, system users)

  • Premium section notifications with subscription alerts

:rocket: Production Ready

  • Docker containerization with health checks

  • GitHub Actions CI/CD pipeline

  • Systemd integration for auto-startup

  • Comprehensive logging and monitoring

  • Graceful shutdown and error handling

Configuration

1. Discourse Webhook Setup

  1. Navigate to Admin → API → Webhooks

  2. Click New Webhook

  3. Configure:


Payload URL: https://your-domain.com/webhook

Content Type: application/json

Secret: your_webhook_secret

Which events: Topic Event + Post Event

2. Telegram Bot Setup

  1. Create bot via @BotFather

  2. Get Chat ID for your group/channel

  3. Optionally set up forum topics for category routing

3. Environment Configuration

Create .env file with required settings (see full configuration in repository).

4. Docker Deployment


# Quick installation

curl -fsSL https://raw.githubusercontent.com/dignezzz/webhook_tg_bot/main/install.sh -o install.sh

chmod +x install.sh

./install.sh install

5. Reverse Proxy Setup

For webhook support on your domain, configure reverse proxy (nginx/Apache) to route webhook requests to the bot container on port 8080.

Example nginx configuration:


location /webhook {

proxy_pass http://localhost:8080/webhook;

proxy_set_header Host $host;

proxy_set_header X-Real-IP $remote_addr;

}

Settings

Name Description Default Required
TELEGRAM_BOT_TOKEN Bot token from @BotFather - :white_check_mark:
TELEGRAM_CHAT_ID Target group/channel ID - :white_check_mark:
TELEGRAM_THREAD_ID Main topic ID (0 = main chat) 0 :cross_mark:
WEBHOOK_SECRET Secret key for signature verification - :white_check_mark:
WEBHOOK_PORT Webhook server port 8080 :cross_mark:
WEBHOOK_PATH Webhook endpoint path /webhook :cross_mark:
OPENAI_API_KEY OpenAI API key for summaries - :cross_mark:
OPENAI_MODEL GPT model to use gpt-4.1-nano :cross_mark:
BASE_URL Your Discourse forum URL - :cross_mark:
MONITORED_CATEGORIES Category IDs to monitor (comma-separated) all :cross_mark:
IGNORED_CATEGORIES Category IDs to ignore (comma-separated) none :cross_mark:
IGNORED_USERS User IDs to ignore (comma-separated) none :cross_mark:
PREMIUM_CATEGORIES Premium category IDs (comma-separated) none :cross_mark:

Category-to-Topic Mapping (Optional):


TELEGRAM_THREAD_ID_1=123456
THREAD_CATEGORIES_1=1,2,3
TELEGRAM_THREAD_ID_2=234567
THREAD_CATEGORIES_2=4,5

Message Format Example


👤 👑 Administrator created a new post: Docker Configuration Guide

📋 Author shares a solution to Docker container configuration problem and explains step-by-step process of fixing database connection errors.

🔗 Topic link (https://forum.example.com/t/topic/123)

🏷 Tags: #docker, #database, #troubleshooting

💎 This section is available by subscription only.

Installation & Management

The bot includes a management script for easy operations:


whtg status # Check bot status

whtg start # Start the bot

whtg stop # Stop the bot

whtg restart # Restart the bot

whtg logs # View logs

whtg update # Update to latest version

whtg uninstall # Remove the bot

Language Support

Note: Currently, all interface messages and documentation are in Russian, but English language support will be added in the near future. The bot works with any Discourse forum regardless of language.

Technical Requirements

  • Docker and Docker Compose

  • Reverse proxy (nginx/Apache) for webhook domain support

  • OpenAI API key (optional, for AI summaries)

  • HTTPS certificate (recommended for production)

Support & Contributions

License: MIT License

2 Likes