From 6e89b1868bb678c9cd7cfc73df0b26b0400e17a6 Mon Sep 17 00:00:00 2001 From: Lizandro Guarnizo <77708265+lizandrogd@users.noreply.github.com> Date: Sat, 24 Jan 2026 01:56:24 -0500 Subject: [PATCH] Update BotService.php --- services/BotService.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/services/BotService.php b/services/BotService.php index 085c4d2..17571fa 100644 --- a/services/BotService.php +++ b/services/BotService.php @@ -222,11 +222,13 @@ class BotService { */ private function processSpecialCommands($phoneNumber, $messageText) { $command = strtolower($messageText); + try { error_log("[BotService] processSpecialCommands - command={$command} phone={$phoneNumber}"); } catch (Throwable $t) {} switch ($command) { case 'menu': case 'menú': case 'inicio': + try { error_log("[BotService] processSpecialCommands - detected MENU command, calling showMainMenu for phone={$phoneNumber}"); } catch (Throwable $t) {} $this->showMainMenu($phoneNumber); return true; @@ -250,13 +252,16 @@ class BotService { * Mostrar menú principal */ private function showMainMenu($phoneNumber) { + try { error_log("[BotService] showMainMenu - phone={$phoneNumber} fetching root menu"); } catch (Throwable $t) {} $mainMenu = $this->db->fetch( "SELECT * FROM menus WHERE is_root = 1 AND is_active = 1 ORDER BY order_position LIMIT 1" ); + try { error_log("[BotService] showMainMenu - fetched root menu=" . json_encode($mainMenu)); } catch (Throwable $t) {} if ($mainMenu) { $this->showMenu($phoneNumber, $mainMenu['id']); } else { + try { error_log("[BotService] showMainMenu - no root menu found for phone={$phoneNumber}"); } catch (Throwable $t) {} $this->whatsappService->sendTextMessage( $phoneNumber, "❌ No hay menús configurados. Contacte con soporte." @@ -268,13 +273,16 @@ class BotService { * Mostrar menú específico */ private function showMenu($phoneNumber, $menuId) { + try { error_log("[BotService] showMenu - phone={$phoneNumber} menuId={$menuId} fetching menu"); } catch (Throwable $t) {} // Obtener información del menú $menu = $this->db->fetch( "SELECT * FROM menus WHERE id = :id AND is_active = 1", ['id' => $menuId] ); + try { error_log("[BotService] showMenu - fetched menu=" . json_encode($menu)); } catch (Throwable $t) {} if (!$menu) { + try { error_log("[BotService] showMenu - menu not found id={$menuId} phone={$phoneNumber}"); } catch (Throwable $t) {} $this->whatsappService->sendTextMessage( $phoneNumber, "❌ Menú no encontrado." @@ -287,6 +295,7 @@ class BotService { "SELECT * FROM menu_options WHERE menu_id = :menu_id AND is_active = 1 ORDER BY option_number", ['menu_id' => $menuId] ); + try { error_log("[BotService] showMenu - menuId={$menuId} options_count=" . count($options)); } catch (Throwable $t) {} if (empty($options)) { $this->whatsappService->sendTextMessage(