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 <noreply@anthropic.com>
This commit is contained in:
Lizandro Guarnizo
2026-06-30 16:54:47 -05:00
co-authored by Claude Sonnet 4.6
parent 6bac0ee823
commit e9bbf8efce
+19 -3
View File
@@ -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;