fix: navegación — atras/cancelar/regresar + NLU desde menús activos
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
79d2399ddf
commit
09db466fa6
+14
-2
@@ -71,9 +71,13 @@ class NormalBot
|
||||
}
|
||||
|
||||
// 3. Active node — resume conversation
|
||||
// Menu-type nodes let NLU act on free text; only re-show if NLU doesn't handle it.
|
||||
$sentinels = ['collecting', '__greeted'];
|
||||
if ($currentNode !== null && !in_array($currentNode, $sentinels, true) && isset($flows[$currentNode])) {
|
||||
return self::handleFlow($flows[$currentNode], $context, $company, $ctxId, $menus);
|
||||
$isMenuNode = ($flows[$currentNode]['type'] ?? '') === 'menu';
|
||||
if (!$isMenuNode) {
|
||||
return self::handleFlow($flows[$currentNode], $context, $company, $ctxId, $menus);
|
||||
}
|
||||
}
|
||||
|
||||
// 4. Welcome message — shown once for brand-new sessions before the category menu
|
||||
@@ -132,11 +136,19 @@ class NormalBot
|
||||
}
|
||||
}
|
||||
if ($route['action'] === 'chat' && ($route['text'] ?? '') !== '') {
|
||||
ConversationContext::updateNode($ctxId, null);
|
||||
// Preserve node when inside a menu so state isn't lost
|
||||
$inMenu = $currentNode !== null && !in_array($currentNode, $sentinels, true)
|
||||
&& isset($flows[$currentNode]) && ($flows[$currentNode]['type'] ?? '') === 'menu';
|
||||
if (!$inMenu) ConversationContext::updateNode($ctxId, null);
|
||||
return self::sendText($route['text'], $context['from'], $company);
|
||||
}
|
||||
}
|
||||
|
||||
// Re-show current menu when NLU didn't route anything
|
||||
if ($currentNode !== null && !in_array($currentNode, $sentinels, true) && isset($flows[$currentNode])) {
|
||||
return self::handleFlow($flows[$currentNode], $context, $company, $ctxId, $menus);
|
||||
}
|
||||
|
||||
// 7. Fallback flow
|
||||
$fallbackFlowId = $perType['fallback_flow'] ?? $config['fallback_flow'] ?? null;
|
||||
if ($fallbackFlowId !== null && isset($flows[$fallbackFlowId])) {
|
||||
|
||||
Reference in New Issue
Block a user