diff --git a/backend/public/debug-chatbot.php b/backend/public/debug-chatbot.php index 03f9f71..80013c7 100644 --- a/backend/public/debug-chatbot.php +++ b/backend/public/debug-chatbot.php @@ -17,7 +17,28 @@ $logs = \App\Core\Database::select("SELECT * FROM messages_log ORDER BY id DESC $sessions = \App\Core\Database::select("SELECT * FROM whatsapp_sessions"); +// Check Node.js gateway status from the PHP environment +$gatewayUrl = rtrim(getenv('WHATSAPP_GATEWAY_URL') ?: 'http://localhost:3722', '/'); +$ch = curl_init($gatewayUrl . '/health'); +curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); +curl_setopt($ch, CURLOPT_TIMEOUT, 3); +$healthResponse = curl_exec($ch); +$healthHttpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); +$healthError = curl_error($ch); +curl_close($ch); + echo json_encode([ + 'env' => [ + 'WHATSAPP_GATEWAY_URL' => getenv('WHATSAPP_GATEWAY_URL'), + 'WEBHOOK_SECRET_SET' => !empty(getenv('WEBHOOK_SECRET')), + 'APP_URL' => getenv('APP_URL') + ], + 'gateway_health' => [ + 'url' => $gatewayUrl . '/health', + 'http_code' => $healthHttpCode, + 'response' => json_decode($healthResponse, true) ?: $healthResponse, + 'error' => $healthError + ], 'chatbot_rules' => $rules, 'messages_log' => $logs, 'whatsapp_sessions' => $sessions