/** * PersonaFlow - Onboarding Flow * Multi-step welcome modal shown once to new users */ const Onboarding = { currentStep: 0, steps: [ { icon: '', title: 'Welcome to PersonaFlow!', desc: 'You\'re about to build your first AI conversation agent. It takes less than 2 minutes and no technical knowledge required.', visual: `
Create Agents
Chat & Video Call
Get Reports
` }, { icon: '', title: 'What is an AI Agent?', desc: 'An agent is an AI persona with a specific role, personality, and purpose — like a Sales Coach, Customer Support Rep, or Interview Trainer.', visual: `
Example: Sales Coach Agent
"Tell me about your product. I'm looking for something to solve our reporting problem..."
"Sure! Our platform integrates with all your existing tools and cuts report time by 80%..."
` }, { icon: '', title: 'Three ways to start', desc: 'Create an agent from scratch, use a pre-built template, or use the shared link someone sent you.', visual: `
Templates
Start with Sales Coach, Interview Prep, and more — ready in 1 click
Build from Scratch
Full 4-step wizard to define role, behavior, output & appearance
Share Links
Share any agent via a link — with password, expiry & usage limits
` }, { icon: '', title: 'You\'re all set!', desc: 'Let\'s create your first agent. Try a template for the fastest start, or build one from scratch.', visual: `
Browse Templates Build from Scratch
` } ], shouldShow() { return !localStorage.getItem('pf-onboarded'); }, show() { if (!this.shouldShow()) return; this.currentStep = 0; this.renderModal(); }, renderModal() { // Dismiss any existing onboarding modal first document.getElementById('onboarding-overlay')?.remove(); const step = this.steps[this.currentStep]; const total = this.steps.length; const isLast = this.currentStep === total - 1; const overlay = document.createElement('div'); overlay.id = 'onboarding-overlay'; overlay.style.cssText = ` position: fixed; inset: 0; z-index: 9999; background: rgba(0,0,0,0.6); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; animation: fadeIn 0.2s ease; `; overlay.innerHTML = `
${this.steps.map((_, i) => `
`).join('')}
${step.icon}

${step.title}

${step.desc}

${step.visual} ${!isLast ? `
` : ''}
`; document.body.appendChild(overlay); // Close on backdrop click overlay.addEventListener('click', (e) => { if (e.target === overlay) this.finish(); }); }, next() { if (this.currentStep < this.steps.length - 1) { this.currentStep++; this.renderModal(); } }, prev() { if (this.currentStep > 0) { this.currentStep--; this.renderModal(); } }, finish() { localStorage.setItem('pf-onboarded', '1'); const overlay = document.getElementById('onboarding-overlay'); if (overlay) { overlay.style.animation = 'fadeOut 0.2s ease forwards'; setTimeout(() => overlay.remove(), 200); } } };