Custom logic with Code (JS)
Run a snippet of JavaScript in a sandbox to compute, validate or branch.
When a flow needs logic that blocks can’t express, drop in a Code (JS) block. It runs a small JavaScript snippet in a sandbox and can read/write your variables.
What the snippet can access
vars— read and write your variables. Assigningvars.x = …saves it for later blocks/messages.user— read-only user fields (user.id,user.first_name, …).return true/return false— choose the outcome:true→ok,false/throw →error.
// Give a 10% discount to users with 100+ points
if (Number(vars.points) >= 100) {
vars.discount = "10";
return true; // → ok
}
vars.discount = "0";
return false; // → error
Outcomes
ok when the snippet returns truthy; error when it returns falsy or throws. Wire both to
keep the flow predictable.