feat: two-message post-selection flow in multi-company pre-menu
After user selects a company, send short confirmation text then reset bot_context and trigger BotRouter with empty message to fire the greeting. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
8f43ccf4c2
commit
f06be3584f
+20
-2
@@ -209,9 +209,27 @@ class WpWebhook
|
||||
$company['_permission_type'] = self::getPermissionType($companies, $selectedId);
|
||||
self::$currentCompany = $company;
|
||||
$displayName = $company['display_name'] ?: $company['name'];
|
||||
WhatsAppSender::sendText($from, "✅ Conectado con *{$displayName}*.\nEscribe tu consulta o *menú* para ver las opciones.", $phoneNumberId);
|
||||
|
||||
// Mensaje 1: confirmación
|
||||
WhatsAppSender::sendText($from, "✅ Conectado con *{$displayName}*.", $phoneNumberId);
|
||||
|
||||
// Mensaje 2: greeting del bot — reset contexto y disparar con mensaje vacío
|
||||
$botCtx = ConversationContext::getOrCreate((int)$selectedId, $from, 'normal');
|
||||
ConversationContext::reset((int)$botCtx['id']);
|
||||
$synthCtx = [
|
||||
'from' => $from,
|
||||
'name' => $name,
|
||||
'message_id' => 'mc_' . uniqid(),
|
||||
'type' => 'text',
|
||||
'timestamp' => time(),
|
||||
'phone_number_id' => $phoneNumberId,
|
||||
'display_phone' => '',
|
||||
'permission_type' => self::getPermissionType($companies, $selectedId),
|
||||
];
|
||||
BotRouter::route($company, $synthCtx, '', 'text');
|
||||
|
||||
self::log('INFO', "Multi-empresa: {$from} seleccionó empresa #{$selectedId} ({$displayName})");
|
||||
return false; // el clic en botón no se procesa como comando del bot
|
||||
return false;
|
||||
}
|
||||
|
||||
// 2. Keyword de reinicio → borrar sesión y mostrar pre-menú
|
||||
|
||||
Reference in New Issue
Block a user