|
<!DOCTYPE html> |
|
<html lang="en"> |
|
<head> |
|
<meta charset="UTF-8"> |
|
<meta name="viewport" content="width=device-width, initial-scale=1.0"> |
|
<title>Customer Support Chatbot</title> |
|
<style> |
|
:root { |
|
--color-accent: #6366f1; |
|
--color-background: #0f172a; |
|
--color-surface: #1e293b; |
|
--color-text: #e2e8f0; |
|
--boxSize: 8px; |
|
--gutter: 4px; |
|
} |
|
body { |
|
margin: 0; |
|
padding: 0; |
|
background-color: var(--color-background); |
|
color: var(--color-text); |
|
font-family: system-ui, -apple-system, sans-serif; |
|
min-height: 100vh; |
|
display: flex; |
|
flex-direction: column; |
|
align-items: center; |
|
justify-content: center; |
|
} |
|
.container { |
|
width: 90%; |
|
max-width: 800px; |
|
background-color: var(--color-surface); |
|
padding: 2rem; |
|
border-radius: 1rem; |
|
box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25); |
|
text-align: center; |
|
} |
|
.input-group { |
|
margin: 1rem 0; |
|
} |
|
input { |
|
padding: 0.75rem; |
|
border-radius: 0.5rem; |
|
border: 1px solid rgba(255, 255, 255, 0.1); |
|
background-color: var(--color-background); |
|
color: var(--color-text); |
|
font-size: 1rem; |
|
width: 100%; |
|
box-sizing: border-box; |
|
} |
|
button { |
|
padding: 1rem 2rem; |
|
border-radius: 0.5rem; |
|
border: none; |
|
background-color: var(--color-accent); |
|
color: white; |
|
font-weight: 600; |
|
cursor: pointer; |
|
transition: all 0.2s ease; |
|
} |
|
button:hover { |
|
opacity: 0.9; |
|
transform: translateY(-1px); |
|
} |
|
#response { |
|
margin-top: 1rem; |
|
background-color: var(--color-surface); |
|
padding: 1rem; |
|
border-radius: 0.5rem; |
|
text-align: left; |
|
} |
|
</style> |
|
</head> |
|
<body> |
|
<div class="container"> |
|
<h1>Customer Support Chatbot</h1> |
|
<p>Ask your question below:</p> |
|
<div class="input-group"> |
|
<input type="text" id="query" placeholder="Type your question here"> |
|
</div> |
|
<button id="submit-button">Submit</button> |
|
<div id="response"></div> |
|
</div> |
|
|
|
<script> |
|
document.getElementById('submit-button').addEventListener('click', async () => { |
|
const query = document.getElementById('query').value; |
|
const responseDiv = document.getElementById('response'); |
|
responseDiv.innerHTML = "<em>Loading...</em>"; |
|
try { |
|
const res = await fetch('/chat', { |
|
method: 'POST', |
|
headers: {'Content-Type': 'application/json'}, |
|
body: JSON.stringify({question: query}) |
|
}); |
|
const data = await res.json(); |
|
responseDiv.innerHTML = data.answer; |
|
} catch (err) { |
|
responseDiv.innerHTML = "<em>Error retrieving answer.</em>"; |
|
} |
|
}); |
|
</script> |
|
</body> |
|
</html> |
|
|