A Discord bot that monitors specific channels and sends notifications to subscribed users via Telegram using the existing FlowWeave Telegram bot infrastructure.
- 🔍 Channel Monitoring: Monitor specific Discord channels for new messages
- 📢 Telegram Notifications: Send formatted notifications to Telegram users
- 👥 User Subscriptions: Users can subscribe/unsubscribe to channel notifications
- 🔐 Admin Controls: Admin-only commands for managing monitored channels
- 📊 Database Integration: Persistent storage with PostgreSQL and Prisma
- 🎯 Smart Filtering: Ignores bot messages, focuses on user content
The bot integrates with the existing workflows system:
Discord Channel → Discord Bot → Database → Telegram Bot → User Notifications
- Discord Service: Monitors channels and processes messages
- Telegram Service: Formats and sends notifications via existing bot
- Database: Stores channel monitors, subscriptions, and message history
- Commands: Slash commands for user interaction
- Node.js 18+ installed
- PostgreSQL database (reuses existing FlowWeave database)
- Discord Application with Bot Token
- Telegram Bot Token (from existing FlowWeave setup)
- Go to Discord Developer Portal
- Create a new application or use existing one
- Go to "Bot" section and create a bot
- Copy the bot token
- Enable these bot permissions:
- Read Messages/View Channels
- Send Messages
- Use Slash Commands
- Read Message History
- Copy the Application ID (Client ID)
# Navigate to the discord-bot-monitor directory
cd discord-bot-monitor
# Install dependencies
npm install
# Setup environment variables
cp .env.example .env
# Edit .env with your tokens
Update .env
file with your credentials:
# Discord Bot Configuration
DISCORD_BOT_TOKEN=your_discord_bot_token_here
DISCORD_CLIENT_ID=your_discord_client_id_here
# Telegram Bot Configuration (from existing workflows)
TELEGRAM_BOT_TOKEN=your_telegram_bot_token
# Database Configuration (from existing workflows)
DATABASE_URL="your_postgresql_connection_string"
# Generate Prisma client
npm run prisma:generate
# Push database schema
npm run prisma:push
# Or run migrations
npm run prisma:migrate
- Go to Discord Developer Portal → OAuth2 → URL Generator
- Select scopes:
bot
andapplications.commands
- Select bot permissions:
- Read Messages/View Channels
- Send Messages
- Use Slash Commands
- Read Message History
- Use the generated URL to invite the bot to your server
# Development mode
npm run dev
# Production mode
npm run build
npm start
/monitor <channel>
- Start monitoring a channel for notifications
- Only administrators can use this command
- Adds the specified channel to the monitoring list
/list-monitors
- List all monitored channels
- Shows channel statistics and subscriber counts
- Admin-only command
/subscribe <channel> <telegram_username>
- Subscribe to channel notifications
- Channel must be monitored by an admin first
- Provide your Telegram username without the @ symbol
- You must have started a conversation with the FlowWeave Telegram bot
/unsubscribe <channel>
- Unsubscribe from channel notifications
- Removes your subscription from the specified channel
/list-subscriptions
- List your current subscriptions
- Shows all channels you're subscribed to
When a message is posted in a monitored channel, subscribers receive a formatted Telegram notification:
🔔 New Discord Message
🏰 Server: Your Server Name
📢 Channel: #announcements
👤 Author: Username
🕐 Time: 2024-01-15 10:30:00
Message:
Hello everyone! This is an important announcement.
📎 Attachments: 2 file(s)
🔗 View Message
The bot extends the existing database with Discord-specific tables:
- DiscordChannelMonitor: Tracks monitored channels
- DiscordSubscription: Manages user subscriptions
- DiscordMessageRecord: Stores message history for analytics
npm run dev # Start in development mode with hot reload
npm run build # Build TypeScript to JavaScript
npm start # Start production build
npm run watch # Watch mode for development
npm run prisma:generate # Generate Prisma client
npm run prisma:push # Push schema to database
npm run prisma:migrate # Run database migrations
discord-bot-monitor/
├── src/
│ ├── services/
│ │ ├── discord.service.ts # Discord monitoring logic
│ │ └── telegram.service.ts # Telegram notification service
│ ├── commands/
│ │ └── subscription.commands.ts # Slash command handlers
│ ├── types/
│ │ └── discord.ts # TypeScript interfaces
│ └── index.ts # Main bot entry point
├── prisma/
│ └── schema.prisma # Database schema
├── package.json
├── tsconfig.json
├── .env # Environment variables
└── README.md
-
"Channel is not being monitored"
- Ask a server administrator to run
/monitor
on the channel first
- Ask a server administrator to run
-
"No chat ID found for Telegram user"
- Make sure you've started a conversation with the FlowWeave Telegram bot
- Use the exact same username in both Discord and Telegram subscriptions
-
Bot not responding to commands
- Check bot permissions in Discord server
- Verify the bot token is correct
- Ensure slash commands are registered
-
Database connection errors
- Verify DATABASE_URL is correct
- Check if the database is accessible
- Run
npm run prisma:generate
andnpm run prisma:push
The bot provides detailed logging for debugging:
# View logs in development
npm run dev
# For production, consider using PM2 or similar process manager
pm2 start dist/index.js --name "discord-monitor"
pm2 logs discord-monitor
This Discord bot seamlessly integrates with the existing FlowWeave ecosystem:
- Shared Database: Uses the same PostgreSQL database as the workflows system
- Telegram Integration: Leverages the existing Telegram bot for notifications
- Consistent Architecture: Follows the same patterns as other FlowWeave services
- Bot tokens are stored in environment variables
- User permissions are checked for admin commands
- Database queries use Prisma for SQL injection protection
- Error handling prevents sensitive information leakage
- Message Filtering: Filter by keywords, user roles, or message types
- Scheduled Summaries: Daily/weekly digest of channel activity
- Rich Embeds: Support for Discord embed forwarding
- User Management: Bulk subscription management for admins
- Analytics: Message statistics and engagement metrics
For issues or questions:
- Check the troubleshooting section above
- Review the logs for error messages
- Ensure all environment variables are correctly set
- Verify database connectivity and schema is up to date
This project is part of the FlowWeave ecosystem and follows the same licensing terms.