+
👥 Configuración por Categoría
+
Define qué menú de bienvenida ve cada categoría de usuario cuando escribe por primera vez o sin contexto activo. El menú debe ser de tipo botón.
+ {$categoryTabHtml}
+
+
🤖 Inteligencia Artificial
diff --git a/public/index.php b/public/index.php
index f7e4955..02d7246 100644
--- a/public/index.php
+++ b/public/index.php
@@ -410,6 +410,21 @@ $routes = [
$aiProvider = trim($_POST['ai_provider'] ?? '');
if ($aiProvider !== '') $config['ai_provider'] = $aiProvider;
+ // Per-category menus
+ $perTypeMenus = $_POST['per_type_menu'] ?? [];
+ $perType = [];
+ foreach ([1, 2, 3] as $cat) {
+ $mk = trim($perTypeMenus[$cat] ?? '');
+ if ($mk !== '') {
+ $perType[(string)$cat] = [
+ 'greeting_menu' => $mk,
+ 'greeting' => '',
+ 'fallback' => '',
+ ];
+ }
+ }
+ if (!empty($perType)) $config['per_type'] = $perType;
+
// General
$greeting = trim($_POST['greeting'] ?? '');
if ($greeting !== '') $config['greeting'] = $greeting;
diff --git a/services/NormalBot.php b/services/NormalBot.php
index 1038875..ac29eeb 100644
--- a/services/NormalBot.php
+++ b/services/NormalBot.php
@@ -46,6 +46,13 @@ class NormalBot
return null;
}
+ // Per-type greeting_menu: direct menu for this category (greeting + fallback in one)
+ $greetingMenuKey = $perType['greeting_menu'] ?? null;
+ if ($greetingMenuKey !== null && $currentNode === null && isset($menus[$greetingMenuKey])) {
+ ConversationContext::updateNode($ctxId, null);
+ return self::buildMenuResponse($menus[$greetingMenuKey], $context['from'], $company);
+ }
+
$greeting = $perType['greeting'] ?? $config['greeting'] ?? null;
if ($greeting !== null && $currentNode === null) {
$greetingFlowId = $perType['greeting_flow'] ?? 'greeting';
@@ -65,6 +72,12 @@ class NormalBot
return self::handleFlow($flows[$fallbackFlowId], $context, $company, $ctxId, $menus);
}
+ // greeting_menu also serves as fallback when nothing else matched
+ if ($greetingMenuKey !== null && isset($menus[$greetingMenuKey])) {
+ ConversationContext::updateNode($ctxId, null);
+ return self::buildMenuResponse($menus[$greetingMenuKey], $context['from'], $company);
+ }
+
$fallback = $perType['fallback'] ?? $config['fallback'] ?? null;
if ($fallback !== null) {
ConversationContext::updateNode($ctxId, null);