Skip to content
awesome-tour

Type to search every page.

    BSurveysContents

    Surveys

    NPS, CSAT and CES surveys with conditional follow-ups — accessible rating scales, display rules and your own backend.

    A survey is a tour with one step per question. So it inherits progress, Back/Next, display rules (ask once, after a cooldown, only on the pro plan…), triggers and analytics.

    Surveys
    Loopworknight-drive.lwp
    001.1.1

    Mixer

    4 channels
    Drums
    80%
    Bass
    35%
    Keys
    60%
    Vox
    50%

    Bounce

    8 bars · 0:21
    Renders the loop to one file.
    Hit Bounce. Rate it 3 or lower to get the follow-up question.
    SurveyDemo.tsx
    import { TourProvider, useTourManager } from '@awesome-tour/react';
    import { createSurvey, type SurveyAnswers } from '@awesome-tour/react/surfaces';
    import { LoopworkApp, useCreateLoopwork, useLoopwork } from '@loopwork';
    import { useEffect, useState } from 'react';
    import { SurveyCard } from '@/components/awesome-tour/survey';
    import { DemoFrame } from './ui';
    let report: (answers: SurveyAnswers) => void = () => {};
    const survey = createSurvey({
    id: 'docs-csat',
    questions: [
    { id: 'sound', type: 'csat', prompt: 'How did the bounce sound?' },
    {
    id: 'off',
    type: 'text',
    prompt: 'What sounded off?',
    placeholder: 'Too quiet, clipping, muddy low end…',
    optional: true,
    when: (answers) => Number(answers.sound) <= 3,
    },
    ],
    onSubmit: (answers) => report(answers),
    });
    /** Asks right after the moment it's about: the first finished bounce. */
    function AskAfterBounce() {
    const manager = useTourManager();
    const status = useLoopwork((s) => s.export.status);
    useEffect(() => {
    if (status === 'done') void manager.start(survey.id, { force: true });
    }, [status, manager]);
    return null;
    }
    export function SurveyDemo() {
    const [answers, setAnswers] = useState<SurveyAnswers | null>(null);
    report = setAnswers;
    const app = useCreateLoopwork({ route: 'mix' });
    return (
    <TourProvider tours={[survey]}>
    <DemoFrame
    title="Surveys"
    footer={
    <span aria-live="polite">
    {answers
    ? `onSubmit(${JSON.stringify(answers)})`
    : 'Hit Bounce. Rate it 3 or lower to get the follow-up question.'}
    </span>
    }
    >
    <LoopworkApp scope="feedback" app={app} layout="routed">
    <AskAfterBounce />
    </LoopworkApp>
    </DemoFrame>
    <SurveyCard survey={survey} lowLabel="Rough" highLabel="Release-ready" />
    </TourProvider>
    );
    }

    Create

    import { createSurvey } from '@awesome-tour/react/surfaces';
    export const nps = createSurvey({
    id: 'nps-q4',
    questions: [
    { id: 'score', type: 'nps', prompt: 'How likely are you to recommend us?' },
    {
    id: 'reason',
    type: 'text',
    prompt: 'What would make it a 10?',
    optional: true,
    when: (answers) => Number(answers.score) < 9, // follow-up for passives and detractors
    },
    ],
    rules: { trigger: { signal: 'onboarding-complete' }, frequency: { cooldownMs: 90 * 86_400_000 } },
    onSubmit: (answers) => fetch('/api/nps', { method: 'POST', body: JSON.stringify(answers) }),
    });
    Type Scale Ends labelled by default
    nps 0–10 “Not at all likely” / “Extremely likely”
    csat 1–5 (max to change) lowLabel / highLabel
    ces 1–7 lowLabel / highLabel
    text free text (placeholder) —

    Next stays disabled until the question is answered (unless it’s optional); on the last question it submits: the survey completes and onSubmit(answers) runs. Answers also live in survey.getState().data.answers, so the analytics plugin with includeData sends them along. npsCategory(score) returns promoter, passive or detractor.

    Render

    import { Survey } from '@awesome-tour/react/surfaces';
    <Survey.Root survey={nps}>
    <Survey.Portal>
    <Survey.Content className="survey">
    <Survey.Prompt />
    <Survey.When type={['nps', 'csat', 'ces']}>
    <Survey.Scale />
    </Survey.When>
    <Survey.When type="text">
    <Survey.Comment />
    </Survey.When>
    <Survey.Back>Back</Survey.Back>
    <Survey.Next>Next</Survey.Next>
    <Survey.Dismiss />
    </Survey.Content>
    </Survey.Portal>
    </Survey.Root>

    Survey.Scale is a radiogroup: every option is a role="radio" button with data-state and data-value; arrow keys move and pick, and the ends are labelled for screen readers. autoAdvance moves on as soon as a value is picked.