-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
28 lines (27 loc) · 971 Bytes
/
index.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Hotel Booking Chatbot</title>
</head>
<body>
<div id="chatbox"></div>
<input type="text" id="userInput" placeholder="Type your message here...">
<button onclick="sendMessage()">Send</button>
<script>
async function sendMessage() {
const userInput = document.getElementById('userInput').value;
const response = await fetch('http://localhost:3000/chat', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ userId: '1', message: userInput }),
});
const data = await response.json();
document.getElementById('chatbox').innerHTML += `<p>User: ${userInput}</p><p>Bot: ${data.message}</p>`;
document.getElementById('userInput').value = '';
}
</script>
</body>
</html>