How sircodak/aguasanfogasta_chatbot works
Project Type and Purpose
• This is a backend-heavy, full-stack chat-bot service built in Python.
• It exposes an HTTP endpoint for Microsoft Teams, orchestrates multiple AI and data-storage services, and persists conversational state.
Main Components
a. Bot Container
• A Dockerized Python application (app.py entry point) running behind Bot Framework
• Hosts modules:
• Bot_Asistente.py (Teams message handling and orchestration)
• OpenAI_Connection.py (OpenAI Assistants API wrapper)
• AzureGPT.py (Azure OpenAI “question improvement”)
• Redis_Connection.py (state persistence)
• Auth_ApiGraph.py (Microsoft Graph/SharePoint integration)
b. External Services
• Microsoft Teams (client channel)
• Azure Bot Framework endpoint (channel service)
• Azure OpenAI API
• OpenAI Assistants API
• Redis cache for conversation state
• SharePoint/Graph API for documents
• Vector Storage (semantic search index)
c. Cron/Sync Scheduler
• A scheduled job (inside the bot container or separate sidecar) that every 90 minutes pulls docs from SharePoint, processes them into embeddings, and updates vector store.
Relationships and Data Flows
• User → Teams client → Bot Framework endpoint → Bot Container (HTTP /api/messages)
• Bot Container:
1. Auth_ApiGraph retrieves user department and SharePoint docs
2. Redis_Connection looks up or initializes conversation state
3. If user question incomplete, AzureGPT module enriches it
4. OpenAI_Connection forwards enriched or original prompt to the correct assistant instance
5. Bot_Asistente formats the AI reply and responds back to Teams
• Sync Scheduler:
• Periodically triggers Auth_ApiGraph → fetch documents → compute embeddings → push to Vector Storage
• All modules read config from environment (config.py)
Architectural Patterns and Principles
• Modular service: each major integration (Redis, OpenAI, GraphAPI) is encapsulated in its own module
• Dependency injection via environment-based config classes
• Stateful vs stateless separation: conversation state in Redis, processing logic in the Python container
• Scheduled batch job for document ingestion