@ -11,6 +11,7 @@ This service provides a WhatsApp interface for task management within WhatsApp g
- Integrates with Evolution API for WhatsApp connectivity.
- Sends direct messages to acknowledge the creator and notify each assignee; includes mentions with phone numbers for quick action.
- DM-only responses: the bot does not post messages in groups; all outputs are sent via DM to the author (except the optional creation summary below).
- DM reminders: opt-in daily/weekly configured via "/t configurar"; runs at local TZ time (default Europe/Madrid), skips when no tasks and avoids duplicates per day.
- Advanced listings: "/t ver" supports scopes "grupo", "mis", "sin" and "todos" with pagination ("… y X más").
- Complete tasks: "/t x <id>" (aliases: hecho, completar, done) with compact DM feedback.
- Claim/unassign tasks: "/t tomar <id>" and "/t soltar <id>" with compact DM feedback.
@ -119,6 +120,7 @@ Estado: la tabla response_queue ya está creada e incluida en los tests de DB.
- Task persistence service (`src/tasks/service.ts`) with `created_by` and assignment inserts in a transaction; supports DB injection for tests.
- Response queue persistente con workers en background y envío vía Evolution API (`src/services/response-queue.ts`), persistiendo metadata `{ mentioned: [...] }` y enviándola como `mentioned` en el payload, con reintentos (backoff exponencial + jitter), recuperación de `processing` y limpieza/retención.
- Contacts service and friendly names: `ContactsService` resolves display names via webhooks (CONTACTS_UPDATE/CHATS_UPDATE) and Evolution API fallback; used to render names in outgoing texts (falls back to numbers). Skips network calls under NODE_ENV=test for fast and isolated unit tests.
- Reminders by DM: user preferences in `user_preferences` (reminder_freq: off|daily|weekly; reminder_time; last_reminded_on), `RemindersService` running minutely (disabled in tests), daily and weekly (Mondays 08:30) summaries, skips when no tasks, compact message with “… y X más”. Command “/t configurar daily|weekly|off” with DM confirmation. Unit tests included.
- Notification UX: Always send DM acknowledgment to the creator in a single line (format: ✅ Tarea <id> creada: "description"), DM to each assignee (excluding the creator); optional group notification controlled by `NOTIFY_GROUP_ON_CREATE` (default false) with proper mentions.
- Natural date tokens support (“hoy”/“mañana”) with TZ configurable (env TZ; default Europe/Madrid) in task creation.
- Unified dd/MM date formatting across outgoing texts.
@ -183,10 +185,10 @@ bun test
## 📅 Roadmap & Priorities (Updated Plan)
### MVP — Próximos pasos (prioridad actual)
1) Recordatorios diarios por DM: preferencia por usuario (daily|off, por defecto off), hora fija local (p. ej., 08:30 TZ), un DM con resumen compacto de “tus tareas”.
1) Afinar recordatorios por DM (daily/weekly): encabezados, hora configurable y pequeños ajustes de formato.
2) Refinar ContactsService: mejorar heurística de nombre, invalidación temprana en CHATS_UPDATE/CONTACTS_UPDATE, TTL configurable, robustez ante fallos, sin llamadas de red en tests.
3) Sincronización mínima de miembros: obtener y cachear miembros de grupos activos con TTL, uso no bloqueante; base para futuras validaciones/UX.
4) Ampliar test suite: cubrir recordatorios, actualización de nombres, sync de miembros y casos extremos de ResponseQueue.
4) Ampliar test suite: actualización de nombres, sync de miembros y casos extremos de ResponseQueue.
### Phase 1: User & Group Foundation (Highest Priority - In Progress)
- [x] **Create WhatsApp ID Normalization Utility:** (`src/utils/whatsapp.ts`) Handle different ID formats.
@ -219,7 +221,7 @@ bun test
- Etapa 4 — Limpieza/retención (Completada)
### Phase 5: Advanced Features (Low Priority)
- [ ] Add task reminders system.
- [x] Add task reminders system (daily/weekly) with user preferences and scheduler.
- All unit tests passing. Added unit tests for CommandService (date parsing "hoy/mañana", DM help, dd/MM formatting, default assignment rules).
- All unit tests passing. Added unit tests for CommandService (date parsing "hoy/mañana", DM help, dd/MM formatting, default assignment rules) y para RemindersService (daily/weekly, duplicados por día, hora/TZ, “… y X más”) y configuración de recordatorios.
- Tests de integración para validaciones de usuarios
- **Testing**
- Suite de tests unitarios con DB en memoria para aislamiento
- **Recordatorios por DM**
- Preferencias por usuario en user_preferences (reminder_freq: off|daily|weekly; reminder_time; last_reminded_on).
- Servicio RemindersService con tick minucioso (desactivado en tests), evita duplicados por día y respeta TZ.
- Soporta daily y weekly (lunes 08:30); no envía si no hay tareas; mensaje compacto con “… y X más”.
- Comando “/t configurar daily|weekly|off” con confirmación por DM.
- Pruebas unitarias para RemindersService y configuración de recordatorios.
## ⚠️ Funcionalidades Pendientes
- **Gestión de Tareas**
@ -53,10 +59,10 @@
- Refinar políticas de caché (TTL, invalidación) y ampliar compatibilidad de endpoints; en DM, WhatsApp no pinta chips de mención de terceros (limitación del cliente).
## ➡️ Próximos Pasos Prioritarios
1. Recordatorios diarios por DM (opt-in daily|off; hora fija local; resumen compacto).
1. Afinar recordatorios por DM (daily/weekly): encabezados, hora configurable y pequeños ajustes de formato.
2. Refinar ContactsService (caché/nombres; TTL configurable; robustez ante fallos; sin red en tests).
3. Sincronización mínima de miembros (cacheada; no bloqueante).
4. Ampliar test suite (recordatorios, contactos, sync de miembros, ResponseQueue).
4. Ampliar test suite (contactos, sync de miembros, ResponseQueue).
## 🐞 Problemas conocidos
- En chats privados, WhatsApp no renderiza chips de mención para terceros; en grupos sí se resuelven al nombre local de cada receptor. El bot incluye nombres en el texto cuando los conoce y números como @dígitos para acción rápida; no hay reescritura por receptor.
@ -74,7 +80,7 @@
- Etapa 4 — Limpieza/retención: COMPLETADA.
## Commit history and status
- Latest status: All unit tests passing; soporte de fechas naturales “hoy/mañana” con TZ configurable (por defecto Europe/Madrid) y formato unificado dd/MM en mensajes; ayuda por DM (“/t”, “/t ayuda”); listados ver grupo/mis/sin/todos; política solo DM; ACK al creador en una línea; notificación al grupo opcional desactivada; ContactsService evita llamadas de red en tests; nombres amigables integrados; rate limiting básico por usuario (15/min, configurable por env; desactivado en tests) implementado.
- Latest status: All unit tests passing; recordatorios por DM implementados (daily/weekly) con preferencia por usuario y comando “/t configurar”; soporte de fechas “hoy/mañana” con TZ configurable y formato dd/MM; ayuda por DM; listados ver grupo/mis/sin/todos; política solo DM; ACK al creador en una línea; notificación al grupo opcional desactivada; ContactsService evita llamadas de red en tests; nombres amigables integrados; rate limiting básico por usuario (15/min, configurable por env; desactivado en tests) implementado.