How abdulaleemdev/telegram-ai-bot works
Telegram AI Bot receives Telegram messages through a FastAPI webhook, processes them with a LangGraph support agent, and replies through Telegram. The agent can answer FAQs, track orders, and handle support tickets with order verification; chat history and order/ticket records provide persistence. The graph includes the documented PostgreSQL and Groq integrations. Relationships for unsampled modules are limited to references in the source index and README; those modules were not inspected in full.
Main entry points: agent.py LangGraph agent · database.py Database connection · main.py FastAPI app · models.py Order and ticket models
Components 20
Webhook and Telegram
- FastAPI app
app/main.py - Webhook handler
app/api/webhook.py - Telegram integration
app/core/telegram.py
AI Conversations
- Message service
app/services/bot_service.py - LangGraph agent
app/graph/agent.py - Groq language model
app/core/ai.py - Chat memory
app/services/chat_memory.py
Customer Support Tools
- FAQ lookup
app/tools/faq_tool.py - Order tracking
app/tools/track_order_tool.py - Order verification
app/tools/verify_order_tool.py - Ticket creation
app/tools/ticket_tool.py
Configuration and Data
- Database connection
app/core/database.py - Order and ticket models
app/database/models.py - ORM base
app/database/base.py - Application config
app/core/config.py - Logging setup
app/core/logging_config.py
Other components
- Telegram user
- Telegram API
- Groq API
- PostgreSQL
Connections 26
- Telegram user → Webhook handler: sends update
README.md - FastAPI app → Webhook handler: mounts router
app/main.py - FastAPI app → Telegram integration: registers webhook
app/main.py - FastAPI app → Application config: validates settings
app/main.py - FastAPI app → Logging setup: sets up logging
app/main.py - Webhook handler → Message service: dispatches message
app/api/webhook.py - Message service → LangGraph agent: runs agent
app/services/bot_service.py - Message service → Telegram integration: sends reply
app/services/bot_service.py - Telegram integration → Telegram API: calls API
app/core/telegram.py - Telegram API → Telegram user: delivers reply
- LangGraph agent → Groq language model: invokes model
app/graph/agent.py - Groq language model → Groq API: uses provider
README.md - LangGraph agent → Chat memory: loads and saves
app/graph/agent.py - LangGraph agent → FAQ lookup: dispatches tool
app/graph/agent.py - LangGraph agent → Order tracking: dispatches tool
app/graph/agent.py - LangGraph agent → Order verification: dispatches tool
app/graph/agent.py - LangGraph agent → Ticket creation: dispatches tool
app/graph/agent.py - Order tracking → Database connection: opens session
app/tools/track_order_tool.py - Order tracking → Order and ticket models: queries orders
app/tools/track_order_tool.py - Ticket creation → Database connection: opens session
app/tools/ticket_tool.py - Ticket creation → Order and ticket models: reads and writes
app/tools/ticket_tool.py - Order verification → Database connection: uses database
app/tools/verify_order_tool.py - Order verification → Order and ticket models: checks orders
app/tools/verify_order_tool.py - Database connection → Application config: reads URL
app/core/database.py - Database connection → PostgreSQL: connects to
README.md - Order and ticket models → ORM base: inherits from
app/database/models.py