-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-updated-webhook.html
More file actions
70 lines (65 loc) · 2.85 KB
/
test-updated-webhook.html
File metadata and controls
70 lines (65 loc) · 2.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<!DOCTYPE html>
<html>
<head>
<title>Test Updated Webhook</title>
</head>
<body>
<h1>Test Updated n8n Webhook</h1>
<p>This will test if your webhook works with the new API key after you update n8n.</p>
<button onclick="testWebhook()">Test Webhook with New API Key</button>
<div id="result"></div>
<script>
async function testWebhook() {
const result = document.getElementById('result');
result.innerHTML = 'Testing webhook with new API key...';
const payload = {
input: {
message: "Hello! Testing with new API key",
chat_id: "test-chat-id-" + Date.now()
},
session_variables: {
"x-hasura-user-id": "test-user-id"
}
};
try {
const response = await fetch('https://ankushrajpoot.app.n8n.cloud/webhook/chatbot-v4', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(payload)
});
const data = await response.json();
console.log('Webhook response:', data);
if (response.ok && data.success) {
result.innerHTML = `
<div style="color: green; border: 2px solid green; padding: 20px; margin: 10px 0;">
<h3>🎉 WEBHOOK WORKS WITH NEW API KEY!</h3>
<p><strong>Success:</strong> ${data.success}</p>
<p><strong>Message:</strong> ${data.message}</p>
<p><strong>AI Response:</strong> ${data.response}</p>
<p><strong>✅ Your chatbot should now work!</strong></p>
</div>
`;
} else {
result.innerHTML = `
<div style="color: red; border: 2px solid red; padding: 20px; margin: 10px 0;">
<h3>❌ WEBHOOK STILL FAILING</h3>
<p><strong>Status:</strong> ${response.status}</p>
<p><strong>Response:</strong> ${JSON.stringify(data)}</p>
<p><strong>Make sure you updated the API key in n8n!</strong></p>
</div>
`;
}
} catch (error) {
result.innerHTML = `
<div style="color: red; border: 2px solid red; padding: 20px; margin: 10px 0;">
<h3>❌ REQUEST FAILED</h3>
<p>${error.message}</p>
</div>
`;
}
}
</script>
</body>
</html>