Skip to main content

What the Rules step does

The Rules step derives new values from data your flow already has. You give it facts — a flat object of inputs — and rules — an object saying what to calculate from them. It works out the order to evaluate in and returns a flat object of results for the rest of the flow to use. It is closest in spirit to a set of spreadsheet formulas: each rule names the value it produces, and rules that depend on one another sort themselves out. Use it when the logic is a calculation or a decision made from values you already have — pricing and discount bands, eligibility checks, validating a submission, scoring, working out a due date, or picking a label. Reach for the Eval step instead when you need real code, and for the Condition step when the outcome is which branch of the flow runs next.

A first example

Facts
Rules
Output
Three things are worth noticing. Rules read facts by name with @fact:. Operators nest — the or takes two comparisons as its inputs. And the key on the left is just a name you chose; it becomes a fact that later rules can read.

A worked example

A discount band, the discount it implies, and the resulting price. Facts
Rules
Output
discountRate.value is an if/else ladder: cells are tried in order and the first matching condition wins, with the last cell as the default. The two rules below it reference it by name, and the engine works out that they must run after it.

What to know before you build one

Some failures are silent

A misspelled operator fails the step and names itself. A ladder that matches nothing, a calculation that produces NaN and an outcome of null do not — the fact is simply absent and the flow carries on.

Dots in rule names need brackets

A rule named finalPrice.value is read downstream as $.rules_1['finalPrice.value']. The dotted form resolves to nothing.

The operator list is fixed

The engine has 96 registered operator names — many of them aliases of each other — plus fact. Anything outside that list does not exist, however reasonable it sounds.

Publish before testing

Editing a flow changes its draft. A running flow keeps using the published version until you publish again.

Where to go next

Getting Started

Build and test a rule end to end.

Core Concepts

The rule shapes, evaluation order, defaults, wildcards and failure modes.

Operations Reference

Every operator, with an executed example.

Common Patterns

Worked solutions to the problems that come up repeatedly.

Variable Mapping

How $. expressions pull facts in from earlier steps.

Rules Step

Configuring the step in the flow editor.