UNPKG

sandia-chatbot-widget

Version:

Production-ready Sandia AI Chatbot Widget v3.0 with advanced themes, animations, notifications, and enterprise features

637 lines (532 loc) โ€ข 14.7 kB
# Sandia AI Chatbot Widget v3.0 - Production Ready ๐Ÿš€ **The most advanced, feature-rich chatbot widget for seamless AI assistant integration into any website or application.** [![NPM Version](https://img.shields.io/npm/v/sandia-chatbot-widget?color=blue)](https://www.npmjs.com/package/sandia-chatbot-widget) [![Downloads](https://img.shields.io/npm/dm/sandia-chatbot-widget)](https://www.npmjs.com/package/sandia-chatbot-widget) [![License](https://img.shields.io/npm/l/sandia-chatbot-widget)](LICENSE) ## ๐ŸŒŸ **What's New in v3.0** โœจ **4 Beautiful Themes** - Modern, Classic, Minimal, Gradient ๐ŸŽจ **Advanced Animations** - Smooth, Bouncy, Slide, Fade effects ๐Ÿ”” **Smart Notifications** - Browser notifications & sound alerts ๐Ÿ“ฑ **Mobile Excellence** - Full-screen mode & touch optimization ๐ŸŽฏ **Accessibility First** - WCAG compliant with screen reader support ๐Ÿ’ฌ **Rich Conversations** - Message timestamps, copy functionality, reactions ๐Ÿ“Ž **File Uploads** - Drag & drop with progress indicators ๐ŸŽค **Voice Input** - Speech-to-text capabilities (coming soon) โšก **Performance** - Lazy loading, virtual scrolling, optimized rendering ๐Ÿ”ง **Developer Tools** - Enhanced APIs, debugging, and customization --- ## ๐Ÿš€ **Quick Start** ### **NPM Installation** ```bash npm install sandia-chatbot-widget@3.0.0 ``` ### **React Integration - Production Ready** ```tsx import { SandiaWidget } from 'sandia-chatbot-widget'; function App() { return ( <SandiaWidget chatbotId="your-chatbot-id" styles={{ theme: 'modern', primaryColor: '#006FEE', shadowStyle: 'soft', animation: 'smooth', darkMode: false, showTimestamps: true, allowFileUpload: true, soundEnabled: true, notificationsEnabled: true }} chatConfig={{ quickReplies: ['Hello', 'Help me', 'Learn more'], maxFileSize: 10, voiceEnabled: true }} onMessage={(msg) => console.log('New message:', msg)} onFileUpload={(file) => console.log('File uploaded:', file.name)} /> ); } ``` ### **Vanilla JavaScript - Enhanced** ```html <!DOCTYPE html> <html> <head> <script> window.SandiaChatbot = { chatbotId: 'your-chatbot-id', version: '3.0', styles: { theme: 'gradient', primaryColor: '#006FEE', shadowStyle: 'glow', animation: 'bouncy', showAvatar: true, showTimestamps: true, soundEnabled: true, notificationsEnabled: true, darkMode: false, autoMinimize: 5 }, chatConfig: { quickReplies: ['Hi there!', 'How can you help?', 'Tell me more'], allowedFileTypes: ['image/*', '.pdf', '.txt'], maxFileSize: 10 } }; </script> <script src="https://unpkg.com/sandia-chatbot-widget@3.0.0/dist/vanilla.js"></script> </head> <body> <!-- Your content --> </body> </html> ``` --- ## ๐ŸŽจ **Theme Showcase** ### **Modern Theme (Default)** ```tsx <SandiaWidget chatbotId="your-id" styles={{ theme: 'modern', primaryColor: '#006FEE', shadowStyle: 'soft', animation: 'smooth' }} /> ``` ### **Gradient Theme** ```tsx <SandiaWidget chatbotId="your-id" styles={{ theme: 'gradient', primaryColor: '#006FEE', shadowStyle: 'glow', animation: 'bouncy' }} /> ``` ### **Classic Corporate** ```tsx <SandiaWidget chatbotId="your-id" styles={{ theme: 'classic', primaryColor: '#1e40af', shadowStyle: 'hard', size: 'lg', customIcon: '๐Ÿข', greeting: 'Welcome to our support center' }} /> ``` ### **Minimal Design** ```tsx <SandiaWidget chatbotId="your-id" styles={{ theme: 'minimal', primaryColor: '#059669', shadowStyle: 'none', animation: 'fade', borderRadius: 12 }} /> ``` --- ## ๐Ÿ”ง **Production Configuration** ### **Complete Styling Options** ```typescript interface WidgetStyles { // Theme System theme?: 'modern' | 'classic' | 'minimal' | 'gradient'; shadowStyle?: 'soft' | 'hard' | 'glow' | 'none'; animation?: 'smooth' | 'bouncy' | 'slide' | 'fade' | 'none'; // Basic Appearance position?: 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left'; primaryColor?: string; backgroundColor?: string; textColor?: string; borderRadius?: number; size?: 'sm' | 'md' | 'lg'; // Advanced Features darkMode?: boolean; showAvatar?: boolean; showTimestamps?: boolean; soundEnabled?: boolean; notificationsEnabled?: boolean; allowFileUpload?: boolean; showTypingIndicator?: boolean; // Conversation Management messagePersistence?: boolean; maxMessages?: number; autoMinimize?: number; // minutes // Customization customAvatar?: string; customIcon?: string; greeting?: string; customCSS?: string; brandingEnabled?: boolean; // Accessibility highContrast?: boolean; reducedMotion?: boolean; // Mobile mobileFullScreen?: boolean; swipeToClose?: boolean; } ``` ### **Chat Configuration** ```typescript interface ChatConfiguration { // Quick Actions quickReplies?: string[]; // File Upload allowedFileTypes?: string[]; maxFileSize?: number; // MB // Voice Features voiceEnabled?: boolean; voiceLanguage?: string; // Performance messagesPerMinute?: number; // Analytics trackingEnabled?: boolean; customEvents?: string[]; } ``` --- ## ๐ŸŽฏ **Enterprise Features** ### **Advanced Event Handling** ```tsx <SandiaWidget chatbotId="your-id" // Core Events onReady={() => console.log('Widget ready')} onOpen={() => analytics.track('chat_opened')} onClose={() => analytics.track('chat_closed')} onMinimize={() => analytics.track('chat_minimized')} onRestore={() => analytics.track('chat_restored')} // Message Events onMessage={(msg) => { console.log('Message:', msg); // Save to your analytics analytics.track('message_sent', { role: msg.role, timestamp: msg.timestamp, length: msg.content.length }); }} onTyping={(isTyping) => console.log('User typing:', isTyping)} // Advanced Events onFileUpload={(file) => { console.log('File upload:', file.name, file.size); // Handle file processing }} onVoiceStart={() => console.log('Voice recording started')} onVoiceEnd={(transcript) => console.log('Voice:', transcript)} // Error Handling onError={(error) => { console.error('Chat error:', error); // Report to error tracking }} onSubscriptionError={(error) => { console.warn('Subscription issue:', error); // Handle billing issues }} /> ``` ### **API Access & Control** ```javascript // Global API for advanced control window.SandiaChatbotAPI.open(); window.SandiaChatbotAPI.close(); window.SandiaChatbotAPI.minimize(); window.SandiaChatbotAPI.restore(); // Send programmatic messages window.SandiaChatbotAPI.sendMessage('Hello from the website!'); // Update configuration dynamically window.SandiaChatbotAPI.updateConfig({ primaryColor: '#ff6b35', theme: 'gradient' }); // Manage notifications window.SandiaChatbotAPI.updateBadge(5); window.SandiaChatbotAPI.resetUnreadCount(); // Get widget state const isOpen = window.SandiaChatbotAPI.isOpen(); const messages = window.SandiaChatbotAPI.getMessages(); const config = window.SandiaChatbotAPI.getConfig(); ``` --- ## ๐Ÿ“ฑ **Mobile Excellence** ### **Responsive Design** - **Auto-detection** of mobile devices - **Full-screen mode** on mobile for better UX - **Touch-optimized** buttons and interactions - **Swipe gestures** for navigation - **iOS zoom prevention** with proper input handling ### **Mobile-Specific Configuration** ```tsx <SandiaWidget chatbotId="your-id" styles={{ mobileFullScreen: true, swipeToClose: true, position: 'bottom-right', // Auto-adjusts on mobile size: 'lg' // Better visibility on mobile }} /> ``` --- ## โ™ฟ **Accessibility & Compliance** ### **WCAG 2.1 AA Compliant** - โœ… **Screen reader support** with proper ARIA labels - โœ… **Keyboard navigation** for all interactions - โœ… **High contrast mode** support - โœ… **Reduced motion** preferences - โœ… **Focus management** and visual indicators - โœ… **Color contrast** meeting accessibility standards ### **Accessibility Configuration** ```tsx <SandiaWidget chatbotId="your-id" styles={{ highContrast: true, reducedMotion: true, // Widget automatically adapts to user preferences }} /> ``` --- ## ๐Ÿ”” **Notifications & Alerts** ### **Smart Notification System** - **Browser notifications** for new messages when chat is closed - **Sound effects** for message alerts and interactions - **Visual badges** with unread message counts - **Auto-minimize** after inactivity periods ### **Notification Setup** ```tsx <SandiaWidget chatbotId="your-id" styles={{ soundEnabled: true, notificationsEnabled: true, autoMinimize: 5 // Auto-minimize after 5 minutes }} onMessage={(msg) => { // Custom notification handling if (!document.hasFocus() && msg.role === 'assistant') { new Notification('New message from support', { body: msg.content.substring(0, 100), icon: '/your-icon.png' }); } }} /> ``` --- ## ๐Ÿ“Š **Analytics Integration** ### **Google Analytics 4** ```tsx <SandiaWidget chatbotId="your-id" onMessage={(message) => { gtag('event', 'chat_message', { event_category: 'chat', event_label: message.role, custom_parameter_1: message.content.length }); }} onOpen={() => { gtag('event', 'chat_opened', { event_category: 'engagement' }); }} /> ``` ### **Custom Analytics** ```tsx <SandiaWidget chatbotId="your-id" metadata={{ userId: user.id, sessionId: sessionStorage.getItem('session'), page: window.location.pathname, source: 'homepage' }} onMessage={(msg) => { analytics.track('Chat Message', { direction: msg.role, timestamp: msg.timestamp, messageLength: msg.content.length, conversationLength: messages.length }); }} /> ``` --- ## ๐ŸŒ **Multi-Language Support** ### **Internationalization Ready** ```tsx <SandiaWidget chatbotId="your-id" styles={{ greeting: t('chat.welcome_message'), customIcon: '๐ŸŒ' }} chatConfig={{ quickReplies: [ t('chat.quick.hello'), t('chat.quick.help'), t('chat.quick.contact') ], voiceLanguage: locale // 'en-US', 'es-ES', 'fr-FR', etc. }} /> ``` --- ## ๐ŸŽ›๏ธ **Framework Integration** ### **Next.js (Recommended)** ```tsx import dynamic from 'next/dynamic'; const SandiaWidget = dynamic( () => import('sandia-chatbot-widget').then(mod => mod.SandiaWidget), { ssr: false, loading: () => <div>Loading chat...</div> } ); export default function Layout({ children }) { return ( <> {children} <SandiaWidget chatbotId={process.env.NEXT_PUBLIC_CHATBOT_ID} styles={{ theme: 'modern', primaryColor: '#006FEE' }} /> </> ); } ``` ### **Vue.js 3** ```vue <template> <div id="app"> <!-- Your content --> </div> </template> <script setup> import { onMounted } from 'vue'; import { initSandiaChatbot } from 'sandia-chatbot-widget'; onMounted(() => { initSandiaChatbot({ chatbotId: 'your-chatbot-id', styles: { theme: 'gradient', primaryColor: '#006FEE' } }); }); </script> ``` ### **Angular** ```typescript import { Component, OnInit } from '@angular/core'; import { initSandiaChatbot } from 'sandia-chatbot-widget'; @Component({ selector: 'app-root', template: '<div>Your content</div>' }) export class AppComponent implements OnInit { ngOnInit() { initSandiaChatbot({ chatbotId: 'your-chatbot-id', styles: { theme: 'modern', primaryColor: '#006FEE', darkMode: true } }); } } ``` --- ## ๐Ÿ”’ **Security & Performance** ### **Enterprise Security** - ๐Ÿ” **Token-based authentication** for private chatbots - ๐ŸŒ **Domain validation** and CORS protection - ๐Ÿ›ก๏ธ **Rate limiting** protection - ๐Ÿ”’ **HTTPS encryption** for all communications - ๐Ÿ“Š **Audit logging** for compliance ### **Performance Optimizations** - โšก **Lazy loading** of components - ๐Ÿ—ƒ๏ธ **Virtual scrolling** for long conversations - ๐Ÿ’พ **Smart caching** of messages and assets - ๐Ÿ“ฆ **Code splitting** for optimal bundle size - ๐Ÿ”„ **Efficient re-rendering** with React optimization --- ## ๐Ÿงช **Testing & Debugging** ### **Debug Mode** ```tsx <SandiaWidget chatbotId="your-id" debug={true} // Enables detailed console logging version="3.0" // Specify API version /> ``` ### **Testing Environment** ```bash # Test with different configurations npm run test:widget # Visual regression testing npm run test:visual # Performance testing npm run test:performance ``` --- ## ๐Ÿ“š **Migration Guide v2 โ†’ v3** ### **Breaking Changes** - Minimum React version: 16.8+ (for hooks) - New required peer dependencies for enhanced features - Updated event handler signatures include timestamps ### **Migration Steps** 1. **Update package**: `npm install sandia-chatbot-widget@3.0.0` 2. **Update styles**: Add new v3.0 style properties 3. **Update events**: Use new enhanced event signatures 4. **Test thoroughly**: Verify all functionality works as expected ### **Backward Compatibility** Most v2 configurations continue to work with v3, but you'll miss out on the new features. --- ## ๐Ÿ†˜ **Support & Resources** ### **Documentation** - ๐Ÿ“– **[Complete API Reference](https://docs.sandia.chat/api)** - ๐ŸŽฅ **[Video Tutorials](https://docs.sandia.chat/tutorials)** - ๐Ÿ’ก **[Best Practices](https://docs.sandia.chat/best-practices)** - ๐Ÿ”ง **[Troubleshooting Guide](https://docs.sandia.chat/troubleshooting)** ### **Community & Support** - ๐Ÿ’ฌ **[Discord Community](https://discord.gg/sandia)** - ๐Ÿ“ง **Email**: support@sandia.chat - ๐Ÿ› **[GitHub Issues](https://github.com/sandia-ai/sandia-chatbot/issues)** - ๐Ÿ“ **[Feature Requests](https://feedback.sandia.chat)** ### **Professional Services** - ๐Ÿข **Enterprise Support** available - ๐ŸŽจ **Custom Theming** services - ๐Ÿ”ง **Integration Consulting** - ๐Ÿ“Š **Analytics Setup** assistance --- ## ๐Ÿ“„ **License** MIT License - free for commercial use. --- ## ๐Ÿš€ **Get Started Today** Ready to integrate the most advanced chatbot widget available? 1. **[Sign up for Sandia AI](https://sandia.chat/signup)** 2. **Create your first chatbot** 3. **Get your chatbot ID** 4. **Install and integrate in minutes!** **Transform your website's user engagement with Sandia AI Chatbot Widget v3.0** โœจ