UNPKG

@spectrumsense/spectrum-chat-dev

Version:

Embeddable AI Widget - Add trusted, evidence-based answers directly to your website. Simple installation, enterprise-grade security.

218 lines (191 loc) â€ĸ 6.84 kB
<!-- This would extend template-base.html in a real framework --> <!-- {% extends "template-base.html" %} --> <!-- {% block title %}Page 2 - Template Example{% endblock %} --> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Page 2 - Template Example</title> <!-- Global Chat Configuration - Only add this once in your main template! --> <script> window.SpectrumChatConfig = { apiUrl: 'http://localhost:8000/api/v1/conversations', tenantId: 'brightspectrum-tenant-123', title: 'Bright Spectrum AI Assistant', introText: 'I am Bright Spectrum AI Assistant. I can answer questions about our programs, costs, and services.', primaryColor: 'hsl(145 73% 35%)', userColor: 'hsl(195 82% 45%)', aiColor: 'hsl(145 73% 35%)', position: 'bottom-right', width: '320px', height: '350px', showIntro: true, enableCitations: false, debug: true }; </script> <!-- Global Chat Script - Only include this once in your main template! --> <script src="../../dist/spectrum-chat.js"></script> <style> body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; margin: 0; padding: 2rem; background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%); min-height: 100vh; color: white; } .container { max-width: 1200px; margin: 0 auto; } h1 { font-size: 2.5rem; font-weight: 700; margin-bottom: 1rem; text-align: center; text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); } .demo-section { background: rgba(255, 255, 255, 0.1); backdrop-filter: blur(10px); border-radius: 1rem; padding: 2rem; margin-bottom: 2rem; box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1); border: 1px solid rgba(255, 255, 255, 0.2); } .demo-title { font-size: 1.5rem; font-weight: 600; margin-bottom: 1rem; } .demo-description { opacity: 0.9; margin-bottom: 1.5rem; line-height: 1.6; } .success { background: linear-gradient(135deg, #10b981 0%, #059669 100%); color: white; padding: 1.5rem; border-radius: 0.75rem; margin: 1.5rem 0; text-align: center; } .success h4 { font-size: 1.25rem; margin-bottom: 0.5rem; } .button { background: rgba(255, 255, 255, 0.2); color: white; border: 1px solid rgba(255, 255, 255, 0.3); padding: 0.75rem 1.5rem; border-radius: 0.5rem; cursor: pointer; font-size: 0.9rem; margin: 0.25rem; text-decoration: none; display: inline-block; transition: all 0.3s ease; backdrop-filter: blur(10px); } .button:hover { background: rgba(255, 255, 255, 0.3); transform: translateY(-2px); } .button-container { display: flex; gap: 1rem; margin: 1.5rem 0; flex-wrap: wrap; justify-content: center; } .nav-links { display: flex; gap: 1rem; justify-content: center; flex-wrap: wrap; margin: 2rem 0; } .nav-link { background: rgba(255, 255, 255, 0.2); color: white; padding: 0.75rem 1.5rem; border-radius: 0.5rem; text-decoration: none; font-weight: 500; transition: all 0.3s ease; backdrop-filter: blur(10px); border: 1px solid rgba(255, 255, 255, 0.3); } .nav-link:hover { background: rgba(255, 255, 255, 0.3); transform: translateY(-2px); } </style> </head> <body> <div class="container"> <h1>📄 Page 2 - Template Extended</h1> <div class="success"> <h4>🎉 Template-Based Implementation!</h4> <p>This page extends the main template that includes the chat script. The chat widget appears automatically with conversation persistence!</p> </div> <div class="demo-section"> <h2 class="demo-title">✨ Automatic Chat Widget</h2> <p class="demo-description"> This page extends the main template (which includes the chat script). The chat widget should automatically appear in the bottom-right corner with the same conversation from previous pages. </p> <div class="success"> <h4>🎉 Success Criteria</h4> <ul> <li>Chat widget appears automatically (inherited from template)</li> <li>Same conversation ID as previous pages</li> <li>Previous messages are remembered</li> <li>New messages continue the conversation</li> <li>No script includes needed in this page</li> </ul> </div> <div class="button-container"> <button class="button" onclick="if(window.SpectrumChatGlobal) window.SpectrumChatGlobal.open(); else alert('Chat widget not available')">Open Chat</button> <button class="button" onclick="if(window.SpectrumChatGlobal) alert('Conversation ID: ' + (window.SpectrumChatGlobal.getConversationId() || 'No conversation started yet')); else alert('Chat widget not available')">Get Conversation ID</button> <button class="button" onclick="if(window.SpectrumChatGlobal) window.SpectrumChatGlobal.close(); else alert('Chat widget not available')">Close Chat</button> </div> </div> <div class="demo-section"> <h2 class="demo-title">🔍 Test Cross-Page Persistence</h2> <p class="demo-description"> If you started a conversation on previous pages, it should continue here seamlessly. Try sending a message that references something from the previous pages. </p> </div> <div class="nav-links"> <a href="template-home.html" class="nav-link">🏠 Home Page</a> <a href="template-page1.html" class="nav-link">📄 Page 1</a> <a href="template-page3.html" class="nav-link">📄 Page 3</a> </div> </div> <script> console.log('Template Page 2 loaded - extends main template!'); console.log('SpectrumChatGlobal available:', !!window.SpectrumChatGlobal); // Log when the page loads setTimeout(() => { if (window.SpectrumChatGlobal) { const convId = window.SpectrumChatGlobal.getConversationId(); console.log('Current conversation ID on Page 2:', convId); if (convId) { console.log('✅ SUCCESS: Conversation ID persisted from previous pages:', convId); } else { console.log('â„šī¸ INFO: No conversation started yet'); } } else { console.log('❌ ERROR: SpectrumChatGlobal not available - check if script is loaded'); } }, 1000); </script> </body> </html>