diff --git a/services/NormalBot.php b/services/NormalBot.php index 6de1b81..be0a8d3 100644 --- a/services/NormalBot.php +++ b/services/NormalBot.php @@ -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 ─────────────────────────────────────── diff --git a/setup/seed_palmas.php b/setup/seed_palmas.php index 612892c..d3d56a6 100644 --- a/setup/seed_palmas.php +++ b/setup/seed_palmas.php @@ -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, diff --git a/setup/test_navegacion.php b/setup/test_navegacion.php index 219ac9d..e950918 100644 --- a/setup/test_navegacion.php +++ b/setup/test_navegacion.php @@ -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);