-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-complete-workflow.html
More file actions
70 lines (66 loc) · 3.1 KB
/
test-complete-workflow.html
File metadata and controls
70 lines (66 loc) · 3.1 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 Complete Workflow</title>
</head>
<body>
<h1>Test Complete Workflow</h1>
<button onclick="testCompleteFlow()">Test Full Message Flow</button>
<div id="result"></div>
<script>
async function testCompleteFlow() {
const result = document.getElementById('result');
result.innerHTML = 'Testing complete workflow...';
try {
// Test the Hasura Action (which calls n8n)
const response = await fetch('https://wertssqowjrkykmeovsg.hasura.ap-south-1.nhost.run/v1/graphql', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'x-hasura-admin-secret': 'Hq=1ILX8*V%Df8PlCyljd*BVys-::p,A'
},
body: JSON.stringify({
query: `
mutation SendMessage($chatId: uuid!, $message: String!) {
sendMessage(chatId: $chatId, message: $message) {
success
message
response
}
}
`,
variables: {
chatId: "631b4b94-5e56-4960-b7b2-237f11a1034d",
message: "Hello, can you introduce yourself?"
}
})
});
const data = await response.json();
console.log('Hasura Action response:', data);
if (data.data && data.data.sendMessage) {
const sendMessageResponse = data.data.sendMessage;
result.innerHTML = `
<div style="border: 1px solid #ccc; padding: 15px; margin: 10px 0;">
<h3>Hasura Action Response:</h3>
<p><strong>Success:</strong> ${sendMessageResponse.success}</p>
<p><strong>Message:</strong> ${sendMessageResponse.message}</p>
<p><strong>AI Response:</strong> ${sendMessageResponse.response}</p>
${sendMessageResponse.success ?
'<div style="color: green;">✅ Workflow completed successfully!</div>' :
'<div style="color: red;">❌ Workflow failed</div>'
}
</div>
`;
} else if (data.errors) {
result.innerHTML = `<div style="color: red;">GraphQL Error: ${JSON.stringify(data.errors)}</div>`;
} else {
result.innerHTML = `<div style="color: orange;">Unexpected response: ${JSON.stringify(data)}</div>`;
}
} catch (error) {
result.innerHTML = `<div style="color: red;">Error: ${error.message}</div>`;
console.error('Error:', error);
}
}
</script>
</body>
</html>