Skip to content

Mikehutu/Telegram-Discord-Agent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

6 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“‘ Telegram β†’ Discord Curator

AI-powered content curation from Telegram to Discord

License: MIT TypeScript Node.js

Drop a link in Telegram β†’ Get an AI-researched summary in Discord


An AI-powered bot that takes links from Telegram, researches the content using GPT-4, and posts organized summaries to Discord with automatic tagging.

Built With

This project uses open-source tools by @kingbootoshi:

  • feather-ai - Lightweight AI agent framework with auto-executing tools

Features

πŸ€– AI-Powered Research: Automatically extracts and summarizes content from GitHub repos, articles, and other links πŸ“ Smart Summaries: GPT-4 generates engaging Discord posts with bullet points and "Why it matters" sections 🏷️ Auto-Tagging: Automatically categorizes content with Forum tags (Forum mode only) πŸ“± Multi-Platform: Receives links via Telegram, posts to Discord πŸ”— Smart URL Handling: Converts arXiv PDF links to abstract pages, handles shortened URLs

Two Modes Available

🎯 Forum Mode (Advanced)

  • Posts to Discord Forum channels as organized threads
  • Auto-tags content with 7 categories:
    • AI Agents
    • Image/Video/Audio
    • LLMs & Chat
    • Dev Tools
    • Research/Papers
    • Web/Mobile Design
    • Open Source
  • Searchable and organized by category

πŸ“ Simple Mode (Basic)

  • Posts to regular Discord text channels
  • Clean, simple messages without threading
  • No tagging or categorization
  • Easier setup and management

Setup

  1. Clone the repository:
git clone https://github.com/Mikehutu/Telegram-Discord-Agent.git
cd Telegram-Discord-Agent
  1. Install dependencies:
npm install
  1. Set up your environment variables (see Environment Variables section below)

  2. Start the bot in your preferred mode:

Forum Mode:

npm run dev    # Development
npm start      # Production

Simple Mode:

npm run simple-dev    # Development
npm run simple        # Production

Environment Variables

Create a .env file with the following variables:

Required for Both Modes

TELEGRAM_BOT_TOKEN=your_telegram_bot_token
OPENROUTER_API_KEY=your_openrouter_api_key
DISCORD_BOT_TOKEN=your_discord_bot_token

Optional: AI Model Configuration

# OpenRouter model to use for content summarization and knowledge extraction
# Default: openai/gpt-4.1-mini
# Examples: anthropic/claude-3-haiku, meta-llama/llama-3.1-8b-instruct, etc.
AI_MODEL=openai/gpt-4.1-mini

Optional: Bot Authorization

# Comma-separated list of authorized Telegram user IDs
# If not set, all users can use the bot
TELEGRAM_AUTHORIZED_USERS=

# Comma-separated list of authorized Telegram chat IDs  
# If not set, all chats can be used (but still subject to user authorization)
# For private chats, chat ID is the same as user ID
TELEGRAM_AUTHORIZED_CHATS=

For Forum Mode (Advanced)

DISCORD_FORUM_CHANNEL_ID=your_forum_channel_id

For Simple Mode (Basic)

DISCORD_CHANNEL_ID=your_regular_channel_id

Note: Use DISCORD_FORUM_CHANNEL_ID for Forum mode OR DISCORD_CHANNEL_ID for Simple mode - not both.

Bot Setup

Telegram Bot Setup

  1. Message @BotFather on Telegram
  2. Send /newbot and follow the prompts
  3. Copy your bot token to the .env file as TELEGRAM_BOT_TOKEN
  4. Add the bot to your desired Telegram chat

Getting Your Telegram User ID and Chat ID

Getting Your Telegram User ID and Chat ID

To prevent unauthorized users from using your bot, you can restrict access using user IDs and chat IDs:

Easiest Method - Use the /status command:

  1. Add your bot to a private chat or group
  2. Send /status to the bot (this command works even with authorization enabled)
  3. The bot will reply with your user ID and chat ID

Manual Method:

  1. Get your User ID:

    • Start a private chat with @userinfobot
    • Send any message to get your user ID
  2. Get your Chat ID (for group chats):

    • Add your bot to the Telegram group/chat
    • Send a message in the group
    • Visit: https://api.telegram.org/bot<YOUR_BOT_TOKEN>/getUpdates
    • Look for the "chat":{"id":...} field in the response
  3. Configure Authorization:

    # Comma-separated list of authorized Telegram user IDs
    TELEGRAM_AUTHORIZED_USERS=123456789,987654321
    
    # Comma-separated list of authorized Telegram chat IDs
    TELEGRAM_AUTHORIZED_CHATS=-1001234567890

    If these variables are not set, the bot will accept messages from all users (not recommended for public use).

Discord Bot Setup

  1. Go to Discord Developer Portal
  2. Create a new application and bot
  3. Copy the bot token to your .env file as DISCORD_BOT_TOKEN
  4. Enable "Message Content Intent" under Bot settings (required to read messages)
  5. Invite the bot to your Discord server with appropriate permissions:
    • Forum Mode: "Send Messages" and "Create Public Threads"
    • Simple Mode: "Send Messages"

Discord Channel Setup

For Forum Mode

  1. Create a Forum channel in Discord
  2. Add these tags to your Forum channel:
    • ai agents
    • image/video/audio
    • llms
    • chat
    • dev tools
    • research/papers
    • web/mobile design
  3. Right-click the Forum channel β†’ Copy Channel ID
  4. Add to .env as DISCORD_FORUM_CHANNEL_ID

For Simple Mode

  1. Use any existing text channel or create a new one
  2. Right-click the channel β†’ Copy Channel ID
  3. Add to .env as DISCORD_CHANNEL_ID

Usage

Sending Links

  1. Send any URL to your Telegram bot
  2. The bot will:
    • Research the link content
    • Generate an AI summary with GPT-4
    • Post to Discord with appropriate formatting

Example Discord Output

Forum Mode:

🧡 Thread: "Anthropic's Constitutional AI Paper"
🏷️ Tags: Research/Papers, AI Agents

πŸ“„ **Anthropic's Constitutional AI Paper**

β€’ Novel approach to training helpful, harmless AI assistants
β€’ Uses AI feedback instead of human feedback for safety training  
β€’ Significantly reduces harmful outputs while maintaining helpfulness

πŸ’‘ **Why it matters**: This could be a breakthrough for scaling AI safety...

πŸ”— https://arxiv.org/abs/2212.08073

Simple Mode:

πŸ“„ **Anthropic's Constitutional AI Paper**

β€’ Novel approach to training helpful, harmless AI assistants
β€’ Uses AI feedback instead of human feedback for safety training
β€’ Significantly reduces harmful outputs while maintaining helpfulness

πŸ’‘ **Why it matters**: This could be a breakthrough for scaling AI safety...

πŸ”— https://arxiv.org/abs/2212.08073

How It Works

  1. Link Detection: Bot monitors your Telegram chat for URLs
  2. Content Research: Extracts titles, descriptions, and metadata from links
  3. AI Summary: GPT-4 generates engaging Discord posts with proper formatting
  4. Smart Posting:
    • Forum Mode: Creates organized threads with auto-tags
    • Simple Mode: Posts directly to channel

How Content Research Works

The bot doesn't use web search - instead, it directly fetches content from each URL:

  • GitHub Repositories: Uses the GitHub API to fetch repository metadata (stars, forks, language, topics) and README content
  • Other Websites: Uses web scraping to fetch the webpage and extract titles, descriptions, and metadata
  • Supported Platforms: GitHub, arXiv, Medium, HuggingFace, Reddit, Hacker News, and general webpages

The AI then reads this extracted content and generates the summary bullet points and "Why it matters" section.

Security Considerations

When running this bot publicly, keep these security and cost considerations in mind:

πŸ” Access Control

  • Always set TELEGRAM_AUTHORIZED_USERS - Without this, anyone who knows your Telegram bot token can use it
  • Set TELEGRAM_AUTHORIZED_CHATS for group chats to restrict which conversations the bot responds to
  • Never share your API keys publicly

πŸ’° Cost Management

  • Each link triggers an AI call (costs money via OpenRouter)
  • Consider adding rate limiting for production use
  • Monitor your OpenRouter usage regularly

🌐 URL Fetching

  • The bot fetches content from any URL shared in authorized chats
  • Only run with trusted users to avoid abuse
  • Consider implementing rate limits per user if running publicly

πŸ”’ Best Practices

  • Keep your .env file private and never commit it
  • Use separate API keys for development vs production
  • Monitor your bot's activity regularly

Docker Deployment

Prerequisites

Quick Start with Docker

  1. Clone and configure:
git clone https://github.com/Mikehutu/Telegram-Discord-Agent.git
cd Telegram-Discord-Agent
  1. Create a .env file with your credentials (see Environment Variables section)

  2. Build and run with Docker Compose:

docker-compose up -d
  1. View logs:
docker-compose logs -f

Running with Docker Only

# Build the image
docker build -t telegram-discord-curator .

# Run the container
docker run -d \
  --name telegram-curator \
  --env TELEGRAM_BOT_TOKEN=your_token \
  --env DISCORD_BOT_TOKEN=your_token \
  --env OPENROUTER_API_KEY=your_key \
  --env DISCORD_CHANNEL_ID=your_channel \
  telegram-discord-curator

Docker Volumes

  • curator_data - Persistent data storage

Docker Profiles

  • default - Forum mode
  • simple - Simple mode (run with docker-compose --profile simple up)

Contributing

Feel free to submit issues and enhancement requests!

License

MIT License - feel free to use and modify as needed.

About

AI-powered content curation from Telegram to Discord - Drop a link to telegram -> Get an AI-researched summary in Discord

Resources

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors