/* Chatbot Script for SolutionsWithKarin.com */ (function() { let chatbot = document.createElement('div'); chatbot.id = 'chatbot-container'; chatbot.innerHTML = `
💬 Chat
`; document.body.appendChild(chatbot); let chatbotToggle = document.getElementById('chatbot-toggle'); let chatbotWindow = document.getElementById('chatbot-window'); let chatbotClose = document.getElementById('chatbot-close'); let chatbotMessages = document.getElementById('chatbot-messages'); let chatbotInput = document.getElementById('chatbot-input'); let chatbotSend = document.getElementById('chatbot-send'); chatbotToggle.addEventListener('click', () => chatbotWindow.classList.toggle('hidden')); chatbotClose.addEventListener('click', () => chatbotWindow.classList.add('hidden')); chatbotSend.addEventListener('click', sendMessage); chatbotInput.addEventListener('keypress', function(e) { if (e.key === 'Enter') sendMessage(); }); function sendMessage() { let userMessage = chatbotInput.value.trim(); if (!userMessage) return; chatbotMessages.innerHTML += `
${userMessage}
`; chatbotInput.value = ''; setTimeout(() => chatbotReply(userMessage), 1000); } function chatbotReply(message) { let response = "I'm here to help!"; message = message.toLowerCase(); if (message.includes("godesana")) { response = "You can explore GoDesana oils here: GoDesana!"; } else if (message.includes("hbn") || message.includes("heart & body naturals")) { response = "Check out Heart & Body Naturals here: HBN!"; } else if (message.includes("oil for")) { response = "Looking for a specific oil? Let me know the issue, and I'll suggest an oil from GoDesana!"; } else if (message.includes("blog") || message.includes("article")) { response = "You can read helpful articles on my blog here: Solutions With Karin!"; } else if (message.includes("email")) { response = "I'd love to stay in touch! Enter your email below so I can send you updates."; chatbotMessages.innerHTML += ``; setTimeout(() => { document.getElementById('chatbot-email-submit').addEventListener('click', () => { let email = document.getElementById('chatbot-email').value; if (email) chatbotMessages.innerHTML += `
Thanks! I'll send updates to ${email}.
`; }); }, 500); return; } chatbotMessages.innerHTML += `
${response}
`; } /* Chatbot CSS */ let chatbotStyle = document.createElement('style'); chatbotStyle.innerHTML = ` #chatbot-container { position: fixed; bottom: 20px; right: 20px; font-family: Arial, sans-serif; z-index: 9999; } #chatbot-toggle { background: #0084ff; color: white; padding: 10px 15px; border-radius: 20px; cursor: pointer; } #chatbot-window { width: 300px; height: 400px; background: white; border: 1px solid #ccc; box-shadow: 0px 0px 10px rgba(0,0,0,0.2); position: fixed; bottom: 60px; right: 20px; display: flex; flex-direction: column; } #chatbot-header { background: #0084ff; color: white; padding: 10px; font-weight: bold; display: flex; justify-content: space-between; } #chatbot-messages { flex: 1; padding: 10px; overflow-y: auto; max-height: 300px; } #chatbot-input { border: 1px solid #ccc; padding: 5px; width: 80%; } #chatbot-send { width: 18%; border: none; background: #0084ff; color: white; cursor: pointer; } .hidden { display: none; } .user-message { text-align: right; background: #0084ff; color: white; padding: 5px; margin: 5px; border-radius: 10px; } .bot-message { text-align: left; background: #f1f1f1; padding: 5px; margin: 5px; border-radius: 10px; } `; document.head.appendChild(chatbotStyle); })();