A sophisticated Telegram bot powered by OpenAI's GPT-4, DALL-E, and Whisper, enhanced with real-time web search capabilities through Tavily API. Harry acts as an experienced freelance mentor, capable of handling text conversations, generating images, analyzing photos, and processing voice messages in both English and Polish.
- Powered by GPT-4 Turbo for natural language understanding
- Maintains conversation context
- Bilingual support (English and Polish)
- Configurable response temperature for creativity control
- Customizable in-memory message history length
- Integration with Tavily API for current information
- Smart search triggering based on query context
- Focus on post-December 2023 content
- Automatic source attribution
- Fallback mechanisms for comprehensive results
- DALL-E 3 integration for image generation
- Image analysis and description
- Support for multiple image formats (JPG, JPEG, PNG, WebP)
- Detailed visual explanations
- Context-aware image generation
- Voice message transcription using Whisper
- Automatic language detection
- Support for OGG to MP3 conversion
- Progress tracking during processing
- Size limit handling (25MB max)
- Node.js (Latest LTS version)
- npm or yarn
- Telegram Bot Token
- OpenAI API Key
- Tavily API Key
-
Clone the repository:
git clone <repository-url> cd personal-ai-assistant
-
Install dependencies:
npm install
-
Configure environment variables:
cp .env.example .env
Edit
.env
file with your credentials:TELEGRAM_BOT_TOKEN
: Your Telegram bot tokenOPENAI_API_KEY
: Your OpenAI API keyTAVILY_API_KEY
: Your Tavily API key
-
Build and start the bot:
npm run build npm start
For development:
npm run dev
/start
- Initialize the bot/help
- Display available commands and capabilities/search <query>
- Search for current information/generate <description>
- Generate images using DALL-E/analyze
- Analyze images (send image after command)/history <number>
- Set message history length/temp <0.0-2.0>
- Adjust response creativity/lang <pl|en>
- Change bot language
OpenAIService
: Manages interactions with OpenAI APIsTavilyService
: Handles web search functionalityMessageHistoryService
: Manages conversation context
CommandHandler
: Processes bot commandsChatHandler
: Manages message interactionsImageHandler
: Processes image-related operationsVoiceHandler
: Handles voice message processing
- Comprehensive TypeScript implementation
- Zod schema validation for runtime type safety
- Interface-driven development
The bot is highly configurable through environment variables and runtime commands:
- Language: Polish (default) or English
- Message history length
- Response temperature (creativity level)
- API endpoints and tokens
- Server settings
src/
├── config/ # Configuration files
├── handlers/ # Command and message handlers
├── services/ # Core services (AI, History, etc.)
├── types/ # TypeScript type definitions
└── index.ts # Application entry point
- TypeScript
- OpenAI API (GPT-4, DALL-E 3, Whisper)
- Tavily API
- grammY (Telegram Bot Framework)
- Zod (Runtime type validation)
- FFmpeg (Audio processing)
- Implement conversation history persistence
- Add support for:
- User preferences storage
- Conversation backups
- Analytics and usage statistics
- Multi-user session management
- Rate limiting and usage tracking
- User authentication and authorization
- Custom personality templates
- Conversation export/import
- Integration with more AI models
- Advanced error handling and recovery
- Performance optimizations
- Add unit tests coverage
- Implement integration tests
- Add end-to-end testing
- Performance benchmarking
ISC License
Contributions are welcome! Please feel free to submit a Pull Request.