fix: fallback_flow por categoria, menu directo en saludo/fallback

This commit is contained in:
Lizandro Guarnizo
2026-06-27 18:53:41 -05:00
parent 02108b7ffa
commit 932a7a78a7
2 changed files with 26 additions and 10 deletions
+19 -10
View File
@@ -83,7 +83,7 @@ $menuConfig = [
],
],
'flows' => [
'show_main_menu' => ['type' => 'menu', 'menu' => 'show_main_menu'],
'show_main_menu' => ['type' => 'menu', 'menu' => 'show_menu_cat2'],
'recibir_info' => ['type' => 'function', 'function' => 'forward_to_ai'],
'descargar_informes' => ['type' => 'menu', 'menu' => 'submenu_informes'],
'menu_mixto' => ['type' => 'menu', 'menu' => 'menu_mixto'],
@@ -98,15 +98,18 @@ $menuConfig = [
],
'per_type' => [
'3' => [
'greeting' => '¡Bienvenido! Escribe *menu* para ver las opciones disponibles.',
'fallback' => 'No entendí. Escribe *menu* para ver las opciones disponibles.',
'greeting_flow' => 'show_main_menu',
'fallback_flow' => 'show_main_menu',
'greeting' => null,
'fallback' => null,
],
'1' => [
'greeting' => '¡Bienvenido! Escribe *menu* para recibir información.',
'fallback' => 'Escribe *menu* para recibir información.',
'greeting_flow' => 'show_menu_cat1',
'fallback_flow' => 'show_menu_cat1',
'greeting' => null,
'fallback' => null,
'commands' => [
'menu' => 'show_menu_cat1',
'info' => 'recibir_info_cat1',
],
'menus' => [
'show_menu_cat1' => [
@@ -128,14 +131,16 @@ $menuConfig = [
'flows' => [
'show_menu_cat1' => ['type' => 'menu', 'menu' => 'show_menu_cat1'],
'recibir_info_cat1' => ['type' => 'function', 'function' => 'forward_to_ai'],
'show_main_menu' => ['type' => 'menu', 'menu' => 'show_menu_cat1'],
],
],
'2' => [
'greeting' => '¡Bienvenido! Escribe *menu* para descargar informes.',
'fallback' => 'Escribe *menu* para descargar informes.',
'greeting_flow' => 'show_menu_cat2',
'fallback_flow' => 'show_menu_cat2',
'greeting' => null,
'fallback' => null,
'commands' => [
'menu' => 'show_menu_cat2',
'informes' => 'descargar_informes',
'menu' => 'show_menu_cat2',
],
'menus' => [
'show_menu_cat2' => [
@@ -154,6 +159,10 @@ $menuConfig = [
],
],
],
'flows' => [
'show_menu_cat2' => ['type' => 'menu', 'menu' => 'show_menu_cat2'],
'show_main_menu' => ['type' => 'menu', 'menu' => 'show_menu_cat2'],
],
],
],
];
+7
View File
@@ -59,8 +59,15 @@ class NormalBot
return $response;
}
$fallbackFlowId = $perType['fallback_flow'] ?? $config['fallback_flow'] ?? null;
if ($fallbackFlowId !== null && isset($flows[$fallbackFlowId])) {
ConversationContext::updateNode($ctxId, $fallbackFlowId);
return self::handleFlow($flows[$fallbackFlowId], $context, $company, $ctxId);
}
$fallback = $perType['fallback'] ?? $config['fallback'] ?? null;
if ($fallback !== null) {
ConversationContext::updateNode($ctxId, null);
return self::sendText($fallback, $context['from'], $company);
}