A powerful Telegram bot that allows you to search through your Telegram folders and conversations with enhanced features like direct message links, calendar event extraction, and action item detection.
- 📁 Folder Browsing - Browse and select your Telegram folders
- 💬 Individual Conversation Selection - Select specific chats/groups with visual indicators
- 🔍 Keyword Search - Search for specific terms across multiple conversations
- 🔗 Direct Message Links - Click to go back to original messages
- 📅 Calendar Event Extraction - Automatically find meeting times and dates
- ✅ Action Item Detection - Identify tasks and deadlines
- ⏰ Time Range Selection - Search last 7 days, 30 days, 3 months, or all time
- 🛡️ Robust Error Handling - Handles timeouts and connection issues gracefully
- Node.js (v16 or higher)
- Telegram API credentials (API_ID and API_HASH)
- Bot token from @BotFather
-
Clone the repository:
git clone <repository-url> cd TG_Folder_Export
-
Install dependencies:
npm install
-
Set up environment variables: Create a
.env
file in the root directory:API_ID=your_api_id API_HASH=your_api_hash BOT_TOKEN=your_bot_token SESSION_STRING=your_session_string
- Go to https://my.telegram.org/
- Log in with your phone number
- Go to "API Development Tools"
- Create a new application
- Copy the
API_ID
andAPI_HASH
- Message @BotFather on Telegram
- Use
/newbot
command - Follow the instructions to create your bot
- Copy the bot token
Run the session generator:
npm run session
Follow the prompts to:
- Enter your phone number (with country code, e.g., +34...)
- Enter the verification code sent to your phone
- Enter your 2FA password (if enabled)
The session string will be automatically saved to your .env
file.
npm start
/start
- Welcome message and main menu/help
- Show detailed help information
- Start the bot → Click "📁 Browse Folders"
- Select a folder → Click folder number
- Select conversations → Click to select (✅ shows selected)
- Choose time range → 7 days, 30 days, 3 months, or all time
- Type search term → Just type in chat (e.g., "meeting", "deadline")
- Get results → With direct links to original messages
- 📅 Meeting - Find meeting-related messages
- ⏰ Deadline - Find deadlines and due dates
- 📞 Call - Find call-related messages
- 📋 Task - Find task assignments
- 💰 Payment - Find payment information
- 🎯 Project - Find project-related messages
- 📝 Custom - Type your own search term
TG_Folder_Export/
├── src/
│ ├── robustEnhancedBot.ts # Main bot with all features
│ └── timeoutResistantSessionGenerator.ts # Session string generator
├── package.json # Project configuration
├── tsconfig.json # TypeScript configuration
├── README.md # This file
└── .env # Environment variables (create this)
npm start
- Start the enhanced botnpm run session
- Generate session stringnpm run build
- Build TypeScript files
The bot includes robust error handling for:
- Connection timeouts - Automatic retry with shorter timeouts
- Message editing errors - Falls back to sending new messages
- Session issues - Clear error messages and recovery instructions
- Search failures - Graceful degradation with helpful suggestions
- Visual indicators - ✅ for selected, ⬜ for unselected
- Multiple selection - Select multiple conversations at once
- Conversation types - 👤 Users, 👥 Groups, 📢 Channels
- Keyword matching - Case-insensitive search
- Time filtering - Search within specified time ranges
- Result limiting - Show top results to prevent overload
- Direct links - Click to go back to original messages
- Calendar events - Extract dates and times automatically
- Action items - Find tasks and deadlines
- Conversation context - Know which chat each result is from
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
This project is licensed under the ISC License.
-
"No session string found"
- Run
npm run session
to generate a session string
- Run
-
"Phone number banned"
- Wait 24 hours before trying again
- Use a different phone number
- Contact Telegram support
-
"Timeout errors"
- Check your internet connection
- Try again in a few minutes
- Use a VPN if needed
-
"Message can't be edited"
- The bot automatically handles this by sending new messages
- No action needed from your side
If you encounter issues:
- Check the error messages in the console
- Verify your
.env
file has all required variables - Ensure your bot token is correct
- Make sure your session string is valid
- Calendar integration (add events directly to calendar)
- Export results to various formats (PDF, CSV)
- Advanced search filters (by sender, date range)
- AI-powered summarization of search results
- Web interface for easier management