export function cesStandardSurvey(form: FormTs) {
// Customer Effort Score (CES) Survey
// Demonstrates: RatingScale (CES preset), ThumbRating, EmojiRating, MatrixQuestion, conditional visibility
// ============================================
// HEADER
// ============================================
form.addRow(row => {
row.addTextPanel('header', {
label: 'How Was Your Experience?',
computedValue: () => 'We want to make sure getting help is always easy for you.',
customStyles: {
backgroundColor: '#0891b2',
color: 'white',
padding: '24px',
borderRadius: '12px',
textAlign: 'center'
}
});
});
// ============================================
// SECTION 1: Customer Effort Score
// ============================================
const cesSection = form.addSubform('cesSection', {
title: 'Effort Rating',
customStyles: () => {
const score = cesSection.ratingScale('effortScore')?.value();
if (score === null || score === undefined) {
return { padding: '16px', borderRadius: '8px', border: '1px dashed #cbd5e1' };
}
if (score >= 5) return { backgroundColor: '#d1fae5', padding: '16px', borderRadius: '8px' };
if (score >= 3) return { backgroundColor: '#fef3c7', padding: '16px', borderRadius: '8px' };
return { backgroundColor: '#fee2e2', padding: '16px', borderRadius: '8px' };
}
});
cesSection.addRow(row => {
row.addRatingScale('effortScore', {
preset: 'ces',
label: 'How easy was it to get your issue resolved today?',
showSegmentColors: false,
size: 'lg',
isRequired: true
});
});
// Dynamic feedback based on effort level
cesSection.addRow(row => {
row.addTextPanel('effortFeedback', {
isVisible: () => cesSection.ratingScale('effortScore')?.value() !== null,
computedValue: () => {
const score = cesSection.ratingScale('effortScore')?.value();
if (score === null || score === undefined) return '';
if (score >= 6) return 'Excellent! We are glad the experience was effortless.';
if (score >= 4) return 'Thank you for your feedback. We are always working to improve.';
return 'We are sorry it was difficult. Your feedback helps us do better.';
},
customStyles: () => {
const score = cesSection.ratingScale('effortScore')?.value();
const baseStyle = { padding: '12px', borderRadius: '6px', textAlign: 'center', fontStyle: 'italic' };
if (score === null || score === undefined) return baseStyle;
if (score >= 6) return { ...baseStyle, color: '#065f46', backgroundColor: '#ecfdf5' };
if (score >= 4) return { ...baseStyle, color: '#92400e', backgroundColor: '#fffbeb' };
return { ...baseStyle, color: '#991b1b', backgroundColor: '#fef2f2' };
}
});
});
// ============================================
// SECTION 2: Resolution Status
// ============================================
const resolutionSection = form.addSubform('resolutionSection', {
title: 'Issue Resolution',
isVisible: () => cesSection.ratingScale('effortScore')?.value() !== null
});
resolutionSection.addRow(row => {
row.addThumbRating('issueResolved', {
label: 'Was your issue fully resolved?',
showLabels: true,
upLabel: 'Yes, resolved',
downLabel: 'No, not resolved',
size: 'lg',
alignment: 'center'
});
});
// Unresolved follow-up
resolutionSection.addSpacer({ height: '16px' });
resolutionSection.addRow(row => {
row.addTextarea('unresolvedDetails', {
label: 'What is still unresolved?',
placeholder: 'Please describe what we can do to help...',
rows: 3,
isVisible: () => resolutionSection.thumbRating('issueResolved')?.value() === 'down',
isRequired: () => resolutionSection.thumbRating('issueResolved')?.value() === 'down'
});
});
// ============================================
// SECTION 3: Pain Points (for high effort)
// ============================================
const painPointsSection = form.addSubform('painPointsSection', {
title: 'What Made It Difficult?',
isVisible: () => {
const score = cesSection.ratingScale('effortScore')?.value();
return score !== null && score !== undefined && score <= 3;
},
customStyles: { backgroundColor: '#fef2f2', padding: '16px', borderRadius: '8px' }
});
painPointsSection.addRow(row => {
row.addCheckboxList('painPoints', {
label: 'Select all that apply:',
options: [
{ id: 'wait-time', name: 'Long wait times' },
{ id: 'transfers', name: 'Transferred multiple times' },
{ id: 'repeat-info', name: 'Had to repeat my information' },
{ id: 'unclear', name: 'Unclear instructions' },
{ id: 'knowledge', name: 'Agent lacked knowledge' },
{ id: 'tools', name: 'Technical issues/tools not working' },
{ id: 'policy', name: 'Unhelpful policies' },
{ id: 'follow-up', name: 'Required multiple follow-ups' }
],
orientation: 'vertical'
});
});
painPointsSection.addSpacer({ height: '16px' });
painPointsSection.addRow(row => {
row.addTextarea('painPointDetails', {
label: 'Please share more details about what went wrong',
placeholder: 'Your detailed feedback helps us improve our processes...',
rows: 3
});
});
// ============================================
// SECTION 4: Success Factors (for low effort)
// ============================================
const successSection = form.addSubform('successSection', {
title: 'What Worked Well?',
isVisible: () => {
const score = cesSection.ratingScale('effortScore')?.value();
return score !== null && score !== undefined && score >= 5;
},
customStyles: { backgroundColor: '#ecfdf5', padding: '16px', borderRadius: '8px' }
});
successSection.addRow(row => {
row.addCheckboxList('successFactors', {
label: 'What made your experience smooth?',
options: [
{ id: 'quick-response', name: 'Quick response time' },
{ id: 'first-contact', name: 'Resolved on first contact' },
{ id: 'knowledgeable', name: 'Knowledgeable agent' },
{ id: 'clear-comm', name: 'Clear communication' },
{ id: 'proactive', name: 'Proactive follow-up' },
{ id: 'self-service', name: 'Easy self-service options' },
{ id: 'empathy', name: 'Agent showed empathy' },
{ id: 'exceeded', name: 'Exceeded my expectations' }
],
orientation: 'vertical'
});
});
// ============================================
// SECTION 5: Channel & Agent Evaluation
// ============================================
const evaluationSection = form.addSubform('evaluationSection', {
title: 'Rate Your Experience',
isVisible: () => cesSection.ratingScale('effortScore')?.value() !== null
});
evaluationSection.addRow(row => {
row.addRadioButton('channel', {
label: 'How did you contact us?',
options: [
{ id: 'phone', name: 'Phone' },
{ id: 'chat', name: 'Live Chat' },
{ id: 'email', name: 'Email' },
{ id: 'self-service', name: 'Self-Service' }
],
orientation: 'horizontal'
});
});
evaluationSection.addSpacer({ height: '16px' });
evaluationSection.addRow(row => {
row.addMatrixQuestion('serviceMatrix', {
label: 'Please rate the following aspects:',
rows: [
{ id: 'response-time', label: 'Response time', isRequired: true },
{ id: 'communication', label: 'Communication clarity' },
{ id: 'professionalism', label: 'Professionalism' },
{ id: 'solution-quality', label: 'Quality of solution' }
],
columns: [
{ id: '1', label: 'Poor' },
{ id: '2', label: 'Fair' },
{ id: '3', label: 'Good' },
{ id: '4', label: 'Very Good' },
{ id: '5', label: 'Excellent' }
],
striped: true,
fullWidth: true
});
});
// ============================================
// SECTION 6: Overall Satisfaction
// ============================================
const satisfactionSection = form.addSubform('satisfactionSection', {
title: 'Overall Impression',
isVisible: () => cesSection.ratingScale('effortScore')?.value() !== null
});
satisfactionSection.addRow(row => {
row.addEmojiRating('overallSatisfaction', {
label: 'How satisfied are you with the overall support experience?',
preset: 'satisfaction',
size: 'lg',
showLabels: true,
alignment: 'center'
});
});
satisfactionSection.addSpacer({ height: '16px' });
satisfactionSection.addRow(row => {
row.addStarRating('agentRating', {
label: () => {
const channel = evaluationSection.radioButton('channel')?.value();
if (channel === 'self-service') return 'Rate the self-service experience';
return 'Rate your support agent';
},
maxStars: 5,
size: 'lg',
alignment: 'center',
showConfettiOnMax: true
});
});
// ============================================
// SECTION 7: Additional Comments
// ============================================
const commentsSection = form.addSubform('commentsSection', {
title: 'Any Additional Comments?',
isVisible: () => cesSection.ratingScale('effortScore')?.value() !== null
});
commentsSection.addRow(row => {
row.addTextarea('additionalComments', {
label: 'Share any other feedback that would help us improve',
placeholder: 'Your suggestions are valuable to us...',
rows: 3,
autoExpand: true
});
});
// ============================================
// SECTION 8: Summary
// ============================================
const summarySection = form.addSubform('summarySection', {
title: 'Your Feedback Summary',
isVisible: () => cesSection.ratingScale('effortScore')?.value() !== null
});
summarySection.addRow(row => {
row.addTextPanel('summaryContent', {
computedValue: () => {
const effortScore = cesSection.ratingScale('effortScore')?.value();
const resolved = resolutionSection.thumbRating('issueResolved')?.value();
const satisfaction = satisfactionSection.emojiRating('overallSatisfaction')?.value();
const agentRating = satisfactionSection.starRating('agentRating')?.value();
const channel = evaluationSection.radioButton('channel')?.value();
if (effortScore === null || effortScore === undefined) return '';
let effortLevel = 'High Effort';
let emoji = '';
if (effortScore >= 6) { effortLevel = 'Very Easy'; emoji = ''; }
else if (effortScore >= 4) { effortLevel = 'Moderate'; emoji = ''; }
else { emoji = ''; }
let summary = `${emoji} CES Feedback Summary\n`;
summary += `${'='.repeat(28)}\n\n`;
summary += `Effort Score: ${effortScore}/7 (${effortLevel})\n`;
if (resolved) {
summary += `Issue Resolved: ${resolved === 'up' ? 'Yes' : 'No'}\n`;
}
if (channel) {
const channelLabels: Record<string, string> = {
'phone': 'Phone',
'chat': 'Live Chat',
'email': 'Email',
'self-service': 'Self-Service'
};
summary += `Contact Channel: ${channelLabels[channel] || channel}\n`;
}
if (satisfaction) {
const satisfactionLabels: Record<string, string> = {
'very-bad': 'Very Dissatisfied',
'bad': 'Dissatisfied',
'neutral': 'Neutral',
'good': 'Satisfied',
'excellent': 'Very Satisfied'
};
summary += `Satisfaction: ${satisfactionLabels[satisfaction] || satisfaction}\n`;
}
if (agentRating) {
summary += `Agent Rating: ${'*'.repeat(agentRating)}${'*'.repeat(5 - agentRating)} (${agentRating}/5)\n`;
}
return summary;
},
customStyles: () => {
const effortScore = cesSection.ratingScale('effortScore')?.value();
const baseStyles = {
padding: '16px',
borderRadius: '8px',
whiteSpace: 'pre-wrap',
fontFamily: 'monospace',
fontSize: '14px'
};
if (effortScore === null || effortScore === undefined) return baseStyles;
if (effortScore >= 5) {
return { ...baseStyles, backgroundColor: '#d1fae5', borderLeft: '4px solid #10b981' };
} else if (effortScore >= 3) {
return { ...baseStyles, backgroundColor: '#fef3c7', borderLeft: '4px solid #f59e0b' };
}
return { ...baseStyles, backgroundColor: '#fee2e2', borderLeft: '4px solid #ef4444' };
}
});
});
// ============================================
// FORM CONFIGURATION
// ============================================
form.configureSubmitButton({
label: 'Submit Feedback',
isVisible: () => cesSection.ratingScale('effortScore')?.value() !== null
});
form.configureCompletionScreen({
type: 'text',
title: 'Thank You!',
message: 'Your feedback helps us make every interaction easier. We appreciate you taking the time to share your experience with us.'
});
}