Spaces:
Running
Running
Add 2 files
Browse files- README.md +7 -5
- index.html +279 -19
README.md
CHANGED
|
@@ -1,10 +1,12 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
-
colorTo:
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
|
|
|
|
|
|
| 8 |
---
|
| 9 |
|
| 10 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
| 1 |
---
|
| 2 |
+
title: supportbot
|
| 3 |
+
emoji: 🐳
|
| 4 |
+
colorFrom: gray
|
| 5 |
+
colorTo: blue
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
| 8 |
+
tags:
|
| 9 |
+
- deepsite
|
| 10 |
---
|
| 11 |
|
| 12 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
index.html
CHANGED
|
@@ -1,19 +1,279 @@
|
|
| 1 |
-
<!
|
| 2 |
-
<html>
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>SupportBot - Customer Assistance</title>
|
| 7 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
| 8 |
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
| 9 |
+
<style>
|
| 10 |
+
.chat-container {
|
| 11 |
+
height: calc(100vh - 180px);
|
| 12 |
+
}
|
| 13 |
+
@media (max-width: 640px) {
|
| 14 |
+
.chat-container {
|
| 15 |
+
height: calc(100vh - 160px);
|
| 16 |
+
}
|
| 17 |
+
}
|
| 18 |
+
.message {
|
| 19 |
+
max-width: 80%;
|
| 20 |
+
animation: fadeIn 0.3s ease-in-out;
|
| 21 |
+
}
|
| 22 |
+
.typing-indicator {
|
| 23 |
+
display: inline-block;
|
| 24 |
+
}
|
| 25 |
+
.typing-indicator span {
|
| 26 |
+
display: inline-block;
|
| 27 |
+
width: 8px;
|
| 28 |
+
height: 8px;
|
| 29 |
+
border-radius: 50%;
|
| 30 |
+
background-color: #4b5563;
|
| 31 |
+
margin: 0 2px;
|
| 32 |
+
opacity: 0.4;
|
| 33 |
+
}
|
| 34 |
+
.typing-indicator span:nth-child(1) {
|
| 35 |
+
animation: bounce 1s infinite;
|
| 36 |
+
}
|
| 37 |
+
.typing-indicator span:nth-child(2) {
|
| 38 |
+
animation: bounce 1s infinite 0.2s;
|
| 39 |
+
}
|
| 40 |
+
.typing-indicator span:nth-child(3) {
|
| 41 |
+
animation: bounce 1s infinite 0.4s;
|
| 42 |
+
}
|
| 43 |
+
@keyframes bounce {
|
| 44 |
+
0%, 100% { transform: translateY(0); opacity: 0.4; }
|
| 45 |
+
50% { transform: translateY(-5px); opacity: 1; }
|
| 46 |
+
}
|
| 47 |
+
@keyframes fadeIn {
|
| 48 |
+
from { opacity: 0; transform: translateY(10px); }
|
| 49 |
+
to { opacity: 1; transform: translateY(0); }
|
| 50 |
+
}
|
| 51 |
+
.send-btn:disabled {
|
| 52 |
+
opacity: 0.5;
|
| 53 |
+
cursor: not-allowed;
|
| 54 |
+
}
|
| 55 |
+
</style>
|
| 56 |
+
</head>
|
| 57 |
+
<body class="bg-gray-100 font-sans">
|
| 58 |
+
<div class="container mx-auto max-w-4xl p-4">
|
| 59 |
+
<!-- Header -->
|
| 60 |
+
<header class="flex items-center justify-between mb-6">
|
| 61 |
+
<div class="flex items-center space-x-3">
|
| 62 |
+
<div class="w-10 h-10 rounded-full bg-blue-600 flex items-center justify-center">
|
| 63 |
+
<i class="fas fa-robot text-white text-xl"></i>
|
| 64 |
+
</div>
|
| 65 |
+
<h1 class="text-2xl font-bold text-gray-800">SupportBot</h1>
|
| 66 |
+
</div>
|
| 67 |
+
<div class="text-sm text-gray-500">
|
| 68 |
+
<span id="current-time"></span>
|
| 69 |
+
</div>
|
| 70 |
+
</header>
|
| 71 |
+
|
| 72 |
+
<!-- Chat Container -->
|
| 73 |
+
<div class="bg-white rounded-xl shadow-lg overflow-hidden">
|
| 74 |
+
<!-- Chat Header -->
|
| 75 |
+
<div class="bg-blue-600 text-white p-4 flex items-center">
|
| 76 |
+
<div class="w-8 h-8 rounded-full bg-blue-500 flex items-center justify-center mr-3">
|
| 77 |
+
<i class="fas fa-headset text-white"></i>
|
| 78 |
+
</div>
|
| 79 |
+
<div>
|
| 80 |
+
<h2 class="font-semibold">Customer Support</h2>
|
| 81 |
+
<p class="text-xs opacity-80" id="status-indicator">Online</p>
|
| 82 |
+
</div>
|
| 83 |
+
</div>
|
| 84 |
+
|
| 85 |
+
<!-- Messages Area -->
|
| 86 |
+
<div class="chat-container p-4 overflow-y-auto" id="chat-messages">
|
| 87 |
+
<!-- Messages will be inserted here by JavaScript -->
|
| 88 |
+
</div>
|
| 89 |
+
|
| 90 |
+
<!-- Input Area -->
|
| 91 |
+
<div class="border-t border-gray-200 p-4 bg-gray-50">
|
| 92 |
+
<div class="flex items-center space-x-2">
|
| 93 |
+
<input
|
| 94 |
+
type="text"
|
| 95 |
+
id="user-input"
|
| 96 |
+
placeholder="Type your message here..."
|
| 97 |
+
class="flex-1 px-4 py-2 rounded-full border border-gray-300 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent"
|
| 98 |
+
autocomplete="off"
|
| 99 |
+
>
|
| 100 |
+
<button
|
| 101 |
+
id="send-btn"
|
| 102 |
+
class="w-10 h-10 rounded-full bg-blue-600 text-white flex items-center justify-center hover:bg-blue-700 transition-colors send-btn"
|
| 103 |
+
disabled
|
| 104 |
+
>
|
| 105 |
+
<i class="fas fa-paper-plane"></i>
|
| 106 |
+
</button>
|
| 107 |
+
</div>
|
| 108 |
+
<div class="mt-2 text-xs text-gray-500 text-center">
|
| 109 |
+
Try asking: "What are your hours?", "How do I contact support?", or "What services do you offer?"
|
| 110 |
+
</div>
|
| 111 |
+
</div>
|
| 112 |
+
</div>
|
| 113 |
+
</div>
|
| 114 |
+
|
| 115 |
+
<script>
|
| 116 |
+
document.addEventListener('DOMContentLoaded', function() {
|
| 117 |
+
// Update current time
|
| 118 |
+
function updateTime() {
|
| 119 |
+
const now = new Date();
|
| 120 |
+
const timeString = now.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' });
|
| 121 |
+
document.getElementById('current-time').textContent = timeString;
|
| 122 |
+
}
|
| 123 |
+
updateTime();
|
| 124 |
+
setInterval(updateTime, 1000);
|
| 125 |
+
|
| 126 |
+
// DOM elements
|
| 127 |
+
const chatMessages = document.getElementById('chat-messages');
|
| 128 |
+
const userInput = document.getElementById('user-input');
|
| 129 |
+
const sendBtn = document.getElementById('send-btn');
|
| 130 |
+
const statusIndicator = document.getElementById('status-indicator');
|
| 131 |
+
|
| 132 |
+
// Initial greeting
|
| 133 |
+
setTimeout(() => {
|
| 134 |
+
addBotMessage("Hello! I'm SupportBot, your virtual assistant. How can I help you today?");
|
| 135 |
+
}, 500);
|
| 136 |
+
|
| 137 |
+
// Enable/disable send button based on input
|
| 138 |
+
userInput.addEventListener('input', function() {
|
| 139 |
+
sendBtn.disabled = this.value.trim() === '';
|
| 140 |
+
});
|
| 141 |
+
|
| 142 |
+
// Send message on Enter key or button click
|
| 143 |
+
userInput.addEventListener('keypress', function(e) {
|
| 144 |
+
if (e.key === 'Enter' && !sendBtn.disabled) {
|
| 145 |
+
sendMessage();
|
| 146 |
+
}
|
| 147 |
+
});
|
| 148 |
+
sendBtn.addEventListener('click', sendMessage);
|
| 149 |
+
|
| 150 |
+
// Chatbot responses
|
| 151 |
+
const responses = {
|
| 152 |
+
greetings: ["Hello!", "Hi there!", "Greetings! How can I assist you today?"],
|
| 153 |
+
farewells: ["Goodbye! Have a great day!", "See you later!", "Thanks for chatting!"],
|
| 154 |
+
hours: "Our operating hours are Monday to Friday, 9:00 AM to 5:00 PM.",
|
| 155 |
+
contact: "You can contact our support team at support@example.com or call us at (123) 456-7890.",
|
| 156 |
+
location: "We're located at 123 Business Street, Suite 100, Tech City, TC 12345.",
|
| 157 |
+
services: "We offer a range of services including web development, digital marketing, and IT consulting.",
|
| 158 |
+
help: "I can help with questions about our hours, location, services, and more. What do you need?",
|
| 159 |
+
returnPolicy: "Our return policy allows returns within 30 days of purchase with a receipt.",
|
| 160 |
+
default: "I'm not sure I understand. Could you try asking differently? Here are some things I can help with: hours, contact info, location, services, or return policy."
|
| 161 |
+
};
|
| 162 |
+
|
| 163 |
+
// Pattern matching for user input
|
| 164 |
+
function getResponse(userMessage) {
|
| 165 |
+
const lowerMsg = userMessage.toLowerCase();
|
| 166 |
+
|
| 167 |
+
if (/(hello|hi|hey|greetings)/i.test(lowerMsg)) {
|
| 168 |
+
return randomResponse(responses.greetings);
|
| 169 |
+
}
|
| 170 |
+
if (/(bye|goodbye|see ya|farewell)/i.test(lowerMsg)) {
|
| 171 |
+
return randomResponse(responses.farewells);
|
| 172 |
+
}
|
| 173 |
+
if (/(hour|time|open|close|when)/i.test(lowerMsg)) {
|
| 174 |
+
return responses.hours;
|
| 175 |
+
}
|
| 176 |
+
if (/(contact|email|phone|call|number)/i.test(lowerMsg)) {
|
| 177 |
+
return responses.contact;
|
| 178 |
+
}
|
| 179 |
+
if (/(where|location|address|place)/i.test(lowerMsg)) {
|
| 180 |
+
return responses.location;
|
| 181 |
+
}
|
| 182 |
+
if (/(service|offer|provide|do)/i.test(lowerMsg)) {
|
| 183 |
+
return responses.services;
|
| 184 |
+
}
|
| 185 |
+
if (/(help|support|assist)/i.test(lowerMsg)) {
|
| 186 |
+
return responses.help;
|
| 187 |
+
}
|
| 188 |
+
if (/(return|refund|exchange|policy)/i.test(lowerMsg)) {
|
| 189 |
+
return responses.returnPolicy;
|
| 190 |
+
}
|
| 191 |
+
if (/(thank|thanks|appreciate)/i.test(lowerMsg)) {
|
| 192 |
+
return "You're welcome! Is there anything else I can help with?";
|
| 193 |
+
}
|
| 194 |
+
|
| 195 |
+
return responses.default;
|
| 196 |
+
}
|
| 197 |
+
|
| 198 |
+
function randomResponse(responsesArray) {
|
| 199 |
+
return responsesArray[Math.floor(Math.random() * responsesArray.length)];
|
| 200 |
+
}
|
| 201 |
+
|
| 202 |
+
// Add a user message to the chat
|
| 203 |
+
function addUserMessage(message) {
|
| 204 |
+
const messageDiv = document.createElement('div');
|
| 205 |
+
messageDiv.className = 'message ml-auto bg-blue-600 text-white p-3 rounded-t-xl rounded-bl-xl mb-3';
|
| 206 |
+
messageDiv.innerHTML = `<p>${message}</p>`;
|
| 207 |
+
chatMessages.appendChild(messageDiv);
|
| 208 |
+
chatMessages.scrollTop = chatMessages.scrollHeight;
|
| 209 |
+
}
|
| 210 |
+
|
| 211 |
+
// Add a bot message to the chat
|
| 212 |
+
function addBotMessage(message) {
|
| 213 |
+
// Show typing indicator
|
| 214 |
+
const typingDiv = document.createElement('div');
|
| 215 |
+
typingDiv.className = 'message mb-3';
|
| 216 |
+
typingDiv.innerHTML = `
|
| 217 |
+
<div class="bg-gray-200 text-gray-800 p-3 rounded-t-xl rounded-br-xl inline-block">
|
| 218 |
+
<div class="typing-indicator">
|
| 219 |
+
<span></span>
|
| 220 |
+
<span></span>
|
| 221 |
+
<span></span>
|
| 222 |
+
</div>
|
| 223 |
+
</div>
|
| 224 |
+
`;
|
| 225 |
+
chatMessages.appendChild(typingDiv);
|
| 226 |
+
chatMessages.scrollTop = chatMessages.scrollHeight;
|
| 227 |
+
|
| 228 |
+
// Simulate typing delay
|
| 229 |
+
setTimeout(() => {
|
| 230 |
+
chatMessages.removeChild(typingDiv);
|
| 231 |
+
|
| 232 |
+
const messageDiv = document.createElement('div');
|
| 233 |
+
messageDiv.className = 'message bg-gray-200 text-gray-800 p-3 rounded-t-xl rounded-br-xl mb-3';
|
| 234 |
+
messageDiv.innerHTML = `<p>${message}</p>`;
|
| 235 |
+
chatMessages.appendChild(messageDiv);
|
| 236 |
+
chatMessages.scrollTop = chatMessages.scrollHeight;
|
| 237 |
+
}, 1000 + Math.random() * 1000);
|
| 238 |
+
}
|
| 239 |
+
|
| 240 |
+
// Send message function
|
| 241 |
+
function sendMessage() {
|
| 242 |
+
const message = userInput.value.trim();
|
| 243 |
+
if (message === '') return;
|
| 244 |
+
|
| 245 |
+
addUserMessage(message);
|
| 246 |
+
userInput.value = '';
|
| 247 |
+
sendBtn.disabled = true;
|
| 248 |
+
|
| 249 |
+
// Simulate processing
|
| 250 |
+
statusIndicator.textContent = "Typing...";
|
| 251 |
+
statusIndicator.style.opacity = "0.8";
|
| 252 |
+
|
| 253 |
+
setTimeout(() => {
|
| 254 |
+
const response = getResponse(message);
|
| 255 |
+
addBotMessage(response);
|
| 256 |
+
|
| 257 |
+
statusIndicator.textContent = "Online";
|
| 258 |
+
statusIndicator.style.opacity = "1";
|
| 259 |
+
}, 500);
|
| 260 |
+
}
|
| 261 |
+
|
| 262 |
+
// Handle inactivity
|
| 263 |
+
let inactivityTimer;
|
| 264 |
+
function resetInactivityTimer() {
|
| 265 |
+
clearTimeout(inactivityTimer);
|
| 266 |
+
inactivityTimer = setTimeout(() => {
|
| 267 |
+
addBotMessage("Are you still there? Type something if you need help!");
|
| 268 |
+
}, 30000); // 30 seconds of inactivity
|
| 269 |
+
}
|
| 270 |
+
|
| 271 |
+
// Reset timer on any user interaction
|
| 272 |
+
userInput.addEventListener('focus', resetInactivityTimer);
|
| 273 |
+
userInput.addEventListener('keypress', resetInactivityTimer);
|
| 274 |
+
sendBtn.addEventListener('click', resetInactivityTimer);
|
| 275 |
+
resetInactivityTimer();
|
| 276 |
+
});
|
| 277 |
+
</script>
|
| 278 |
+
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=Mishak/supportbot" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
|
| 279 |
+
</html>
|