+
@@ -4781,6 +4795,12 @@ function saveConfig() {
fd.append('approval_webhook', fullConfig.approval_webhook || '');
fd.append('ignore_prefixes', (fullConfig.ignore_prefixes || []).join('\\n'));
+ // Per-category menus — read from DOM so they're preserved on every AJAX save
+ [1, 2, 3].forEach(cat => {
+ const sel = document.querySelector('select[name="per_type_menu[' + cat + ']"]');
+ if (sel) fd.append('per_type_menu[' + cat + ']', sel.value);
+ });
+
fetch('/admin/bot-config/save', {
method: 'POST',
body: fd
diff --git a/public/index.php b/public/index.php
index fb84127..dbb0087 100644
--- a/public/index.php
+++ b/public/index.php
@@ -562,6 +562,8 @@ $routes = [
}
$approvalWebhook = trim($_POST['approval_webhook'] ?? '');
if ($approvalWebhook !== '') $config['approval_webhook'] = $approvalWebhook;
+ $welcomeMenu = trim($_POST['welcome_menu'] ?? '');
+ if ($welcomeMenu !== '') $config['welcome_menu'] = $welcomeMenu;
CompanyRepository::save(['id' => $companyId, 'config_json' => json_encode($config, JSON_UNESCAPED_UNICODE)]);
header('Location: /admin/bot-config?id=' . $companyId . '&msg=saved');
diff --git a/services/NormalBot.php b/services/NormalBot.php
index 7dc46fd..9d2ca4c 100644
--- a/services/NormalBot.php
+++ b/services/NormalBot.php
@@ -76,7 +76,14 @@ class NormalBot
return self::handleFlow($flows[$currentNode], $context, $company, $ctxId, $menus);
}
- // 4. Per-type greeting menu — only for brand-new sessions (currentNode === null)
+ // 4. Welcome message — shown once for brand-new sessions before the category menu
+ $welcomeMenuKey = $config['welcome_menu'] ?? null;
+ if ($welcomeMenuKey && $currentNode === null && isset($menus[$welcomeMenuKey])) {
+ ConversationContext::updateNode($ctxId, '__greeted');
+ return self::buildMenuResponse($menus[$welcomeMenuKey], $context['from'], $company);
+ }
+
+ // 4b. Per-type greeting menu — only for brand-new sessions (currentNode === null)
$greetingMenuKey = $perType['greeting_menu'] ?? null;
if ($greetingMenuKey !== null && $currentNode === null && isset($menus[$greetingMenuKey])) {
ConversationContext::updateNode($ctxId, '__greeted'); // sentinel: evita re-envío del menú