fix: el NLU nunca atendia texto libre tras un informe; api_base_url apunta al ERP
preservingReset dejaba current_node en NULL, que process() no distingue de una sesion nueva: se redisparaba el flujo de bienvenida (ask_finca), skip_if_set lo saltaba al menu principal y el paso de NLU nunca corria. Por eso "elegir otra finca" o "informe de mantenimiento de plateo" devolvian el menu. Ahora queda el centinela __greeted, que marca sesion iniciada. api_base_url guardaba el Graph API de WhatsApp, pero WhatsAppSender lo tiene hardcodeado y todos los demas consumidores esperan el ERP. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
1b797df2f0
commit
ce5d4ef2b2
@@ -1247,6 +1247,9 @@ class NormalBot
|
||||
if (!empty($keep)) {
|
||||
ConversationContext::updateMetadata($ctxId, $keep);
|
||||
}
|
||||
// Sesión ya iniciada, no nueva: con current_node = null los pasos de
|
||||
// bienvenida se redisparan y el texto libre nunca llega al NLU.
|
||||
ConversationContext::updateNode($ctxId, '__greeted');
|
||||
}
|
||||
|
||||
// ── Resolves fixed-mode var values ───────────────────────────────────────
|
||||
|
||||
@@ -499,7 +499,7 @@ $companies = [
|
||||
'display_name' => 'Rosa Blanca',
|
||||
'phone_number_id' => '1168511569675820',
|
||||
'display_phone' => '',
|
||||
'api_base_url' => 'https://graph.facebook.com/v22.0',
|
||||
'api_base_url' => 'https://app.palmas360.com/rosablanca', // ERP, no el Graph API (WhatsAppSender lo tiene hardcodeado)
|
||||
'api_key' => 'EAAqbNQQekwUBRm8ZAAfCvXZAsxcM1BTkiHjVJYeOfXYCg5t4qYtBL7ap2IdHGa1iXclZBO47gZBshYZBAlQRuUvgSib2Owh7gPnAWfNlHXZAT61ccElXoihuXuEuy0qLiB95tDhLMWPqoKYuDwAHCU78RQxoi1nzz1OsOY40EK7U2tKZBVuZABQZCJctZBrLK7rRiC7AZDZD',
|
||||
'bot_type' => 'normal',
|
||||
'requires_approval' => 0,
|
||||
@@ -511,7 +511,7 @@ $companies = [
|
||||
'display_name' => 'Palmas360 Test',
|
||||
'phone_number_id' => '1168511569675820',
|
||||
'display_phone' => '',
|
||||
'api_base_url' => 'https://graph.facebook.com/v22.0',
|
||||
'api_base_url' => 'https://app.palmas360.com/rosablanca', // ERP, no el Graph API (WhatsAppSender lo tiene hardcodeado)
|
||||
'api_key' => 'EAAqbNQQekwUBRm8ZAAfCvXZAsxcM1BTkiHjVJYeOfXYCg5t4qYtBL7ap2IdHGa1iXclZBO47gZBshYZBAlQRuUvgSib2Owh7gPnAWfNlHXZAT61ccElXoihuXuEuy0qLiB95tDhLMWPqoKYuDwAHCU78RQxoi1nzz1OsOY40EK7U2tKZBVuZABQZCJctZBrLK7rRiC7AZDZD',
|
||||
'bot_type' => 'normal',
|
||||
'requires_approval' => 0,
|
||||
|
||||
@@ -118,6 +118,33 @@ foreach (['2', '3'] as $cat) {
|
||||
check("cat {$cat}: 'salir' va a la raíz", $cmds['salir'] ?? null, 'show_main_menu');
|
||||
}
|
||||
|
||||
echo "\nQuién atiende el texto libre\n";
|
||||
|
||||
/**
|
||||
* Espejo del orden de process(): qué paso agarra un mensaje de texto que no es
|
||||
* comando. Lo que importa es que el NLU llegue a opinar cuando la sesión ya
|
||||
* empezó — si no, "quiero informe de plateo" rebota al menú.
|
||||
*/
|
||||
$atiende = function (?string $nodo, $greeting, ?string $greetingMenu, array $flows): string {
|
||||
$centinelas = ['collecting', '__greeted'];
|
||||
if ($nodo !== null && !in_array($nodo, $centinelas, true) && isset($flows[$nodo])) {
|
||||
if (($flows[$nodo]['type'] ?? '') !== 'menu') return 'nodo-activo';
|
||||
}
|
||||
if ($greetingMenu !== null && $nodo === null) return 'menu-bienvenida';
|
||||
if ($greeting !== null && $nodo === null) return 'flujo-bienvenida';
|
||||
return 'nlu';
|
||||
};
|
||||
|
||||
// Cat 2/3 usan greeting = '' para disparar ask_finca en el primer mensaje
|
||||
check('sesión nueva pide la finca',
|
||||
$atiende(null, '', null, $flows), 'flujo-bienvenida');
|
||||
check('tras un informe el NLU atiende',
|
||||
$atiende('__greeted', '', null, $flows), 'nlu');
|
||||
check('parado en un menú el NLU atiende',
|
||||
$atiende('submenu_ciclos', '', null, $flows), 'nlu');
|
||||
check('en medio de una lista no interfiere',
|
||||
$atiende('collecting', '', null, $flows), 'nlu');
|
||||
|
||||
echo "\nask_finca\n";
|
||||
$af = $flows['ask_finca'];
|
||||
check('no repregunta si ya hay finca', $af['skip_if_set'] ?? false, true);
|
||||
|
||||
Reference in New Issue
Block a user