diff --git a/admin/v1/WpWebhook.php b/admin/v1/WpWebhook.php index 7a8ab81..ddeffe9 100644 --- a/admin/v1/WpWebhook.php +++ b/admin/v1/WpWebhook.php @@ -187,7 +187,7 @@ class WpWebhook } // Pre-menú multi-empresa: retorna true si la empresa quedó resuelta, false si hay que esperar al usuario - private static function handleMultiCompany(string $from, string $name, array $companies, string $rawText, string $phoneNumberId): bool + private static function handleMultiCompany(string $from, string $name, array $companies, string $rawText, string $phoneNumberId, string $msgType = 'text'): bool { // 1. El usuario tocó un botón de selección de empresa if (str_starts_with($rawText, '__co_')) { @@ -233,7 +233,8 @@ class WpWebhook } // 2. Keyword de reinicio → borrar sesión y mostrar pre-menú - if (self::isResetKeyword($rawText)) { + // Solo aplica para texto libre; las respuestas interactivas no son keywords + if ($msgType === 'text' && self::isResetKeyword($rawText)) { try { db()->prepare("DELETE FROM multi_company_sessions WHERE wa_number = ?")->execute([$from]); } catch (\PDOException $e) {} self::sendCompanyPreMenu($from, $phoneNumberId, $name, $companies); return false; @@ -418,7 +419,7 @@ class WpWebhook 'button' => $msg['button']['payload'] ?? $msg['button']['text'] ?? '', default => '', }; - if (!self::handleMultiCompany($from, $name, $matchedCompanies, $rawText, $phoneNumberId)) { + if (!self::handleMultiCompany($from, $name, $matchedCompanies, $rawText, $phoneNumberId, $type)) { continue; } self::log('INFO', "Número {$from} → empresa (multi-sel): " . (self::$currentCompany['name'] ?? '?'));