diff --git a/services/NormalBot.php b/services/NormalBot.php index 5feb9a3..6562a70 100644 --- a/services/NormalBot.php +++ b/services/NormalBot.php @@ -125,6 +125,7 @@ class NormalBot if (!$ep || empty($ep['url'])) { self::log("API report: endpoint_key '{$endpointKey}' no configurado para company {$company['id']}"); + ConversationContext::reset($ctxId); return self::sendText('El informe solicitado no está configurado. Contacta al administrador.', $context['from'], $company); } @@ -150,7 +151,7 @@ class NormalBot $curlOpts = [ CURLOPT_RETURNTRANSFER => true, CURLOPT_FOLLOWLOCATION => true, - CURLOPT_TIMEOUT => 60, + CURLOPT_TIMEOUT => 15, CURLOPT_HTTPHEADER => [ 'Authorization: Bearer ' . $apiKey, 'X-API-Key: ' . $apiKey, @@ -170,11 +171,13 @@ class NormalBot if ($error) { self::log("API report error [{$endpointKey}]: {$error}"); + ConversationContext::reset($ctxId); return self::sendText('Error al obtener el reporte. Intenta de nuevo.', $context['from'], $company); } if ($httpCode >= 400) { self::log("API report HTTP {$httpCode} [{$endpointKey}]: " . mb_substr($content, 0, 200)); + ConversationContext::reset($ctxId); return self::sendText('Error al obtener el reporte. Intenta de nuevo.', $context['from'], $company); } @@ -208,6 +211,7 @@ class NormalBot if (!$upload['success'] || !$upload['media_id']) { self::log("API report upload failed [{$endpointKey}]: " . ($upload['error'] ?? 'unknown')); + ConversationContext::reset($ctxId); return self::sendText('Error al enviar el reporte. Intenta de nuevo.', $context['from'], $company); }