class FAQChat extends HTMLElement { constructor() { super(); this.attachShadow({ mode: 'open' }); // FAQ data this.faqs = [ { question: "What is the $150 Live Coach add-on?", answer: "By purchasing the $150 Live Coach add-on, you will receive a link that allows you to sign up for one hour of real, live coaching with a trained professional." }, { question: "What is your average reply time?", answer: "We try to respond to all messages within 1–2 business days." }, { question: "Do you offer promo codes?", answer: "Yes! We commonly post promo codes on our TikTok and Instagram pages, so be sure to follow us there." }, { question: "What is Amplify?", answer: "Amplify is a mental fitness platform that helps users build confidence, focus, and resilience through immersive VR and AR experiences and personalized coaching." }, { question: "How do I contact support?", answer: "You can contact us via email at amplify.ny@veinternational.org or fill out the support form on our Help Center page. We typically respond within 1-2 business days!" }, { question: "Do you offer group discounts?", answer: "Yes! We offer special group rates for schools, teams, and corporate groups. Please contact us at amplify.ny@veinternational.org with your group size for a custom quote." }, { question: "What equipment do I need?", answer: "For VR experiences, you'll need a compatible VR headset (Meta Quest 2 or higher). For AR features, most modern smartphones work! Many features also work without any special equipment." }, { question: "Who is Amplify for?", answer: "Amplify is for anyone who wants to improve performance under pressure, including students, professionals, and individuals preparing for presentations, interviews, or new roles." }, { question: "Do I need VR equipment to use Amplify?", answer: "Some experiences are enhanced with VR or AR, but Amplify also offers features that can be used without specialized equipment." }, { question: "What is the AI Coach?", answer: "The AI Coach provides instant feedback, encouragement, and guidance to help users improve their mental performance in real time." }, { question: "How is live coaching different from the AI Coach?", answer: "Live coaching offers one-on-one sessions with trained professionals for personalized support, while the AI Coach provides immediate, on-demand guidance anytime." }, { question: "Can Amplify help with public speaking or interviews?", answer: "Yes, Amplify places users in realistic, high-pressure scenarios such as presentations and interviews to help build confidence and performance skills." }, { question: "Is Amplify suitable for beginners?", answer: "Absolutely. Amplify is designed for all experience levels, whether you're just starting or looking to refine your mental performance skills." } ]; this.messages = [ { sender: 'bot', content: 'Hi there! How can I help you today?', buttons: this.faqs.map(faq => faq.question) } ]; this.render(); } render() { this.shadowRoot.innerHTML = `
Amplify Help Assistant
`; this.renderMessages(); this.setupEventListeners(); feather.replace(); } renderMessages() { const container = this.shadowRoot.getElementById('messages-container'); container.innerHTML = ''; this.messages.forEach((msg) => { const messageDiv = document.createElement('div'); messageDiv.className = `message ${msg.sender}-message`; messageDiv.textContent = msg.content; if (msg.buttons) { const buttonsDiv = document.createElement('div'); buttonsDiv.className = 'question-buttons'; msg.buttons.forEach(question => { const button = document.createElement('button'); button.className = 'question-btn'; button.textContent = question; button.addEventListener('click', () => this.handleQuestionClick(question)); buttonsDiv.appendChild(button); }); messageDiv.appendChild(buttonsDiv); } container.appendChild(messageDiv); }); // Scroll to bottom container.scrollTop = container.scrollHeight; // Re-render icons for any new feather icons in messages if (window.feather) { feather.replace({ scope: this.shadowRoot }); } } handleQuestionClick(question) { // Add user message this.messages.push({ sender: 'user', content: question }); this.renderMessages(); // Find answer const faq = this.faqs.find(item => item.question === question); if (faq) { // Simulate typing setTimeout(() => { this.messages.push({ sender: 'bot', content: faq.answer }); this.renderMessages(); }, 500); } } setupEventListeners() { const toggleButton = this.shadowRoot.getElementById('chat-toggle'); const closeButton = this.shadowRoot.getElementById('close-chat'); toggleButton.addEventListener('click', () => { this.classList.toggle('open'); toggleButton.style.display = 'none'; }); closeButton.addEventListener('click', () => { this.classList.remove('open'); toggleButton.style.display = 'flex'; }); } } customElements.define('faq-chat', FAQChat);