TG2AI is an ultra-minimalist, stateless Telegram bot designed to convert any public Telegram channel into clean, AI-ready data formats (Markdown, JSON, CSV) in less than 10 seconds.
Perfect for loading expert context into ChatGPT, Claude Projects, building personal RAG bases, or preparing custom datasets for LLM fine-tuning.
🇷🇺 Бот полностью поддерживает русский язык! Если язык вашего интерфейса Telegram русский, бот автоматически переключится на него.
When you export chat history using the native Telegram Desktop client, you get cluttered HTML or verbose JSON files. * Bloated Context: Up to 90% of the export consists of service code, system styles, and HTML noise. Feeding this directly to Claude or ChatGPT blows up your context window and burns your token budget. * No Markdown Structure: Standard exports do not organize posts cleanly for LLM consumption, making note-taking systems like Obsidian difficult to build.
The TG2AI Solution: It scrapes, cleanses, formats, and estimates tokens in 10 seconds. You get clean text, structured code, and active links.
This project is designed to run completely stateless and fit comfortably within the Vercel Hobby Free Tier (serverless execution).
Create a private or public repository on GitHub, commit your code, and push:
git clone https://github.com/your-username/tg2ai.git
cd tg2ai
npm install
Import the project into Vercel and add the following Environment Variables:
* TELEGRAM_BOT_TOKEN: Your bot token from @BotFather.
* NEXT_PUBLIC_TELEGRAM_BOT_USERNAME: The username of your bot (e.g., tg2aiibot).
* WEBHOOK_URL: Your Vercel deployment URL (e.g., https://your-project.vercel.app).
Once deployed, open your browser and navigate to:
https://your-project.vercel.app/api/set-webhook
You will see: {"ok":true,"result":true,"description":"Webhook was set"}. Your bot is live!
For fast local testing without setting up tunnels or webhooks:
.env file in the root directory:
env
TELEGRAM_BOT_TOKEN=your_bot_token
NEXT_PUBLIC_TELEGRAM_BOT_USERNAME=your_bot_usernamebash
npm run dev # Runs next dev server
npx tsx --env-file=.env src/lib/run-polling.ts # Runs bot listenerWe want to make TG2AI the ultimate bridge between Telegram and AI coding agents.
If you are using agentic coding helpers (like Antigravity, Claude Code, or Cline), we are wrapping this utility into a reusable Agentic Skill. This will allow any AI coder to automatically fetch and index Telegram channels directly into a workspace via a simple slash command.
Feel free to open issues, submit Pull Requests, and help us make this tool better!
This project is licensed under the MIT License - see the LICENSE file for details.
$ claude mcp add tg2ai \
-- python -m otcore.mcp_server <graph>