Spaces:
Sleeping
Sleeping
Update static/script.js
Browse files- static/script.js +20 -15
static/script.js
CHANGED
|
@@ -61,9 +61,7 @@ function clearChat() {
|
|
| 61 |
|
| 62 |
function displayForm() {
|
| 63 |
const chatMessages = document.getElementById('chatMessages');
|
| 64 |
-
if (!
|
| 65 |
-
|
| 66 |
-
Messages) {
|
| 67 |
console.error('Chat messages container not found for form!');
|
| 68 |
return;
|
| 69 |
}
|
|
@@ -217,6 +215,10 @@ function displayCategories() {
|
|
| 217 |
return;
|
| 218 |
}
|
| 219 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 220 |
categories.forEach(category => {
|
| 221 |
const messageDiv = document.createElement('div');
|
| 222 |
messageDiv.className = 'bot-message';
|
|
@@ -257,16 +259,19 @@ function handleResponse(userInput) {
|
|
| 257 |
}
|
| 258 |
|
| 259 |
// Handle category selection
|
| 260 |
-
if (lastMessage === 'about tionat and account setup'
|
| 261 |
-
lastMessage === 'nutritional supplements' ||
|
| 262 |
-
lastMessage === 'health care products' ||
|
| 263 |
-
lastMessage === 'personal care and skincare' ||
|
| 264 |
-
lastMessage === 'returns and customer support' ||
|
| 265 |
-
lastMessage === 'security and account management') {
|
| 266 |
return; // Questions are already displayed via displayOptions
|
| 267 |
-
}
|
| 268 |
-
|
| 269 |
-
if (lastMessage === '
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 270 |
addMessage('bot', "Please provide more details about your query so our service agent can assist you.");
|
| 271 |
displayForm();
|
| 272 |
return;
|
|
@@ -284,10 +289,10 @@ function handleResponse(userInput) {
|
|
| 284 |
} else if (lastMessage.includes('what payment methods do you accept?')) {
|
| 285 |
botResponse = 'We accept a wide variety of payment methods, including credit/debit cards (Visa, MasterCard, American Express), net banking, PayPal, and cash on delivery (where applicable).';
|
| 286 |
} else if (lastMessage.includes('what is the best supplement for boosting immunity?')) {
|
| 287 |
-
botResponse = 'Our Immunity Booster supplements, like Vitamin C, Zinc, and Echinacea, are popular choices for improving immune system health. We recommend consulting with
|
| 288 |
} else if (lastMessage.includes('are your nutritional supplements vegan-friendly?')) {
|
| 289 |
-
botResponse = 'Yes,
|
| 290 |
-
} else if (lastMessage.includes('how do i know which supplement is right
|
| 291 |
botResponse = 'We recommend consulting with a healthcare professional before choosing a supplement. You can also check our detailed product descriptions and consult with our customer service for recommendations.';
|
| 292 |
} else if (lastMessage.includes('are there any side effects of using your supplements?')) {
|
| 293 |
botResponse = 'All our products are thoroughly tested for safety, but individual reactions may vary. We suggest reading the product description for possible side effects or consulting with a healthcare provider before using any product.';
|
|
|
|
| 61 |
|
| 62 |
function displayForm() {
|
| 63 |
const chatMessages = document.getElementById('chatMessages');
|
| 64 |
+
if (!chatMessages) {
|
|
|
|
|
|
|
| 65 |
console.error('Chat messages container not found for form!');
|
| 66 |
return;
|
| 67 |
}
|
|
|
|
| 215 |
return;
|
| 216 |
}
|
| 217 |
|
| 218 |
+
// Clear any existing option buttons to prevent duplicates
|
| 219 |
+
const existingButtons = chatMessages.querySelectorAll('.option-button');
|
| 220 |
+
existingButtons.forEach(button => button.parentElement.remove());
|
| 221 |
+
|
| 222 |
categories.forEach(category => {
|
| 223 |
const messageDiv = document.createElement('div');
|
| 224 |
messageDiv.className = 'bot-message';
|
|
|
|
| 259 |
}
|
| 260 |
|
| 261 |
// Handle category selection
|
| 262 |
+
if (lastMessage === 'about tionat and account setup') {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 263 |
return; // Questions are already displayed via displayOptions
|
| 264 |
+
} else if (lastMessage === 'nutritional supplements') {
|
| 265 |
+
return;
|
| 266 |
+
} else if (lastMessage === 'health care products') {
|
| 267 |
+
return;
|
| 268 |
+
} else if (lastMessage === 'personal care and skincare') {
|
| 269 |
+
return;
|
| 270 |
+
} else if (lastMessage === 'returns and customer support') {
|
| 271 |
+
return;
|
| 272 |
+
} else if (lastMessage === 'security and account management') {
|
| 273 |
+
return;
|
| 274 |
+
} else if (lastMessage === 'other') {
|
| 275 |
addMessage('bot', "Please provide more details about your query so our service agent can assist you.");
|
| 276 |
displayForm();
|
| 277 |
return;
|
|
|
|
| 289 |
} else if (lastMessage.includes('what payment methods do you accept?')) {
|
| 290 |
botResponse = 'We accept a wide variety of payment methods, including credit/debit cards (Visa, MasterCard, American Express), net banking, PayPal, and cash on delivery (where applicable).';
|
| 291 |
} else if (lastMessage.includes('what is the best supplement for boosting immunity?')) {
|
| 292 |
+
botResponse = 'Our Immunity Booster supplements, like Vitamin C, Zinc, and Echinacea, are popular choices for improving immune system health. We recommend consulting with a healthcare professional before choosing a supplement.';
|
| 293 |
} else if (lastMessage.includes('are your nutritional supplements vegan-friendly?')) {
|
| 294 |
+
botResponse = 'Yes, many of our nutritional supplements are vegan-friendly. Please check the product details for specific information on ingredients and certifications.';
|
| 295 |
+
} else if (lastMessage.includes('how do i know which supplement is right for me?')) {
|
| 296 |
botResponse = 'We recommend consulting with a healthcare professional before choosing a supplement. You can also check our detailed product descriptions and consult with our customer service for recommendations.';
|
| 297 |
} else if (lastMessage.includes('are there any side effects of using your supplements?')) {
|
| 298 |
botResponse = 'All our products are thoroughly tested for safety, but individual reactions may vary. We suggest reading the product description for possible side effects or consulting with a healthcare provider before using any product.';
|