Skip to main content

Cases

Every branching node routes through an ordered list of cases. Each case pairs a condition (when) with a destination and optional effects (then):
Cases are evaluated in order and the first match wins. When nothing matches, the execution moves to the node’s on_no_match, or the definition-wide on_no_match if the node doesn’t declare one — so an execution always has somewhere to go. Point the definition-wide fallback at a dedicated end node (an unhandled ending) and it doubles as your safety net.

Operands

Conditions compare operands, each one of three forms: Arithmetic supports +, -, *, /. Addition and multiplication take any number of args; subtraction and division take exactly two:

Comparisons


Combinators

Combine conditions with all (AND), any (OR) and not, nested up to 32 levels:
Two more forms round out the language: {"exists": {"var": "..."}} is true when the variable is present, and {"always": true} matches unconditionally — the standard last case or single-exit route.

Effects

A matching case can write values into state.* before the execution moves on. state.* is the execution’s own memory: it survives every later node, call, retry and wait, and is never reset. Use it for counters, flags, and a value that can come from different nodes depending on the path the contact took, such as the last disposition when several agent nodes can produce it. A single earlier node’s outputs don’t need it: they stay readable at node.<id>.* for the whole execution.
The workflow editor has no field for effects. Write them through the API (Save a workflow draft) or the Bolna MCP save_workflow_draft tool.

Writing a value

set_value maps each target to the value it receives. One effect can write several targets:
  • Target — always state.<name>, a single segment with no further dots. Any other target fails publish.
  • Value — either an operand (var, const or op), written as it resolves, or {"value": <operand>, "type": "<type>"}, which first coerces the value to one of the nine variable types (string, number, boolean, timestamp, phone, email, url, json, timezone). Declare number on anything you will count or compare, so a numeric string such as "3" is stored as 3. timestamp stores an ISO-8601 string and also converts an epoch number in seconds or milliseconds, which makes the result usable as a time node’s at.

How effects run

  • Only the matched case’s effects run. A node’s on_no_match fallback carries no effects.
  • Effects run in list order, before the execution moves to to. A case holds up to 10 effects.
  • The assignments inside one set_value run in no guaranteed order, so don’t read a target in the same set_value that writes it. When one write depends on another, put them in two effects.
  • When a value can’t resolve, for example because it reads a variable that doesn’t exist yet, that assignment is skipped, the target keeps its previous value, and the execution’s timeline records a warning. The case’s other assignments still run.
  • When a typed value can’t be coerced, the uncoerced value is written and a warning is recorded.
  • An effect never stops the execution.

Reading state

Read a value with {"var": "state.<name>"} anywhere a variable is accepted: case conditions, the agent and api nodes’ config.variables, a recipient, and a time or retry node’s at. A state.* variable doesn’t exist until a case writes it. Until then every comparison on it is false, even under not, and arithmetic over it doesn’t resolve, so an increment on a counter that was never set is skipped. Set starting values on a start node case, which runs exactly once, or test for the variable with exists. Each node’s outputs in the execution detail include the state.* writes its case made, and the execution’s final state is returned once it finishes.

Patterns

Count attempts. Start the counter on the start node and increment it after every call:
Carry the previous call into the next one. When the previous call always comes from the same agent node, read its summary directly from node.<extraction_node_id>.extraction.call_summary. When it can come from different agent nodes depending on the path, no single node.<id> names it, so copy it into state.* on each of those extraction nodes’ cases, then pass that as a prompt variable:
Branch on the last outcome later. A case anywhere downstream, including after a time wait, can route on the last outcome, whichever agent node produced it:

Variable namespaces

call.*, response.* and callback.* hold the latest node’s values of that kind. When a workflow has two agent nodes and you need the first call’s status after the second call ran, read it from node.<first_node_id>.* instead.
aisensy_whatsapp is fire-and-forget for now — it doesn’t wait on or surface AiSensy’s delivery status, so whatsapp.* isn’t actually populated. Don’t branch on it; see Workflow Nodes.

Time

system.* gives a workflow the same time variables an agent prompt gets (see System variables), read when each node is evaluated, plus two numbers for arithmetic: A node that waits, such as an agent node waiting for its call or a time node, reads the time it resumed, not the time it started.

Setting the timezone

Local time is read in each contact’s own timezone, like timezone in an agent call’s user_data. Declare one start field with the timezone type, under any name, and set a fallback on the definition for contacts that leave it blank:
The field takes an exact IANA name such as Asia/Kolkata or America/New_York; names are case-sensitive. Like any declared field, it arrives as a CSV column, or a top-level key in a JSON upload or single run, under the field’s name. A value that isn’t an IANA name, such as IST, fails that upload row with invalid_field_type, and a single run returns 422. A workflow can declare only one timezone-typed field, and a field merely named timezone with another type is ordinary data. A workflow that reads any local-time variable fails publish unless it sets defaults.timezone or makes its timezone-typed field required, so every contact has a zone. system.current_timestamp needs no timezone.
The workflow editor doesn’t offer the timezone type yet. Declare the field through the API (Save a workflow draft) or the Bolna MCP save_workflow_draft tool; the editor keeps it when you save.

Examples

With one hour as 3,600 seconds and one day as 86,400: Stop calling after 7 PM. The same check a graph agent’s expression edge makes:
Wait until 10 AM tomorrow. Add 1 day and 10 hours to midnight, write it as a timestamp into state.*, then use it as a time node’s at:
Keep "type": "timestamp": without it state.resume_at stays a number, which at can’t wait on, so the node moves on at once. Publish warns about this as numeric_at. Count days since the journey started. Save system.current_day_start on the start node as state.day0, then this is 0 on the first day, 1 on the next, and so on:
Offsets from system.current_day_start count elapsed seconds, not clock time. On a day the timezone changes for daylight saving, an offset that passes the change lands an hour off. Timezones without daylight saving, such as Asia/Kolkata, are unaffected.

Variables in node configs

Node configs (agent prompt variables, API URLs/bodies, WhatsApp templates) don’t embed expressions directly. They use {placeholder} references resolved by the node’s config.variables map:
Each variable spec takes a value operand, an optional type (one of string, number, boolean, timestamp, phone, email, url, json, timezone — the value is coerced, and the execution treats a failed coercion as a missing value), and required. A missing required variable stops the execution with termination_reason required_variable_missing; a missing optional one resolves empty and the execution continues with a warning event on its timeline.

Next steps

Nodes

What each node writes and branches on

Quickstart

See conditions in a complete working definition