How aldyar/umnico_bot works
This repository runs a PDR customer-service bot alongside a FastAPI webhook receiver. The main workflow accepts incoming Umnico messages, records them, waits for a quiet period, builds recent chat history, gets an AI response, and sends it back through Umnico; lead status and admin chat logs are also updated. A separate Telegram workflow lets admins browse accounts and edit their prompts. Some lead-management implementation was not sampled, so its storage wiring is shown only where the route’s calls and module names support it.
Main entry points: user.py Webhook API · main.py Application startup · models.py Database models · ai_function.py AI responses
Components 18
Application runtime
- Application startup
main.py - Webhook API
router/user.py
Webhook conversation
- Conversation timers
app/storage.py - AI responses
function/ai_function.py
Persistence
- Account operations
function/account_func.py - Lead operations
function/lead_func.py - Message history
function/messages_func.py - Database models
database/models.py - MySQL database
Telegram administration
- Account controls
handlers/user.py - Bot menu setup
app/command.py - Admin notifications
handlers/bot_request.py
External services
- Umnico messaging
function/umnico_request.py - Umnico platform
- OpenAI API
- Telegram
Other components
- Customer message
- Admin user
Connections 28
- Application startup → Webhook API: registers router
- Application startup → Account controls: registers handlers
- Application startup → Database models: initializes schema
- Application startup → Bot menu setup: sets commands
- Application startup → Telegram: starts polling
- Customer message → Umnico platform: sends message
- Umnico platform → Webhook API: posts webhook
- Webhook API → Account operations: checks account
- Webhook API → Lead operations: checks lead
- Webhook API → Message history: records messages
- Webhook API → Conversation timers: tracks debounce
- Webhook API → Admin notifications: logs chat events
- Webhook API → AI responses: requests image analysis
- Webhook API → Message history: loads history
- Webhook API → AI responses: requests reply
- Webhook API → Umnico messaging: sends reply
- Webhook API → Lead operations: updates lead status
- AI responses → OpenAI API: requests completion
- AI responses → Umnico platform: downloads image
- Umnico messaging → Umnico platform: posts message
- Message history → Database models: queries messages
- Account operations → Database models: queries accounts
- Lead operations → Database models: queries leads
- Database models → MySQL database: reads and writes
- Admin user → Telegram: uses bot
- Telegram → Account controls: dispatches updates
- Account controls → Account operations: lists and edits
- Admin notifications → Telegram: sends admin logs