Commit Graph

12 Commits

Author SHA1 Message Date
google-labs-jules[bot]
3cdc7a73ef This commit fixes a critical bug where the bot would get stuck in previous conversational flows and provide incorrect responses.
The /start command handler in main.py now explicitly calls flow_engine.end_flow() to clear any existing conversation state for the user.

This ensures that every /start command provides a clean slate, resolving the state management issue and making the bot's interactions predictable and correct.
2025-12-21 18:23:53 +00:00
google-labs-jules[bot]
384e23cf58 fix: resolve unresponsive bot by migrating to FlowEngine
The Telegram bot was becoming unresponsive due to a conflict between a legacy `ConversationHandler` for the `propose_activity` flow and the main `FlowEngine`. This was likely caused by breaking changes in the `python-telegram-bot` library.

This commit resolves the issue by:
1.  Removing the problematic `ConversationHandler` from `main.py` and its related functions from `modules/equipo.py`.
2.  Migrating the "propose activity" feature to a data-driven JSON flow (`crew_propose_activity.json`), making it compatible with the existing `FlowEngine`.
3.  Pinning the `python-telegram-bot` dependency to `<22` in `requirements.txt` to prevent future breakage from upstream updates.

This change ensures all conversational flows are handled consistently by the `FlowEngine`, restoring bot responsiveness and improving maintainability.
2025-12-21 18:07:45 +00:00
Marco Gallegos
0c2c9fc524 feat: Implement multi-step conversation flows with dynamic UI, persistent state, and improved path handling. 2025-12-21 11:42:08 -06:00
google-labs-jules[bot]
7b633ef2e8 feat: Implement NFC tag creation wizard via FlowEngine
This commit implements the NFC tag creation wizard as a data-driven JSON flow, completing a key item from the roadmap.

-   **Refactor to FlowEngine:** The previous implementation, which used a `ConversationHandler`, has been completely replaced. The wizard is now defined in `talia_bot/data/flows/admin_create_nfc_tag.json` and is managed by the central `FlowEngine`.
-   **New Module:** The logic for generating the Base64 tag is encapsulated in a new, dedicated module: `talia_bot/modules/nfc_tag.py`.
-   **Improved UX:** The "Sucursal" (branch) selection step now uses buttons, as originally specified in the documentation, improving the user experience.
-   **Code Cleanup:** The obsolete `talia_bot/modules/create_tag.py` module and its corresponding `ConversationHandler` have been removed from `main.py`, making the codebase more consistent and maintainable.
-   **Documentation:** The `README.md` has been updated to mark the feature as complete and to include a description of the new wizard.
2025-12-21 10:13:28 +00:00
google-labs-jules[bot]
ab2831b542 feat: Implement remote printing and sales RAG flow
Implement the first two items from the product roadmap:

1.  **Remote Printing Service:**
    *   Create a new `printer.py` module to handle sending files via SMTP and checking status via IMAP.
    *   Add a document handler in `main.py` to allow admin users to send files to the bot for printing.
    *   Add a `/check_print_status` command for admins to monitor the print job status.
    *   Add SMTP/IMAP configuration variables to `config.py` and `.env.example`.

2.  **Sales RAG Flow:**
    *   Implement a `sales_rag.py` module to generate personalized sales pitches.
    *   The sales flow uses a Retrieval-Augmented Generation (RAG) approach, retrieving relevant services from `services.json` to create a detailed prompt for the LLM.
    *   The existing `flow_engine.py` is modified to trigger the sales pitch generation upon completion of the `client_sales_funnel` flow.
    *   Update `main.py` to handle the flow engine's responses and send the generated pitch to the user.
    *   Update `client_sales_funnel.json` to be triggered by a button in the client menu.
2025-12-21 08:53:50 +00:00
google-labs-jules[bot]
ac52998d47 feat: Implement JSON-based conversational flow engine and add all flow files
This commit finalizes the implementation of the JSON-driven conversational flow engine.

Key changes:
- Introduces `flow_engine.py` to manage loading and processing conversational flows from external files.
- Adds the complete set of individual JSON files for all admin, crew, and client flows under the `talia_bot/data/flows/` directory.
- Integrates the flow engine into `main.py` to handle user interactions based on the new modular flow definitions.

This resolves the issue where the flow files were missing from the repository, providing a complete and functional implementation.
2025-12-21 05:07:36 +00:00
google-labs-jules[bot]
6bb7bc6b44 feat: Implement JSON-based conversational flow engine
This commit introduces a new `FlowEngine` to manage conversational flows based on JSON definitions.

Key changes:
- Created `talia_bot/modules/flow_engine.py` to handle the logic of parsing and executing flows.
- Added a `conversations` table to the database to persist user state during flows.
- Created the `talia_bot/data/flows` directory and added a sample `create_project.json` flow.
- Integrated the `FlowEngine` into `main.py` with a `universal_handler` that routes user input to the engine or to legacy handlers.
2025-12-21 04:58:12 +00:00
google-labs-jules[bot]
104e291204 fix: Recreate and upload all missing flow engine files
This commit provides a complete and clean implementation of the JSON-driven flow engine to resolve persistent issues with missing files in previous commits.

This commit includes:
- All individual flow definition files in the `talia_bot/data/flows/` directory.
- The `talia_bot/data/services.json` file.
- The `talia_bot/modules/flow_engine.py` module with corrected logic for handling user responses and robust role assignment.
- All other necessary backend modules that were missing after the environment reset.

This comprehensive commit ensures that all required files are present and correctly implemented, providing a stable foundation for the new modular conversational architecture. All code has been reviewed and corrected based on feedback.
2025-12-21 04:44:59 +00:00
google-labs-jules[bot]
8cd1fd2782 feat: Implement JSON-driven conversational flow engine
This commit completely refactors the bot's architecture to use a generic, JSON-driven flow engine, replacing the previous hardcoded `ConversationHandler` logic.

Key changes include:
- **New Flow Engine:** Introduces `talia_bot/modules/flow_engine.py` to manage conversational state based on definitions in `talia_bot/data/flows.json`.
- **Centralized Flow Definitions:** All conversational flows for Admin, Crew, and Client roles are now defined in `talia_bot/data/flows.json`.
- **Persistent Conversations:** Adds a `conversations` table to the database (`talia_bot/db.py`) to persist user state, making flows robust across bot restarts.
- **Universal Handler:** Refactors `main.py` to use a `universal_handler` that processes all user input (text, audio, documents, callbacks) and routes it through the flow engine.
- **Asynchronous Refactoring:** Converts key modules (`vikunja.py`, `llm_engine.py`) to be fully asynchronous using `httpx` and `openai` async clients for better performance.
- **Non-Blocking Print Jobs:** Replaces the blocking `asyncio.sleep` in the print confirmation flow with a non-blocking `JobQueue` background task, ensuring the bot remains responsive.
- **New Modules:** Adds `mailer.py`, `imap_listener.py`, and `transcription.py` to support the print and audio transcription flows.
- **Updated Documentation:** The `README.md` and `.env.example` have been comprehensively updated to reflect the new architecture, configuration, and setup instructions.
2025-12-21 02:58:30 +00:00
google-labs-jules[bot]
5f048a31b2 feat: implement IMAP confirmation loop for print flow
Adds a confirmation loop to the printing feature.

- Creates a new `imap_listener.py` module to check for confirmation emails from the printer.
- Updates `main.py` to use a JSON payload in the email subject, containing a unique `job_id` and the `telegram_id` of the user.
- After sending a print job, the bot now waits for a specified time and then checks the IMAP inbox for a matching confirmation.
- Notifies the user via Telegram whether the print job was successful or if a confirmation was not received.
- Updates `flows.json` with a clearer message for the user during the print process.
2025-12-20 23:26:18 +00:00
google-labs-jules[bot]
b0e7209653 feat: implement JSON-driven conversational flow engine
Replaces hardcoded ConversationHandlers with a generic flow engine that reads conversation definitions from talia_bot/data/flows.json.

- Adds a 'conversations' table to the database to persist user state, making flows robust against restarts.
- Implements a central 'universal_handler' in main.py to process all user inputs (text, voice, callbacks, documents) through the new engine.
- Refactors Vikunja, LLM, and Calendar modules to be asynchronous and support the new architecture.
- Adds a new 'transcription' module for OpenAI Whisper and a 'mailer' module for the print flow.
- Implements the full logic for all specified user flows, including project/task management, calendar blocking, idea capture (with branching logic), and the RAG-based client sales funnel.
- Cleans up legacy code and handlers.
2025-12-20 22:55:50 +00:00
google-labs-jules[bot]
da790b8afc refactor: Overhaul project structure and role management
This commit implements the first phase of the new architectural vision for the Talia Bot.

Key changes include:
- Renamed the main application directory from `app` to `talia_bot` and updated all associated imports and configurations (`Dockerfile`, tests).
- Replaced the static, `.env`-based permission system with a dynamic, database-driven role management system.
- Introduced a `db.py` module to manage a SQLite database (`users.db`) for user persistence.
- Updated `identity.py` to fetch roles ('admin', 'crew', 'client') from the database.
- Rewrote the `README.md` and `.env.example` to align with the new project specification.
- Refactored the LLM module into the new `modules` structure.
2025-12-20 20:33:59 +00:00