Robbin / template /index.html
Swathi6's picture
Update template/index.html
96bbc40 verified
raw
history blame
4.82 kB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Restaurant Chatbot</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f4f4f9;
margin: 0;
padding: 0;
}
#chat-container {
max-width: 600px;
margin: 0 auto;
padding: 20px;
background-color: #ffffff;
border-radius: 8px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
margin-top: 50px;
}
#chat-box {
max-height: 400px;
overflow-y: auto;
margin-bottom: 20px;
border: 1px solid #ddd;
padding: 10px;
background-color: #f9f9f9;
border-radius: 5px;
}
#user-input {
width: 100%;
padding: 12px;
margin-top: 10px;
border: 1px solid #ddd;
border-radius: 5px;
}
#send-btn {
padding: 12px 20px;
background-color: #007bff;
color: white;
border: none;
cursor: pointer;
border-radius: 5px;
margin-top: 10px;
width: 100%;
}
#send-btn:hover {
background-color: #0056b3;
}
.bot-message, .user-message {
padding: 10px;
margin-bottom: 10px;
border-radius: 5px;
}
.bot-message {
background-color: #f1f1f1;
}
.user-message {
background-color: #007bff;
color: white;
text-align: right;
}
</style>
</head>
<body>
<div id="chat-container">
<h2 style="text-align: center; color: #333;">Restaurant Chatbot</h2>
<div id="chat-box">
<!-- Messages will appear here -->
</div>
<input type="text" id="user-input" placeholder="Ask about the menu or suggest a dish...">
<button id="send-btn" onclick="sendMessage()">Send</button>
</div>
<script>
// Sample menu
const menu = {
'appetizers': ['Samosa', 'Pakora', 'Spring Roll', 'Chaat'],
'main_course': ['Butter Chicken', 'Paneer Butter Masala', 'Biryani', 'Dosa'],
'desserts': ['Gulab Jamun', 'Jalebi', 'Rasgulla', 'Kheer']
};
// Function to suggest dishes based on ingredients (a simple implementation)
function suggestDish(ingredients) {
if (ingredients.includes('chicken')) {
return 'Butter Chicken';
} else if (ingredients.includes('paneer')) {
return 'Paneer Butter Masala';
} else if (ingredients.includes('sweet')) {
return 'Gulab Jamun';
} else {
return 'Sorry, no suggestions available.';
}
}
// Send user message to the chatbot and get the response
function sendMessage() {
var userMessage = document.getElementById("user-input").value;
if (userMessage.trim() === "") return;
appendMessage(userMessage, "user");
var response = "";
if (userMessage.toLowerCase().includes('menu')) {
response = "Here is our menu:\n";
for (const category in menu) {
response += category.charAt(0).toUpperCase() + category.slice(1) + ":\n";
response += menu[category].join("\n") + "\n\n";
}
} else if (userMessage.toLowerCase().includes('suggest') || userMessage.toLowerCase().includes('ingredients')) {
// Assuming ingredients are available (you could extend this with more dynamic input)
const ingredients = ['chicken', 'paneer', 'sweet']; // Placeholder ingredients
const suggestedDish = suggestDish(ingredients);
response = `Based on your ingredients, we suggest: ${suggestedDish}`;
} else {
response = "Sorry, I didn't understand that. Can you ask about the menu or suggest a dish?";
}
appendMessage(response, "bot");
document.getElementById("user-input").value = "";
}
// Append messages to the chat box
function appendMessage(message, sender) {
var chatBox = document.getElementById("chat-box");
var messageDiv = document.createElement("div");
messageDiv.classList.add(sender + "-message");
messageDiv.innerHTML = message;
chatBox.appendChild(messageDiv);
chatBox.scrollTop = chatBox.scrollHeight;
}
</script>
</body>
</html>