# Webhook Telegram Bot - AI-Powered Discourse Notifications

**URL:** https://meta.discourse.org/t/webhook-telegram-bot-ai-powered-discourse-notifications/377512
**Category:** Extras
**Created:** [August 6, 2025, 9:48am UTC](https://meta.discourse.org/t/webhook-telegram-bot-ai-powered-discourse-notifications/377512 "2025-08-06T09:48:41Z")
**Posts on this page:** 1
**Showing post:** 1

<div class="post-metadata">

### Author: ![DigneZzZ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dignezzz/32/506171_2.png) [@DigneZzZ](https://meta.discourse.org/u/DigneZzZ)
#### Post date: [August 6, 2025, 9:48am UTC](https://meta.discourse.org/t/webhook-telegram-bot-ai-powered-discourse-notifications/377512/1 "2025-08-06T09:48:42Z")

</div>

| | | |
| --- | --- | --- |
| ℹ | **Summary** | Professional Telegram bot for automatic notifications about new posts from Discourse forums with AI-generated summaries using OpenAI GPT-4.1-nano |
| 🛠 | **Repository Link** | [GitHub - DigneZzZ/webhook\_tg\_bot · GitHub](https://github.com/dignezzz/webhook_tg_bot) |
| 📖 | **Install Guide** | [README\_EN.md](https://github.com/dignezzz/webhook_tg_bot/blob/main/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

**🔗 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)

**🤖 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

**📱 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 (👑 Admin, 🛡 Moderator, ⭐ Staff, etc.)

- Smart HTML message formatting

**🎯 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

**🚀 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:

```plaintext

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](https://t.me/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**

```bash

# 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:

```nginx

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 | - | ✅ |
| `TELEGRAM_CHAT_ID` | Target group/channel ID | - | ✅ |
| `TELEGRAM_THREAD_ID` | Main topic ID (0 = main chat) | 0 | ❌ |
| `WEBHOOK_SECRET` | Secret key for signature verification | - | ✅ |
| `WEBHOOK_PORT` | Webhook server port | 8080 | ❌ |
| `WEBHOOK_PATH` | Webhook endpoint path | /webhook | ❌ |
| `OPENAI_API_KEY` | OpenAI API key for summaries | - | ❌ |
| `OPENAI_MODEL` | GPT model to use | gpt-4.1-nano | ❌ |
| `BASE_URL` | Your Discourse forum URL | - | ❌ |
| `MONITORED_CATEGORIES` | Category IDs to monitor (comma-separated) | all | ❌ |
| `IGNORED_CATEGORIES` | Category IDs to ignore (comma-separated) | none | ❌ |
| `IGNORED_USERS` | User IDs to ignore (comma-separated) | none | ❌ |
| `PREMIUM_CATEGORIES` | Premium category IDs (comma-separated) | none | ❌ |

**Category-to-Topic Mapping** (Optional):

```plaintext

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

```

### Message Format Example

```plaintext

👤 👑 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:

```bash

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

- **GitHub Repository** : [GitHub - DigneZzZ/webhook\_tg\_bot · GitHub](https://github.com/dignezzz/webhook_tg_bot)

- **Issues** : [Report bugs or feature requests](https://github.com/dignezzz/webhook_tg_bot/issues)

- **Discussions** : [Community discussions](https://github.com/dignezzz/webhook_tg_bot/discussions)

**License** : MIT License

---

_[View the full topic](https://meta.discourse.org/t/webhook-telegram-bot-ai-powered-discourse-notifications/377512)._
