export function aiReadinessQuiz(form: FormTs) {
form.setTitle(() => '🤖 Is Your Company Ready for AI?');
// ========== STATE ==========
type CategoryKey = 'data' | 'infrastructure' | 'talent' | 'strategy' | 'culture';
const scores = form.state<Record<CategoryKey, number>>({
data: 0,
infrastructure: 0,
talent: 0,
strategy: 0,
culture: 0
});
// ========== SCORING FUNCTIONS ==========
const updateScore = (category: CategoryKey, points: number) => {
scores.update(current => ({
...current,
[category]: (current[category] || 0) + points
}));
};
const getTotalScore = () => {
const s = scores();
return (Object.values(s) as number[]).reduce((sum: number, val: number) => sum + val, 0);
};
const getMaxScore = () => 100;
const getScorePercentage = () => Math.round((getTotalScore() / getMaxScore()) * 100);
type ReadinessLevel = 'leader' | 'advancing' | 'developing' | 'exploring' | 'starting';
const getReadinessLevel = (): ReadinessLevel => {
const pct = getScorePercentage();
if (pct >= 80) return 'leader';
if (pct >= 60) return 'advancing';
if (pct >= 40) return 'developing';
if (pct >= 20) return 'exploring';
return 'starting';
};
const getReadinessLabel = () => {
const level = getReadinessLevel();
const labels: Record<ReadinessLevel, string> = {
leader: 'AI Leader',
advancing: 'AI Advancing',
developing: 'AI Developing',
exploring: 'AI Exploring',
starting: 'AI Starting'
};
return labels[level];
};
const getReadinessDescription = () => {
const level = getReadinessLevel();
const descriptions: Record<ReadinessLevel, string> = {
leader: 'Your organization is well-positioned to lead AI initiatives. You have strong foundations across data, infrastructure, talent, and culture.',
advancing: 'You\'re making good progress on your AI journey. Focus on strengthening weaker areas to become an AI leader.',
developing: 'You have some AI foundations in place but need to invest in key areas before scaling AI initiatives.',
exploring: 'You\'re in the early stages of AI readiness. Start with foundational data and talent investments.',
starting: 'Your AI journey is just beginning. Focus on building basic data infrastructure and upskilling your team.'
};
return descriptions[level];
};
const getCategoryScore = (category: CategoryKey) => {
const s = scores();
const maxPerCategory = 20;
return Math.round((s[category] / maxPerCategory) * 100);
};
const getWeakestArea = (): CategoryKey => {
const s = scores();
const entries = Object.entries(s) as [CategoryKey, number][];
const sorted = entries.sort((a, b) => a[1] - b[1]);
return sorted[0]?.[0] || 'data';
};
const getCategoryLabel = (category: CategoryKey) => {
const labels: Record<CategoryKey, string> = {
data: 'Data Readiness',
infrastructure: 'Technical Infrastructure',
talent: 'AI Talent & Skills',
strategy: 'AI Strategy',
culture: 'Organizational Culture'
};
return labels[category];
};
// ========== COMPLETION SCREEN ==========
form.configureCompletionScreen({
type: 'text',
title: '🤖 Your AI Readiness Report Is Ready!',
message: () => `Your AI readiness score is ${getScorePercentage()}% (${getReadinessLabel()}). Check your email for your detailed report with personalized recommendations for accelerating your AI journey.`
});
// ========== PAGES ==========
const pages = form.addPages('quiz-pages', { heightMode: 'current-page' });
// ========== PAGE 1: Data Readiness ==========
const page1 = pages.addPage('data-readiness', { mobileBreakpoint: 500 });
page1.addRow(row => {
row.addTextPanel('header1', {
label: 'Step 1 of 7: Data Readiness',
computedValue: () => 'AI needs quality data - let\'s assess your data foundations',
customStyles: { fontSize: '0.9rem', color: '#6b7280', marginBottom: '1rem' }
});
});
page1.addSpacer({ height: '24px' });
page1.addRow(row => {
row.addRadioButton('dataCollection', {
label: 'How would you describe your data collection?',
options: [
{ id: 'advanced', name: 'Automated, centralized, and comprehensive' },
{ id: 'good', name: 'Mostly digitized with some manual processes' },
{ id: 'basic', name: 'Mix of digital and paper-based' },
{ id: 'limited', name: 'Mostly manual with scattered data sources' }
],
orientation: 'vertical',
onValueChange: (v) => {
if (v === 'advanced') updateScore('data', 5);
else if (v === 'good') updateScore('data', 4);
else if (v === 'basic') updateScore('data', 2);
else if (v === 'limited') updateScore('data', 1);
}
});
});
page1.addRow(row => {
row.addRadioButton('dataQuality', {
label: 'How confident are you in your data quality?',
options: [
{ id: 'high', name: 'High - we have data governance and quality processes' },
{ id: 'medium', name: 'Medium - some quality issues but manageable' },
{ id: 'low', name: 'Low - significant quality and consistency issues' },
{ id: 'unknown', name: 'Unknown - we haven\'t assessed data quality' }
],
orientation: 'vertical',
onValueChange: (v) => {
if (v === 'high') updateScore('data', 5);
else if (v === 'medium') updateScore('data', 3);
else if (v === 'low') updateScore('data', 1);
else if (v === 'unknown') updateScore('data', 0);
}
});
});
page1.addRow(row => {
row.addSuggestionChips('dataTypes', {
label: 'What types of data do you have access to? (Select all)',
suggestions: [
{ id: 'customer', name: '👥 Customer data' },
{ id: 'transaction', name: '💰 Transaction data' },
{ id: 'operations', name: '⚙️ Operational data' },
{ id: 'market', name: '📊 Market data' },
{ id: 'product', name: '📦 Product data' },
{ id: 'employee', name: '👔 Employee data' }
],
onValueChange: (v) => {
const count = (v || []).length;
updateScore('data', Math.min(count * 2, 10));
}
});
});
// ========== PAGE 2: Technical Infrastructure ==========
const page2 = pages.addPage('infrastructure', { mobileBreakpoint: 500 });
page2.addRow(row => {
row.addTextPanel('header2', {
label: 'Step 2 of 7: Technical Infrastructure',
computedValue: () => 'AI requires the right technical foundation',
customStyles: { fontSize: '0.9rem', color: '#6b7280', marginBottom: '1rem' }
});
});
page2.addSpacer({ height: '24px' });
page2.addRow(row => {
row.addRadioButton('cloudInfra', {
label: 'What is your cloud infrastructure status?',
options: [
{ id: 'mature', name: 'Mature cloud-native with ML platforms (AWS/GCP/Azure ML)' },
{ id: 'hybrid', name: 'Hybrid cloud with some ML capabilities' },
{ id: 'migrating', name: 'Currently migrating to cloud' },
{ id: 'onprem', name: 'Primarily on-premises infrastructure' }
],
orientation: 'vertical',
onValueChange: (v) => {
if (v === 'mature') updateScore('infrastructure', 5);
else if (v === 'hybrid') updateScore('infrastructure', 4);
else if (v === 'migrating') updateScore('infrastructure', 2);
else if (v === 'onprem') updateScore('infrastructure', 1);
}
});
});
page2.addRow(row => {
row.addSuggestionChips('techCapabilities', {
label: 'Which technical capabilities do you have? (Select all)',
suggestions: [
{ id: 'datawarehouse', name: '🏢 Data Warehouse' },
{ id: 'datalake', name: '🌊 Data Lake' },
{ id: 'apis', name: '🔌 APIs/Microservices' },
{ id: 'pipelines', name: '📡 Data Pipelines' },
{ id: 'mlops', name: '🤖 MLOps Tools' },
{ id: 'gpu', name: '⚡ GPU Computing' }
],
onValueChange: (v) => {
const count = (v || []).length;
updateScore('infrastructure', Math.min(Math.round(count * 2.5), 15));
}
});
});
// ========== PAGE 3: AI Talent & Skills ==========
const page3 = pages.addPage('talent', { mobileBreakpoint: 500 });
page3.addRow(row => {
row.addTextPanel('header3', {
label: 'Step 3 of 7: AI Talent & Skills',
computedValue: () => 'People are the most important asset for AI success',
customStyles: { fontSize: '0.9rem', color: '#6b7280', marginBottom: '1rem' }
});
});
page3.addSpacer({ height: '24px' });
page3.addRow(row => {
row.addRadioButton('aiTeam', {
label: 'Do you have dedicated AI/ML talent?',
options: [
{ id: 'team', name: 'Yes, a dedicated AI/ML team (3+ people)' },
{ id: 'some', name: 'A few data scientists/ML engineers' },
{ id: 'analysts', name: 'Data analysts who want to learn AI' },
{ id: 'none', name: 'No dedicated AI talent yet' }
],
orientation: 'vertical',
onValueChange: (v) => {
if (v === 'team') updateScore('talent', 6);
else if (v === 'some') updateScore('talent', 4);
else if (v === 'analysts') updateScore('talent', 2);
else if (v === 'none') updateScore('talent', 0);
}
});
});
page3.addRow(row => {
row.addMatrixQuestion('skillLevels', {
label: 'Rate your organization\'s skill levels:',
rows: [
{ id: 'ml', label: 'Machine Learning', isRequired: true },
{ id: 'data', label: 'Data Engineering', isRequired: true },
{ id: 'analytics', label: 'Data Analytics', isRequired: true },
{ id: 'domain', label: 'AI Domain Knowledge', isRequired: true }
],
columns: [
{ id: 'none', label: 'None' },
{ id: 'basic', label: 'Basic' },
{ id: 'moderate', label: 'Moderate' },
{ id: 'advanced', label: 'Advanced' }
],
onValueChange: (v) => {
if (!v) return;
let skillPoints = 0;
Object.values(v).forEach(level => {
if (level === 'advanced') skillPoints += 3;
else if (level === 'moderate') skillPoints += 2;
else if (level === 'basic') skillPoints += 1;
});
updateScore('talent', Math.min(skillPoints, 14));
}
});
});
// ========== PAGE 4: AI Strategy ==========
const page4 = pages.addPage('strategy', { mobileBreakpoint: 500 });
page4.addRow(row => {
row.addTextPanel('header4', {
label: 'Step 4 of 7: AI Strategy',
computedValue: () => 'A clear AI strategy guides successful implementation',
customStyles: { fontSize: '0.9rem', color: '#6b7280', marginBottom: '1rem' }
});
});
page4.addSpacer({ height: '24px' });
page4.addRow(row => {
row.addRadioButton('aiStrategy', {
label: 'Does your organization have an AI strategy?',
options: [
{ id: 'formal', name: 'Yes, a formal AI strategy with roadmap and KPIs' },
{ id: 'informal', name: 'Informal plans but no formal strategy' },
{ id: 'starting', name: 'Currently developing an AI strategy' },
{ id: 'none', name: 'No AI strategy yet' }
],
orientation: 'vertical',
onValueChange: (v) => {
if (v === 'formal') updateScore('strategy', 6);
else if (v === 'informal') updateScore('strategy', 3);
else if (v === 'starting') updateScore('strategy', 2);
else if (v === 'none') updateScore('strategy', 0);
}
});
});
page4.addRow(row => {
row.addRadioButton('useCases', {
label: 'Have you identified specific AI use cases?',
options: [
{ id: 'prioritized', name: 'Yes, prioritized list with business cases' },
{ id: 'identified', name: 'Some use cases identified but not prioritized' },
{ id: 'exploring', name: 'Still exploring potential use cases' },
{ id: 'none', name: 'Haven\'t identified any yet' }
],
orientation: 'vertical',
onValueChange: (v) => {
if (v === 'prioritized') updateScore('strategy', 6);
else if (v === 'identified') updateScore('strategy', 4);
else if (v === 'exploring') updateScore('strategy', 2);
else if (v === 'none') updateScore('strategy', 0);
}
});
});
page4.addRow(row => {
row.addRadioButton('aiBudget', {
label: 'What\'s your AI investment budget?',
options: [
{ id: 'significant', name: 'Significant dedicated budget (>$500K/year)' },
{ id: 'moderate', name: 'Moderate budget ($100K-$500K/year)' },
{ id: 'small', name: 'Small/pilot budget (<$100K/year)' },
{ id: 'none', name: 'No dedicated AI budget' }
],
orientation: 'vertical',
onValueChange: (v) => {
if (v === 'significant') updateScore('strategy', 8);
else if (v === 'moderate') updateScore('strategy', 5);
else if (v === 'small') updateScore('strategy', 3);
else if (v === 'none') updateScore('strategy', 0);
}
});
});
// ========== PAGE 5: Organizational Culture ==========
const page5 = pages.addPage('culture', { mobileBreakpoint: 500 });
page5.addRow(row => {
row.addTextPanel('header5', {
label: 'Step 5 of 7: Organizational Culture',
computedValue: () => 'Culture determines AI adoption success',
customStyles: { fontSize: '0.9rem', color: '#6b7280', marginBottom: '1rem' }
});
});
page5.addSpacer({ height: '24px' });
page5.addRow(row => {
row.addRatingScale('leadershipSupport', {
label: 'How supportive is leadership of AI initiatives?',
preset: 'custom',
min: 1,
max: 5,
lowLabel: 'Not supportive',
highLabel: 'Highly supportive',
onValueChange: (v) => {
if (v) updateScore('culture', v * 2);
}
});
});
page5.addRow(row => {
row.addRadioButton('changeReadiness', {
label: 'How does your organization handle change?',
options: [
{ id: 'embraces', name: 'Embraces innovation and change' },
{ id: 'accepts', name: 'Generally accepts change with some resistance' },
{ id: 'resistant', name: 'Often resistant to new technologies' },
{ id: 'very_resistant', name: 'Very risk-averse and slow to change' }
],
orientation: 'vertical',
onValueChange: (v) => {
if (v === 'embraces') updateScore('culture', 5);
else if (v === 'accepts') updateScore('culture', 3);
else if (v === 'resistant') updateScore('culture', 1);
else if (v === 'very_resistant') updateScore('culture', 0);
}
});
});
page5.addRow(row => {
row.addRadioButton('dataDecisions', {
label: 'How data-driven is your decision making?',
options: [
{ id: 'very', name: 'Very - most decisions backed by data' },
{ id: 'somewhat', name: 'Somewhat - mix of data and intuition' },
{ id: 'little', name: 'Little - mostly intuition-based decisions' },
{ id: 'none', name: 'Not at all - no data-driven culture' }
],
orientation: 'vertical',
onValueChange: (v) => {
if (v === 'very') updateScore('culture', 5);
else if (v === 'somewhat') updateScore('culture', 3);
else if (v === 'little') updateScore('culture', 1);
else if (v === 'none') updateScore('culture', 0);
}
});
});
// ========== PAGE 6: Results ==========
const page6 = pages.addPage('results', { mobileBreakpoint: 500 });
page6.addRow(row => {
row.addTextPanel('header6', {
label: 'Step 6 of 7: Your AI Readiness Assessment',
computedValue: () => 'Here\'s where your organization stands',
customStyles: { fontSize: '0.9rem', color: '#6b7280', marginBottom: '1rem' }
});
});
page6.addSpacer({ height: '24px' });
page6.addRow(row => {
row.addTextPanel('mainScore', {
label: 'AI Readiness Score',
computedValue: () => `${getScorePercentage()}%`,
customStyles: () => {
const score = getScorePercentage();
return {
fontSize: '56px',
fontWeight: 'bold',
textAlign: 'center',
padding: '20px',
borderRadius: '12px',
color: score >= 60 ? '#059669' : score >= 40 ? '#ca8a04' : '#dc2626',
background: score >= 60 ? '#ecfdf5' : score >= 40 ? '#fefce8' : '#fef2f2'
};
}
});
});
page6.addRow(row => {
row.addTextPanel('readinessLevel', {
label: 'Your Status',
computedValue: () => `🏆 ${getReadinessLabel()}`,
customStyles: { textAlign: 'center', fontSize: '24px', fontWeight: 'bold', padding: '10px' }
});
});
page6.addRow(row => {
row.addTextPanel('readinessDesc', {
label: '',
computedValue: () => getReadinessDescription(),
customStyles: { textAlign: 'center', padding: '15px', background: '#f9fafb', borderRadius: '8px' }
});
});
const categorySection = page6.addSubform('categoryBreakdown', {
title: '📊 Category Breakdown (click to expand)',
isCollapsible: true,
customStyles: { background: '#f9fafb', borderRadius: '8px', marginTop: '20px' }
});
categorySection.addRow(row => {
row.addTextPanel('dataScore', {
label: '📁 Data Readiness',
computedValue: () => `${getCategoryScore('data')}%`,
customStyles: () => ({
padding: '10px',
background: getCategoryScore('data') >= 60 ? '#ecfdf5' : getCategoryScore('data') >= 40 ? '#fefce8' : '#fef2f2',
borderRadius: '4px'
})
});
row.addTextPanel('infraScore', {
label: '🖥️ Infrastructure',
computedValue: () => `${getCategoryScore('infrastructure')}%`,
customStyles: () => ({
padding: '10px',
background: getCategoryScore('infrastructure') >= 60 ? '#ecfdf5' : getCategoryScore('infrastructure') >= 40 ? '#fefce8' : '#fef2f2',
borderRadius: '4px'
})
});
});
categorySection.addRow(row => {
row.addTextPanel('talentScore', {
label: '👥 AI Talent',
computedValue: () => `${getCategoryScore('talent')}%`,
customStyles: () => ({
padding: '10px',
background: getCategoryScore('talent') >= 60 ? '#ecfdf5' : getCategoryScore('talent') >= 40 ? '#fefce8' : '#fef2f2',
borderRadius: '4px'
})
});
row.addTextPanel('strategyScore', {
label: '🎯 AI Strategy',
computedValue: () => `${getCategoryScore('strategy')}%`,
customStyles: () => ({
padding: '10px',
background: getCategoryScore('strategy') >= 60 ? '#ecfdf5' : getCategoryScore('strategy') >= 40 ? '#fefce8' : '#fef2f2',
borderRadius: '4px'
})
});
});
categorySection.addRow(row => {
row.addTextPanel('cultureScore', {
label: '🏢 Culture',
computedValue: () => `${getCategoryScore('culture')}%`,
customStyles: () => ({
padding: '10px',
background: getCategoryScore('culture') >= 60 ? '#ecfdf5' : getCategoryScore('culture') >= 40 ? '#fefce8' : '#fef2f2',
borderRadius: '4px'
})
});
row.addEmpty('1fr');
});
page6.addRow(row => {
row.addTextPanel('priorityArea', {
label: '🎯 Priority Focus Area',
computedValue: () => `Focus on improving your ${getCategoryLabel(getWeakestArea())} - this is your biggest opportunity for AI readiness improvement.`,
customStyles: { padding: '15px', background: '#fef3c7', borderRadius: '8px', marginTop: '15px' }
});
});
// ========== PAGE 7: Lead Capture ==========
const page7 = pages.addPage('lead-capture', { mobileBreakpoint: 500 });
page7.addRow(row => {
row.addTextPanel('header7', {
label: 'Step 7 of 7: Get Your AI Readiness Report',
computedValue: () => 'Receive a detailed action plan for your AI journey',
customStyles: { fontSize: '0.9rem', color: '#6b7280', marginBottom: '1rem' }
});
});
page7.addSpacer({ height: '24px' });
page7.addRow(row => {
row.addTextbox('name', { label: 'Your Name', isRequired: true, placeholder: 'John Smith' }, '1fr');
row.addEmail('email', { label: 'Work Email', isRequired: true, placeholder: 'john@company.com' }, '1fr');
});
page7.addRow(row => {
row.addTextbox('company', { label: 'Company Name', isRequired: true, placeholder: 'Acme Inc.' }, '1fr');
row.addDropdown('companySize', {
label: 'Company Size',
options: [
{ id: 'startup', name: '1-50 employees' },
{ id: 'small', name: '51-200 employees' },
{ id: 'medium', name: '201-1000 employees' },
{ id: 'large', name: '1000+ employees' }
]
}, '1fr');
});
page7.addRow(row => {
row.addDropdown('industry', {
label: 'Industry',
options: [
{ id: 'tech', name: 'Technology' },
{ id: 'finance', name: 'Financial Services' },
{ id: 'healthcare', name: 'Healthcare' },
{ id: 'retail', name: 'Retail/E-commerce' },
{ id: 'manufacturing', name: 'Manufacturing' },
{ id: 'other', name: 'Other' }
]
}, '1fr');
row.addDropdown('role', {
label: 'Your Role',
options: [
{ id: 'exec', name: 'Executive/C-Level' },
{ id: 'director', name: 'Director/VP' },
{ id: 'manager', name: 'Manager' },
{ id: 'technical', name: 'Technical Lead' },
{ id: 'other', name: 'Other' }
]
}, '1fr');
});
page7.addRow(row => {
row.addCheckboxList('consent', {
options: [
{ id: 'report', name: '📄 Send me the detailed AI Readiness Report with action plan', isRequired: true },
{ id: 'consultation', name: '📞 I\'d like a free AI readiness consultation' },
{ id: 'newsletter', name: '💡 Subscribe to AI implementation insights' }
],
defaultValue: ['report'],
orientation: 'vertical'
});
});
// ========== SUBMIT BUTTON ==========
form.configureSubmitButton({
label: () => `🤖 Get My AI Readiness Report (Score: ${getScorePercentage()}%)`
});
// ========== PDF REPORT ==========
form.configurePdf('ai-readiness-report', pdf => {
pdf.configure({
filename: 'ai-readiness-assessment.pdf',
pageSize: 'A4',
allowUserDownload: true,
downloadButtonLabel: '🤖 Download AI Readiness Report',
header: {
title: 'AI Readiness Assessment',
subtitle: 'Your Personalized AI Implementation Guide'
},
footer: {
text: 'Generated by FormTs',
showPageNumbers: true
}
});
pdf.addSection('Executive Summary', section => {
section.addRow(row => {
row.addField('Overall Score', `${getScorePercentage()}%`);
row.addField('Readiness Level', getReadinessLabel());
});
section.addText(getReadinessDescription());
});
pdf.addSection('Category Scores', section => {
section.addTable(
['Category', 'Score', 'Status'],
[
['Data Readiness', `${getCategoryScore('data')}%`, getCategoryScore('data') >= 60 ? '✅ Good' : '⚠️ Needs Work'],
['Infrastructure', `${getCategoryScore('infrastructure')}%`, getCategoryScore('infrastructure') >= 60 ? '✅ Good' : '⚠️ Needs Work'],
['AI Talent', `${getCategoryScore('talent')}%`, getCategoryScore('talent') >= 60 ? '✅ Good' : '⚠️ Needs Work'],
['AI Strategy', `${getCategoryScore('strategy')}%`, getCategoryScore('strategy') >= 60 ? '✅ Good' : '⚠️ Needs Work'],
['Culture', `${getCategoryScore('culture')}%`, getCategoryScore('culture') >= 60 ? '✅ Good' : '⚠️ Needs Work']
]
);
});
pdf.addPageBreak();
pdf.addSection('Priority Focus Area', section => {
section.addText(`Your biggest improvement opportunity: ${getCategoryLabel(getWeakestArea())}`);
});
pdf.addSection('Recommended Next Steps', section => {
section.addText('1. Address your priority focus area identified above');
section.addText('2. Identify 2-3 high-value AI use cases for your industry');
section.addText('3. Build or hire foundational AI/ML talent');
section.addText('4. Establish data governance and quality processes');
section.addText('5. Create a formal AI strategy with executive sponsorship');
section.addText('6. Start with a pilot project to build organizational confidence');
});
pdf.addSection('AI Implementation Timeline', section => {
section.addTable(
['Phase', 'Focus', 'Duration'],
[
['Foundation', 'Data infrastructure, talent acquisition', '3-6 months'],
['Pilot', 'First AI use case implementation', '2-4 months'],
['Scale', 'Expand successful pilots', '6-12 months'],
['Optimize', 'MLOps, continuous improvement', 'Ongoing']
]
);
});
});
form.configureSubmitBehavior({ sendToServer: true });
}