Understanding Facts
Facts are the input data for your rules - a flat key-value object where keys are unique identifiers and values are the data to evaluate.Fact Structure
Static Facts
Hard-coded values that don’t change
Dynamic Facts
Values pulled from previous steps using variable mapping
Static Facts
Static facts have hard-coded values:Dynamic Facts with Variable Mapping
Most facts in real flows pull data from previous steps using variable mapping:When the Rules step executes, all variable mapping expressions are resolved first, converting your facts into actual values before any rules are evaluated. Learn more about variable mapping
Fact Naming Conventions
Fact keys can be any valid JSON key, but we recommend using descriptive names with a property suffix:Referencing Facts in Rules
Reference facts in your rules using the@fact: prefix followed by the exact fact key:
Understanding Rules
Rules define the logic for calculating outcomes based on your facts. Rules are structured as key-value pairs where the key is the rule name and the value defines how to calculate it.Simple Rule Format
Use simple format for direct calculations without conditions:Conditional Rule Format
Use conditional format when the outcome depends on conditions - an array of condition/outcome pairs evaluated top to bottom:Nested Operations
You can nest operations within theinput array to create complex calculations:
orderTotal - (orderTotal * discountRate)
Rules Referencing Rules
Rules can reference the outcomes of other rules using@fact:ruleName:
Operators
Operators are the functions that manipulate your data. The Rules engine includes operators for math, comparisons, logic, strings, arrays, dates, and more.Operator Categories
Math Operations
Math Operations
Basic:
Rounding:
Advanced:
Big Numbers:
+, -, *, /, ^, %Rounding:
round, ceil, floor, trunc, toFixedAdvanced:
min, max, log, baseLog, numberFormatBig Numbers:
addBig, subtractBig, multiplyBig, divideBigComparison Operations
Comparison Operations
Equality:
Magnitude:
Range:
= (equal), != (notEqual)Magnitude:
>, >=, <, <=Range:
between, notBetweenLogic Operations
Logic Operations
Boolean:
Existence:
and, or, notExistence:
empty, notEmptyString Operations
String Operations
Manipulation:
Formatting:
Searching:
concat, join, substring, splitFormatting:
stringTemplate, numberFormatSearching:
startsWith, endsWith, stringContains, stringNotContainsArray Operations
Array Operations
Creation:
Searching:
Transformation:
Processing: Use wildcards like
generateArray, concatArraySearching:
arrayContains, arrayNotContains, inArray, notInArrayTransformation:
sort, sortString, arrayFilterProcessing: Use wildcards like
@fact:items.value/*/priceDate Operations
Date Operations
Current:
Calculation:
Formatting:
today, now, timeNowCalculation:
addDate, subtractDate, dateDiffFormatting:
dateFormat, toISOLookup & Mapping
Lookup & Mapping
Key-Value:
Membership:
Sets:
map / lookupMembership:
inOptions / options-in, in, notInSets:
isSubset, isNotSubset, setUnion, setIntersection, setDifferenceJSON Operations
JSON Operations
Parsing:
Querying:
jsonParse, jsonStringifyQuerying:
jPath for JSONPath queries like $.items[0].nameFull Operations Reference
See the complete operations reference with syntax, parameters, and examples for every operator
Array Processing with JSONPath
The Rules engine supports processing arrays using JSONPath queries via thejPath operator.
Learn more about JSONPath
Learn about variable mapping with JSONPath and other data transformations using jPath references and queries
JSONPath Syntax
UsejPath to extract values from literal array objects:
Example: Extract Array Values
Extract prices from a cart items array:Example: Element-by-Element Operations
Calculate line totals by multiplying price × quantity for each item:When both inputs to a math operator are arrays of the same length, they’re processed element-by-element:
prices[0] * quantities[0], prices[1] * quantities[1], etc.Common JSONPath Patterns
| Pattern | Description | Example |
|---|---|---|
$[*] | All array elements | Get entire array |
$[*].propertyName | Property from all elements | $[*].price |
$.0 or $[0] | First element | Get first item |
$[-1] | Last element | Get last item |
$[0:3] | Array slice | First 3 items |
Alternative: Wildcard Syntax
Wildcard Syntax for Flattened Data (Advanced)
Wildcard Syntax for Flattened Data (Advanced)
Rules also support a wildcard syntax (Using wildcard:Most users should use literal arrays with
@fact:items/*/property) for working with flattened key-value structures. This is an advanced feature most users won’t need.Flattened structure:jPath queries instead, as shown in the primary examples above.Data Flow & Evaluation
Understanding how the Rules engine processes your facts and rules:1
Variable Mapping Resolution
All facts with variable mapping expressions are resolved first, pulling data from previous steps in your flow
2
Dependency Analysis
The engine analyzes which rules depend on which facts and other rules
3
Evaluation Order
Rules are evaluated in dependency order - a rule that references another rule’s outcome waits for that rule to complete first
4
Condition Evaluation
For conditional rules, conditions are checked top to bottom, and the first matching condition’s outcome is returned
5
Output Generation
All rule outcomes are collected into a flat object matching your rule names
Example Flow
Best Practices
Use Descriptive Names
Name facts and rules clearly:
customerAge.value not caBe Consistent
Use the same property suffixes throughout: always
.value, not mixing .value and .valKeep Rules Simple
Break complex logic into multiple small rules rather than one giant rule
Add Comments
Use descriptive rule names as self-documentation:
qualifiesForPremiumDiscount explains itselfTest Incrementally
Add rules one at a time and test each in the Flow Debugger
Provide Defaults
Always include a default outcome in conditional rules to handle unexpected cases
What’s Next?
Operations Reference
Complete reference for all available operators with syntax and examples
Rule Patterns
Common patterns and best practices for real-world scenarios
Examples Library
Complete working examples for e-commerce, CRM, support, and more
Variable Mapping
Learn how to map data from previous steps into your facts
Need Help? Visit our Help Center or join the Community for support.