Skip to main content
Scripts are how you compute something the interview can’t express with conditions alone: set a variable from a combination of earlier answers, flag a respondent who matches a profile you care about, prepare a value that a later question or a webhook will use. You write a few lines of JavaScript on a single block, and they run for every respondent who passes through it. The Script button sits in the question panel of the block. The modal that opens says what it does: “Run JavaScript when a node opens or after a respondent submits an answer”.

The two tabs

Runs before the node is shown. Use it to prepare something the respondent is about to see or to set a value that depends on where they’ve been so far.
Each tab has its own code editor and its own script. A block can have both, one, or neither.

What a script can read and write

Two objects are available inside a script.
read
The answer given to a question, addressed by its question code. This is why the question code is worth setting deliberately: it’s the handle your scripts use.
write
A variable of the campaign. Assign to it and the value stays with the respondent for the rest of the interview.
The example loaded in the product shows both in two lines: read two answers, and write one variable when either matches.
The full API reference isn’t published yet. Stick to questions.<CODE>.responseValue for reading and vars.<name> for writing — those are the two documented entry points.

Quick run

Quick run executes the script in an isolated state, without saving anything. It’s the way to check that your code does what you think before any respondent goes through the block. Nothing you run this way touches the collected data or the variables of a real session.
Set the question codes before you write the script. Renaming a code later breaks every script that referred to the old one, silently.

Next steps

Context variables

Create the variables your scripts write to, and reuse them in question copy.

Logic and conditions

Show or skip a question, and branch the flow with navigation rules.

Webhooks

Send each response, variables included, to your own endpoint as it comes in.