diff --git a/src/services/command.ts b/src/services/command.ts index e1a4613..6a7ea35 100644 --- a/src/services/command.ts +++ b/src/services/command.ts @@ -94,6 +94,19 @@ export class CommandService { .map(j => normalizeWhatsAppId(j)) .filter((id): id is string => !!id) )); + // Detectar también tokens de texto que empiezan por '@' como posibles asignados + const atTokenCandidates = tokens.slice(2) + .filter(t => t.startsWith('@')) + .map(t => t.replace(/^@+/, '')); + const normalizedFromAtTokens = Array.from(new Set( + atTokenCandidates + .map(v => normalizeWhatsAppId(v)) + .filter((id): id is string => !!id) + )); + const combinedAssigneeCandidates = Array.from(new Set([ + ...mentionsNormalizedFromContext, + ...normalizedFromAtTokens + ])); const { description, dueDate } = this.parseNueva(trimmed, mentionsNormalizedFromContext); @@ -106,7 +119,7 @@ export class CommandService { // Normalizar menciones y excluir duplicados y el número del bot const botNumber = process.env.CHATBOT_PHONE_NUMBER || ''; const assigneesNormalized = Array.from(new Set( - mentionsNormalizedFromContext + combinedAssigneeCandidates .filter(id => !botNumber || id !== botNumber) ));