#!/bin/bash # Test script to verify n8n webhook is being called correctly # This simulates what create-meet-link function does SUPABASE_URL="https://lovable.backoffice.biz.id" SERVICE_ROLE_KEY="eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJzdXBhYmFzZSIsImlhdCI6MTc2NjAzNzEyMCwiZXhwIjo0OTIxNzEwNzIwLCJyb2xlIjoic2VydmljZV9yb2xlIn0.t6D9VwaukYGq4c_VbW1bkd3ZkKgldpCKRR13nN14XXc" echo "๐Ÿ” Checking platform settings..." echo "" # Fetch current platform settings SETTINGS=$(curl -s "$SUPABASE_URL/rest/v1/platform_settings?select=integration_n8n_base_url,integration_n8n_test_mode" \ -H "Authorization: Bearer $SERVICE_ROLE_KEY" \ -H "apikey: $SERVICE_ROLE_KEY") echo "Current Settings:" echo "$SETTINGS" | jq '.' # Extract values BASE_URL=$(echo "$SETTINGS" | jq -r '.[0].integration_n8n_base_url') TEST_MODE=$(echo "$SETTINGS" | jq -r '.[0].integration_n8n_test_mode') echo "" echo "Base URL: $BASE_URL" echo "Test Mode: $TEST_MODE" # Construct webhook URL if [ "$TEST_MODE" = "true" ] || [ "$TEST_MODE" = "True" ]; then WEBHOOK_PATH="/webhook-test/" else WEBHOOK_PATH="/webhook/" fi WEBHOOK_URL="${BASE_URL}${WEBHOOK_PATH}create-meet" echo "" echo "๐Ÿ“ก Webhook URL that will be called:" echo "$WEBHOOK_URL" echo "" # Test if webhook is reachable (without actually triggering) echo "๐Ÿงช Testing webhook reachability..." curl -s -o /dev/null -w "HTTP Status: %{http_code}\n" -X POST "$WEBHOOK_URL" \ -H "Content-Type: application/json" \ -d '{ "slot_id": "test-slot-123", "date": "2025-12-23", "start_time": "14:00:00", "end_time": "15:00:00", "client_name": "Test Client", "client_email": "test@example.com", "topic": "Test Topic", "calendar_id": "test@example.com", "brand_name": "Test Hub", "test_mode": true }' || echo "Webhook not reachable" echo "" echo "โœ… Test complete!"