up
This commit is contained in:
@@ -24,6 +24,14 @@ class BotService {
|
||||
|
||||
$messageText = trim($messageText);
|
||||
$phoneNumber = $user['phone_number'];
|
||||
|
||||
// DEBUG: log basic context
|
||||
try {
|
||||
$userId = $user['id'] ?? 'unknown';
|
||||
error_log("[BotService] processMessage start - user_id={$userId} phone={$phoneNumber} type={$messageType} message='" . substr($messageText,0,200) . "' current_menu_id=" . ($user['current_menu_id'] ?? 'null') . " on_hold=" . ($user['on_hold'] ?? '0') . " advisor_requested=" . ($user['advisor_requested'] ?? '0') . " bot_paused_until=" . ($user['bot_paused_until'] ?? 'null'));
|
||||
} catch (Throwable $t) {
|
||||
// ignore logging errors
|
||||
}
|
||||
|
||||
// Verificar si es un nuevo usuario (enviar mensaje de bienvenida)
|
||||
if ($this->isNewUser($user['id'])) {
|
||||
@@ -50,6 +58,7 @@ class BotService {
|
||||
} catch (Exception $e) {
|
||||
// ignore
|
||||
}
|
||||
error_log("[BotService] processMessage - returning early because on_hold active for user {$user['id']}");
|
||||
return;
|
||||
} else {
|
||||
// El hold expiró, liberar y continuar
|
||||
@@ -67,6 +76,7 @@ class BotService {
|
||||
} catch (Exception $e) {
|
||||
// ignore
|
||||
}
|
||||
error_log("[BotService] processMessage - returning early because advisor_requested active for user {$user['id']}");
|
||||
return;
|
||||
} else {
|
||||
// expiró la espera: limpiar flag
|
||||
@@ -244,12 +254,16 @@ class BotService {
|
||||
$phoneNumber = $user['phone_number'];
|
||||
$currentMenuId = $user['current_menu_id'];
|
||||
|
||||
// DEBUG
|
||||
try { error_log("[BotService] processMenuSelection - user_id={$user['id']} menu_id={$currentMenuId} received='{$messageText}'"); } catch (Throwable $t) {}
|
||||
|
||||
// Verificar si es un número
|
||||
if (!is_numeric($messageText)) {
|
||||
$this->whatsappService->sendTextMessage(
|
||||
$phoneNumber,
|
||||
"❌ Por favor, responde solo con el número de la opción deseada."
|
||||
);
|
||||
error_log("[BotService] processMenuSelection - non-numeric response from user {$user['id']}: '{$messageText}'");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -266,9 +280,11 @@ class BotService {
|
||||
$phoneNumber,
|
||||
"❌ Opción inválida. Por favor, selecciona una opción válida del menú."
|
||||
);
|
||||
error_log("[BotService] processMenuSelection - no option found for user {$user['id']} menu={$currentMenuId} option={$optionNumber}");
|
||||
return;
|
||||
}
|
||||
|
||||
error_log("[BotService] processMenuSelection - option found for user {$user['id']} menu={$currentMenuId} option={$optionNumber} action={$option['action_type']}");
|
||||
// Procesar acción de la opción
|
||||
$this->processMenuAction($phoneNumber, $option);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user