diff --git a/backend/public/debug-chatbot.php b/backend/public/debug-chatbot.php index 80013c7..58125ca 100644 --- a/backend/public/debug-chatbot.php +++ b/backend/public/debug-chatbot.php @@ -27,6 +27,27 @@ $healthHttpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); $healthError = curl_error($ch); curl_close($ch); +// Test message sending endpoint to see what response it gives (404, 403, etc) +$sendUrl = $gatewayUrl . '/api/messages/send'; +$payload = json_encode([ + 'session_key' => 'mock_test_session', + 'phone' => '1234567890', + 'message' => 'test' +]); +$ch = curl_init($sendUrl); +curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); +curl_setopt($ch, CURLOPT_POST, true); +curl_setopt($ch, CURLOPT_POSTFIELDS, $payload); +curl_setopt($ch, CURLOPT_HTTPHEADER, [ + 'Content-Type: application/json', + 'X-Webhook-Secret: ' . getenv('WEBHOOK_SECRET') +]); +curl_setopt($ch, CURLOPT_TIMEOUT, 5); +$sendResponse = curl_exec($ch); +$sendHttpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); +$sendError = curl_error($ch); +curl_close($ch); + echo json_encode([ 'env' => [ 'WHATSAPP_GATEWAY_URL' => getenv('WHATSAPP_GATEWAY_URL'), @@ -39,6 +60,12 @@ echo json_encode([ 'response' => json_decode($healthResponse, true) ?: $healthResponse, 'error' => $healthError ], + 'gateway_send_test' => [ + 'url' => $sendUrl, + 'http_code' => $sendHttpCode, + 'response' => json_decode($sendResponse, true) ?: $sendResponse, + 'error' => $sendError + ], 'chatbot_rules' => $rules, 'messages_log' => $logs, 'whatsapp_sessions' => $sessions