@dieugene/kak-dela-bot v1.0.0
Template Telegram Bot
This repository contains a template for creating Telegram bots with a robust architecture and extensive feature set. It's designed to be a foundation for building various types of Telegram bots with AI capabilities, user management, and advanced dialog handling.
🚀 Features
Core Functionality
- Dialog Management: Built-in dialog system using
@dialogai/dialog-class
- User Management: Comprehensive user control system via
@dialogai/user-controller
- AI Integration: LangChain integration for AI/LLM capabilities
- Database Support: YDB (Yandex Database) integration
- File Handling: Support for various file types (documents, photos, audio, video)
- Voice Message Processing: Built-in voice message recognition
- Session Management: Advanced session handling and cleanup
- Error Handling: Comprehensive error management system
- Admin Functions: Built-in administrative capabilities
- Onboarding: Customizable onboarding flow
- Queue System: Support for queues and timers
- Logging: Integrated logging system
Technical Stack
- Runtime: Node.js
- Telegram API: Telegraf library
- Dialog System:
@dialogai/dialog-class
- for building dialogs - User Management:
@dialogai/user-controller
- for user data management (get_user_data, set_user_data) - Database:
@dieugene/key-object-db
or@dieugene/ydb
- for storing profiles and events
- Utilities:
@dieugene/utils
- for link generation and command parsing@dieugene/sessions
- for session management@dieugene/tg-messages-cache
- for message caching@dieugene/callbacks
- for inline button handling
- AI/LLM:
@langchain/openai
- for AI-powered features - Additional Tools: QR code generation (
qrcode
npm package)
📋 Data Structure
Identifiers and Timestamps
- All string identifiers use UUID format
- Timestamps (
created_on
) are stored as Unix time - Dates are stored in ISO date format
🔧 Implementation Guidelines
Dialog Implementation
The template uses @dialogai/dialog-class
for building natural conversations. This module provides:
- Dialog state management
- Natural conversation flow
- Integration with message caching and sessions
User Management
The template uses @dialogai/user-controller
for user data management with basic operations:
get_user_data
- retrieve user informationset_user_data
- store user information
File Handling
The template supports file handling through Telegram's API with:
- Document upload and processing
- Photo handling
- Audio and video message support
- Voice message recognition
Inline Buttons
The template uses @dieugene/callbacks
for handling inline buttons:
- Registration of callback functions
- Parameter passing through callbacks
- Callback lifecycle management
Database Usage
The template supports two database options:
@dieugene/key-object-db
- for key-object storage@dieugene/ydb
- for Yandex Database integration
🛠️ Getting Started
- Clone the repository
- Install dependencies:
npm install
- Configure environment variables
- Set up your database connection
- Start the bot:
npm start
📦 Module Integration
Career Dialog Bot Integration
The template is compatible with @dieugene/career-dialog-bot
for file handling:
- Uses the same architectural components
- Supports resume and portfolio management
- Implements file processing workflows
File Processing Workflow
- Handle file uploads through Telegram events
- Store file metadata in user database
- Process files as needed (e.g., resume parsing)
- Manage file access and updates
🔐 Security Considerations
- Never expose API keys in the code
- Implement proper user authentication
- Validate all user inputs
- Use secure session management
- Implement rate limiting where necessary
📝 Best Practices
- Always use UUID for identifiers
- Implement proper error handling
- Use the built-in logging system
- Follow the established dialog patterns
- Implement proper session cleanup
- Use the callback system for inline buttons
- Maintain proper database indexing
🤝 Contributing
- Fork the repository
- Create your feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
5 months ago