Decision graph
A decision graph is a visual canvas where you connect nodes to model decision logic. Data flows from an input node, through processing nodes, to an output node. Every decision graph has:- Input node — Receives the data you want to evaluate
- Processing nodes — Transform and evaluate the data (decision tables, expressions, functions, switches)
- Output node — Returns the final result (optional unless you need output validation)
Decision table
A decision table is a spreadsheet-like component for conditional logic. Rows define rules: conditions on the left, outcomes on the right.Inputs
Outputs
Unary tests vs standard expressions
When an input column has a field name defined, cells use unary test syntax — shorthand expressions evaluated against that field:| Operator | Example | Matches |
|---|---|---|
| Comparison | > 100, <= 50, != 0 | Values matching the comparison |
| Range (inclusive) | [1..10] | Values from 1 to 10 |
| Range (exclusive) | (0..100) | Values between 0 and 100 |
| List | 'US', 'GB', 'CA' | Any value in the list |
| Combined | > 5 and < 10 | Values matching both conditions |
| Any | (empty) | Matches any value |
customer.age > 18 and customer.country == 'US'.
Hit policies
Hit policies control how the engine handles multiple matching rows:| Policy | Behavior |
|---|---|
| First | Returns the first matching row (default) |
| Collect | Returns all matching rows as an array |
Expression node
An expression node transforms data using the ZEN expression language. Use it for calculations, mappings, and data manipulation.
Use
$ to reference the current expression node’s output. In the example above, $.subtotal refers to the subtotal field calculated earlier in the same node.
The operators and functions below work throughout GoRules — in expression nodes, decision table cells, and switch
conditions.
Operators
| Type | Operators |
|---|---|
| Arithmetic | +, -, *, /, %, ^ (power) |
| Comparison | ==, !=, >, <, >=, <= |
| Logical | and, or, not |
| Ternary | condition ? then : else |
| Null coalescing | value ?? fallback |
| Range check | x in [1..10], x not in (0..100) |
Built-in functions
| Category | Functions |
|---|---|
| Math | abs, floor, ceil, round, min, max, sum, avg, median |
| String | len, upper, lower, trim, contains, startsWith, endsWith, matches, split |
| Array | map, filter, some, all, one, none, count, flatMap, keys, values |
| Date | d(), duration |
| Type | string, number, bool, type, isNumeric |
Function node
A function node runs custom JavaScript for complex logic that expressions can’t handle. Use it when you need external API calls, complex algorithms, or operations that require full programming language capabilities.- ES6+ JavaScript — Modern syntax including async/await
- Built-in libraries —
dayjsfor dates,big.jsfor precision math,zodfor validation - Async operations — Await promises for API calls or async logic
Switch node
A switch node routes data through different paths based on conditions. It evaluates conditions in order and sends data down the first matching branch.
How data flows
When you evaluate a decision, data flows through the graph:- Input — You provide a JSON object with your data
- Processing — Each node receives data, processes it, and passes results forward
- Output — The final node returns the decision result
Output node is optional and most often it’s not used. Without one, the engine returns the results from all endpoint
nodes combined.
Pass-through behavior
By default, nodes use pass-through mode — they carry forward all incoming data plus their own outputs. This means downstream nodes can access both the original input and any values added by previous nodes.- Direct input — Data passed directly into the node
- Previous nodes — Output from upstream nodes in the graph
Referencing previous nodes
Use$nodes to access the output of any upstream node by its name:
{ rating: "good", score: 720 }. The Income Check node outputs { sufficient: true }. In the Final Decision expression node, you can combine both:
$nodes through the input parameter:
Special symbols
The$ symbol has different meanings depending on context:
| Symbol | Context | Meaning |
|---|---|---|
$ | Expression node | Reference to current node’s output (e.g., $.subtotal) |
$ | Unary test (decision table) | The field value being tested (e.g., len($) > 5) |
$nodes | Any node | Access output from previous nodes |
$root | Expression node | The entire context object |
# | Array iteration | Current element in map, filter, etc. |
JDM file format
Decision graphs are stored as JSON Decision Model (JDM) files. This portable format lets you:- Version control rules in Git
- Move rules between environments
- Share rules across applications
- Edit rules programmatically