Skip to content

Flow rules and return values

Banh evaluates rules in order and returns the first matching rule’s value. An optional else must appear last. If no rule matches and there is no else, execution fails.

flow:
- when: urgent.probability >= 0.85
do: return
value:
route: escalation
- when: department.value == "billing"
do: return
value:
route: billing
- else:
do: return
value:
route: support

Each expression compares a single decision field against a JSON string, finite number, or boolean. Supported operators are ==, !=, >, >=, <, and <=. Ordered comparisons require numbers. String literals use double quotes.

Arbitrary code, compound boolean expressions, loops, and side-effect actions are not supported. Arrange multiple simple rules in priority order.

value can contain JSON-compatible objects, arrays, strings, numbers, booleans, or null. Your application receives the output and decides what action to take.

An entire string can reference a decision field:

value:
route: "{{ department.value }}"
accepted: "{{ department.accepted }}"

Interpolation works recursively in objects and arrays and preserves the field’s type. A boolean remains a boolean rather than becoming a string.

Partial strings such as "Route to {{ department.value }}" are rejected. Unknown references fail validation; unavailable metadata raises an error when the return executes.

See decisions and confidence for field availability and policy behavior.