feat: per-category greeting menu in bot config
Add a "Por Categoría" tab in the bot config UI where each permission category (1, 2, 3) can be assigned its own greeting button menu. When a user writes without an active context, the bot shows the menu configured for their category instead of falling through to the global greeting text. NormalBot.process() now checks per_type[X].greeting_menu first, which directly references a menu key and serves as both greeting and fallback for that category. Fully backward-compatible with existing greeting_flow. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
0b851208ea
commit
32e2a2a82e
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user