Commit Graph

63 Commits

Author SHA1 Message Date
Marco Gallegos
c55bf923bc Merge pull request #26 from marcogll/feature/flow-engine-implementation-15654864159042246464
Feature/flow engine implementation 15654864159042246464
2025-12-20 21:46:44 -06:00
google-labs-jules[bot]
41db01265b fix: Add missing data files to PR
The previous commits were missing the newly created data files (`services.json` and the `flows/` directory). This commit adds these untracked files to the branch to make the implementation complete and functional.
2025-12-21 03:46:23 +00:00
Marco Gallegos
46e65710a8 Merge pull request #25 from marcogll/main
Flows engine
2025-12-20 21:46:03 -06:00
Marco Gallegos
7da934088a Merge pull request #24 from marcogll/feature/flow-engine-implementation-15654864159042246464
refactor: Modularize conversational flows into individual files
2025-12-20 21:38:33 -06:00
google-labs-jules[bot]
12ae335e39 refactor: Modularize conversational flows into individual files
This commit refactors the conversational flow architecture by splitting the monolithic `flows.json` file into individual JSON files for each flow, located in the new `talia_bot/data/flows/` directory.

Key changes:
- **Modular Flow Files:** Each conversational flow is now an independent JSON file (e.g., `admin_check_agenda.json`), improving maintainability and making it easier to modify or add new flows.
- **Updated Flow Engine:** The `FlowEngine` in `talia_bot/modules/flow_engine.py` has been updated to dynamically load all `.json` files from the `talia_bot/data/flows/` directory at startup.
- **Removed Monolithic File:** The old `talia_bot/data/flows.json` file has been deleted, completing the transition to the new modular structure.

This change enhances the organization of the project and aligns with the user's request for easier modification of individual flows.
2025-12-21 03:23:24 +00:00
Marco Gallegos
54a75f0402 Merge pull request #23 from marcogll/feature/flow-engine-implementation-15654864159042246464
feat: Implement JSON-driven conversational flow engine
2025-12-20 21:05:34 -06: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
Marco Gallegos
4582747851 Merge pull request #22 from marcogll/feature/flow-engine-implementation-15654864159042246464
feat: implement JSON-driven conversational flow engine (final)
2025-12-20 19:56:42 -06:00
google-labs-jules[bot]
6ebe452c05 feat: implement JSON-driven conversational flow engine (final)
This commit delivers the complete and final implementation of the new conversational flow engine, addressing all feedback from previous code reviews.

- **Adds Critical Data Files:** Creates `talia_bot/data/flows.json` and `talia_bot/data/services.json`, resolving the critical blocking issue and making the bot fully functional.
- **Corrects Vikunja Flow:** The `admin_project_management` flow in `flows.json` now correctly includes a step to select a task after selecting a project. The resolution logic in `main.py` is updated to use the correct `task_id`.
- **Implements All Resolutions:** The `handle_flow_resolution` function in `main.py` is now complete, with functional logic for all resolution types, including robust date/time parsing for calendar events and branching logic for idea capture.
- **Fixes and Cleanup:** Corrects the OpenAI API call in the `transcription.py` module and removes all legacy `ConversationHandler` code from `vikunja.py` and `main.py`.
- **Configuration and Docs:** The project configuration (`config.py`, `.env.example`) and documentation (`README.md`) are fully updated to reflect the final state of the new architecture.
2025-12-21 01:28:24 +00:00
Marco Gallegos
813acb3a36 Merge pull request #21 from marcogll/feature/flow-engine-implementation-15654864159042246464
Feature/flow engine implementation 15654864159042246464
2025-12-20 17:31:51 -06: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]
43e37c6ae5 feat: implement JSON-driven conversational flow engine and update docs
Replaces the hardcoded ConversationHandler system with a generic, data-driven flow engine. This new architecture reads conversation logic from `talia_bot/data/flows.json`, enabling flexible and maintainable conversational flows for all user roles.

- **Core Engine:** Introduces `flow_engine.py` to manage conversation state, step progression, and data collection. Adds a `conversations` table to the database for robust state persistence.
- **Unified Handler:** Refactors `main.py` to use a `universal_handler` that processes all user inputs (text, voice, callbacks, documents) through the new engine.
- **Async Integrations:** All external service modules (`vikunja.py`, `llm_engine.py`, `calendar.py`) are now fully asynchronous. New modules for `transcription.py` (Whisper) and `mailer.py` (SMTP) have been added.
- **Complete Flow Logic:** Implements the full business logic for all specified user flows, including project/task management with correct task selection, calendar event creation with date parsing, idea capture with branching logic (Task vs. Note), and the RAG-based client sales funnel.
- **Configuration:** Adds new environment variables like `VIKUNJA_INBOX_PROJECT_ID` for better configurability.
- **Documentation:** Completely rewrites `README.md` to accurately reflect the new architecture, project structure, and setup instructions.
- **Cleanup:** Removes all legacy `ConversationHandler` code and unused functions.
2025-12-20 23:01:14 +00:00
Marco Gallegos
e49935b542 Merge pull request #20 from marcogll/feature/flow-engine-implementation-15654864159042246464
Implement Flow-Based Conversation Engine
2025-12-20 16:56:16 -06: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
Marco Gallegos
c6f46ab2c6 Merge pull request #19 from marcogll/feat/project-restructure-12016173615219522068
Refactor: Restructure Project and Implement DB-based Roles
2025-12-20 14:35:20 -06: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
Marco Gallegos
611120cef6 feat: update gitignore and refactor callback query dispatch with error handling 2025-12-18 16:03:00 -06:00
Marco Gallegos
05922b1e0b Merge pull request #18 from marcogll/feat/vikunja-admin-menu-14354086038768774668
feat: Fix admin menu and stabilize core functionality
2025-12-18 09:58:42 -06:00
Marco Gallegos
a1e35579a4 Merge branch 'main' into feat/vikunja-admin-menu-14354086038768774668 2025-12-18 09:58:34 -06:00
google-labs-jules[bot]
2f49596857 feat: Fix admin menu and stabilize core functionality
Fixes several critical bugs in the admin menu, including timeouts and unresponsive buttons caused by incorrect handling of asynchronous functions in the button dispatcher.

Restructures the admin menu into a primary and secondary menu for better user experience.

Corrects the "create tag" conversation handler to be initiated by a command, ensuring the conversation starts correctly.

Updates `tasks.md` to reflect the bug fixes and improvements.
2025-12-18 15:40:14 +00:00
Marco Gallegos
25d349f115 docs: Replace general development task tracking with a specific bot correction plan. 2025-12-18 09:31:39 -06:00
Marco Gallegos
9a83fb93bb feat: Add asynchronous support and improved logging/error handling for calendar functions, introduce a calendar debug script, and refactor role-based menu logic. 2025-12-18 09:24:54 -06:00
Marco Gallegos
54f4e9ee41 Merge pull request #17 from marcogll/feat/vikunja-admin-menu-14354086038768774668
Restructure Admin Menu and Enhance Vikunja Integration
2025-12-18 09:11:49 -06:00
google-labs-jules[bot]
c9ef9ab5b5 feat: Restructure admin menu and enhance Vikunja integration
Restructures the admin menu into a primary and secondary menu for better user experience.
The primary menu now shows the most common actions.
The secondary menu contains less frequent admin commands.

Refactors the Vikunja module to be triggered by a menu button instead of a command.
Adds "edit task" functionality to the Vikunja module.
Fixes a bug where the button dispatcher was calling a non-existent function.
2025-12-18 15:05:54 +00:00
Marco Gallegos
f15b4661d2 Merge pull request #16 from marcogll/feat/vikunja-integration-17177940012497540698
Implement Interactive Vikunja Task Management
2025-12-18 08:48:48 -06:00
google-labs-jules[bot]
d0879cc3d6 feat: Implement interactive Vikunja task management
This commit introduces a `ConversationHandler` for the `/vik` command, replacing the previous simple command.

The new implementation provides an interactive menu for users with admin permissions to:
- View their tasks from a hardcoded project (ID 1).
- Add new tasks to the same project.

The changes include:
- A new `ConversationHandler` in `app/modules/vikunja.py` to manage the interactive flow.
- Integration of the new handler in `app/main.py`.
- Removal of the old `/vik` command handler.
- A fix in `test_vikunja.py` to correctly load environment variables.
2025-12-18 14:47:41 +00:00
Marco Gallegos
556fd8a3bd feat: Add Vikunja task management, refactor Google Calendar integration, and implement N8N webhook fallback. 2025-12-18 08:27:40 -06:00
Marco Gallegos
cab2008838 feat: Add standard .gitignore and .dockerignore files for project exclusion rules. 2025-12-18 00:27:20 -06:00
Marco Gallegos
96542bcd61 feat: Implement dynamic Google Calendar agenda, and configure OpenAI model, Calendly link, and daily summary schedule. 2025-12-18 00:23:11 -06:00
Marco Gallegos
e960538943 docs: Translate comments and logging messages to Spanish across various modules and the scheduler. 2025-12-18 00:17:14 -06:00
Marco Gallegos
ade8a5f98d Merge pull request #15 from marcogll/feat/create-tag-command-4960906393557654142
Feat/create tag command 4960906393557654142
2025-12-18 00:06:14 -06:00
google-labs-jules[bot]
7079348d00 docs: Add comprehensive comments and update README
This commit adds detailed inline comments and docstrings to all modules within the `app/modules/` directory to improve code clarity, readability, and maintainability.

It also updates the `README.md` file to include `create_tag.py` and `print.py` in the "Módulos Funcionales" section, ensuring the documentation is synchronized with the codebase.
2025-12-18 05:37:21 +00:00
google-labs-jules[bot]
02dba09599 docs: Add comments and document /create_tag command
This commit adds detailed inline comments to the `app/modules/create_tag.py` module to improve code clarity and maintainability.

It also updates the `README.md` file to include a new section documenting the functionality and usage of the `/create_tag` command.
2025-12-18 05:24:40 +00:00
Marco Gallegos
5327a078f9 Merge pull request #14 from marcogll/feat/create-tag-command-4960906393557654142
Add `/create_tag` command for generating NFC data
2025-12-17 22:42:24 -06:00
google-labs-jules[bot]
9e7e093409 feat: Add /create_tag command for generating NFC data
This commit introduces a new `/create_tag` command that initiates a conversational flow to collect user data and generate a Base64-encoded JSON string for NFC tag creation.

- Adds a new module `app/modules/create_tag.py` with a `ConversationHandler` to manage the multi-step data collection.
- Prompts the user for `name`, `num_emp`, `sucursal`, and `telegram_id`.
- Generates a Base64-encoded JSON string from the collected data.
- Integrates the new command into `app/main.py`.
2025-12-18 04:02:26 +00:00
Marco Gallegos
ce30e5591e ajsutes codex 2025-12-15 18:47:48 -06:00
Marco Gallegos
a598ef6916 Merge pull request #13 from marcogll/feature/implement-final-features-13803593538780194893
Implement LLM and Scheduler Modules
2025-12-15 18:34:59 -06:00
google-labs-jules[bot]
eb680edc54 feat: Implement LLM and scheduler modules
- Implement `llm.py` with OpenAI API integration for smart responses.
- Implement `scheduler.py` to send a daily summary to the bot owner using `python-telegram-bot`'s `JobQueue`.
- Integrate the scheduler into the main application.
- Add `pytz` as a new dependency.
- Update `tasks.md` to mark all tasks as complete.
2025-12-16 00:24:06 +00:00
Marco Gallegos
9654ba7dd5 Merge pull request #12 from marcogll/feat/add-print-command-8512170790091266484
feat: Add /print command for authorized users
2025-12-15 17:46:13 -06:00
google-labs-jules[bot]
48f932c134 feat: Add /print command for authorized users
This commit introduces a new `/print` command that is restricted to authorized users. The command displays non-sensitive configuration details to administrators.

The main changes are:
- Created `app/modules/print.py` to house the handler for the new command.
- The handler uses the existing `is_admin` function from `app/permissions.py` to check for authorization.
- The command displays the Timezone, Calendar ID, and n8n Webhook URL.
- Integrated the new command into `app/main.py`.
- Updated `tasks.md` to document the new feature.
2025-12-15 23:44:15 +00:00
Marco Gallegos
e4f058766c Merge pull request #11 from marcogll/feat/add-print-command-8512170790091266484
Add /print command for authorized users
2025-12-15 17:32:33 -06:00
Marco Gallegos
889f60997c Merge branch 'main' into feat/add-print-command-8512170790091266484 2025-12-15 17:32:20 -06:00
google-labs-jules[bot]
490f55bfcf feat: Add /print command for authorized users
This commit introduces a new `/print` command that is restricted to authorized users.

The main changes are:
- Created `app/modules/print.py` to house the handler for the new command.
- The handler uses the existing `is_admin` function from `app/permissions.py` to check for authorization.
- Integrated the new command into `app/main.py`.
- Updated `tasks.md` to document the new feature.
2025-12-15 23:31:39 +00:00
Marco Gallegos
93530967b1 Merge pull request #10 from marcogll/feature/google-calendar-integration-14767443416126099530
feat: Implement LLM and scheduler functionalities
2025-12-15 17:27:25 -06:00
google-labs-jules[bot]
99faa1eecb feat: Implement LLM and scheduler functionalities
This commit finalizes Phase 4 of the project by implementing the
LLM and scheduler integrations.

- Implements `get_smart_response` in `app/llm.py` to generate
  AI-powered responses using the OpenAI API.
- Implements a daily summary scheduler in `app/scheduler.py` using
  the `JobQueue` from `python-telegram-bot` for better integration
  with the application's event loop.
- Adds `get_events_for_day` to `app/calendar.py` to fetch daily
  events for the summary.
- Integrates the scheduler into the main application loop in
  `app/main.py`.
- Improves the date formatting in the daily summary for better
  readability.
- Updates `tasks.md` to reflect the completion of Phase 4.
2025-12-15 23:25:52 +00:00
Marco Gallegos
0e8cfef055 Merge pull request #9 from marcogll/feature/google-calendar-integration-14767443416126099530
feat: Implement Google Calendar Integration
2025-12-15 17:17:34 -06:00
google-labs-jules[bot]
2a8f8dd537 feat: Implement Google Calendar integration
- Implements `get_available_slots` to find open time slots.
- Implements `create_event` to schedule new events.
- Uses a service account for server-to-server authentication.
- Adds `GOOGLE_SERVICE_ACCOUNT_FILE` and `CALENDAR_ID` to the configuration.
- Updates `tasks.md` to reflect the completion of the integration.
- Includes error handling for Google Calendar API calls.
2025-12-15 21:57:08 +00:00
Marco Gallegos
6bdae0869c Merge pull request #8 from marcogll/feat/initial-project-structure-5769203822268670178
feat: Complete Phase 3 and refactor dispatcher
2025-12-15 15:47:24 -06:00
google-labs-jules[bot]
dd7ce72f8b feat: Complete Phase 3 and refactor dispatcher
- Implements the `admin` module with a system status placeholder.
- Enhances the `onboarding` module to provide a dedicated menu for the `admin` role.
- Refactors the `button` handler in `main.py` to use a scalable, dictionary-based dispatcher for all module integrations.
- Updates `tasks.md` to mark the completion of all Phase 3 modules.
2025-12-15 20:51:42 +00:00
Marco Gallegos
33c36a2b83 Merge pull request #7 from marcogll/feat/initial-project-structure-5769203822268670178
Feat/initial project structure 5769203822268670178
2025-12-15 14:42:16 -06:00