fix: salir button works, cap at 3 buttons, no AI error on unmatched input
- Add 'goodbye' function: resets context + sends farewell with menu hint - Add safety slice to 3 buttons in buildMenuResponse (WhatsApp hard limit) - In hybrid mode: when greeting_menu is configured for the user's category, use it as fallback instead of escalating to AI — prevents "Lo siento, tengo problemas..." from appearing when nothing matches - Expose buildGreetingMenu() as public for BotRouter access - DB: fixed submenu_informes and submenu_ciclos from 4→3 buttons, added salir flow (goodbye function) and salir/exit commands (company 2) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
32e2a2a82e
commit
b6a85c33f7
@@ -108,6 +108,21 @@ class BotRouter
|
||||
return $response;
|
||||
}
|
||||
|
||||
// Only escalate to AI if bot type truly needs it; avoid AI for menu-driven bots
|
||||
$config = self::getConfig($company);
|
||||
$permType = (string)($context['permission_type'] ?? 1);
|
||||
$perType = $config['per_type'][$permType] ?? [];
|
||||
|
||||
// If a greeting_menu is configured for this category, use it as fallback instead of AI
|
||||
$greetingMenuKey = $perType['greeting_menu'] ?? null;
|
||||
if ($greetingMenuKey !== null) {
|
||||
$menus = array_merge($config['menus'] ?? [], $perType['menus'] ?? []);
|
||||
if (isset($menus[$greetingMenuKey])) {
|
||||
self::log("NormalBot no manejó '{$input}' — mostrando menú de categoría en lugar de IA");
|
||||
return NormalBot::buildGreetingMenu($menus[$greetingMenuKey], $context['from'], $company);
|
||||
}
|
||||
}
|
||||
|
||||
self::log("NormalBot no manejó '{$input}', escalando a IA");
|
||||
return self::runAiBot($company, $context, $input);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user