From e9bbf8efce238713198045d29e2f3695c5e9e33b Mon Sep 17 00:00:00 2001 From: Lizandro Guarnizo <77708265+lizandrogd@users.noreply.github.com> Date: Tue, 30 Jun 2026 16:54:47 -0500 Subject: [PATCH] feat: per-type greeting_menu takes priority over global show_main_menu When user says "menu/inicio/volver", bot now shows the menu configured for their category (per_type.greeting_menu) instead of the global show_main_menu. Same redirect applies to interactive button taps. Co-Authored-By: Claude Sonnet 4.6 --- services/NormalBot.php | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/services/NormalBot.php b/services/NormalBot.php index 74af543..7dc46fd 100644 --- a/services/NormalBot.php +++ b/services/NormalBot.php @@ -30,6 +30,12 @@ class NormalBot } if ($dirty) ConversationContext::updateMetadata($ctxId, $m); + // "menu/inicio/volver" → prefer per-type greeting_menu over global show_main_menu + $greetingMenuKey = $perType['greeting_menu'] ?? null; + if ($action === 'show_main_menu' && $greetingMenuKey && isset($menus[$greetingMenuKey])) { + $action = $greetingMenuKey; + } + ConversationContext::updateNode($ctxId, $action); // Commands that match a flow if (isset($flows[$action])) { @@ -943,9 +949,19 @@ class NormalBot } // Direct flow match (button id == flow key) - if (isset($flows[$input])) { - ConversationContext::updateNode($ctxId, $input); - return self::handleFlow($flows[$input], $context, $company, $ctxId, $menus); + // Redirect show_main_menu → per-type greeting_menu if configured + $resolvedInput = $input; + $greetingMenuKey = $perType['greeting_menu'] ?? null; + if ($resolvedInput === 'show_main_menu' && $greetingMenuKey && isset($menus[$greetingMenuKey])) { + $resolvedInput = $greetingMenuKey; + } + if (isset($flows[$resolvedInput])) { + ConversationContext::updateNode($ctxId, $resolvedInput); + return self::handleFlow($flows[$resolvedInput], $context, $company, $ctxId, $menus); + } + if (isset($menus[$resolvedInput])) { + ConversationContext::updateNode($ctxId, $resolvedInput); + return self::buildMenuResponse($menus[$resolvedInput], $context['from'], $company); } return null;