Command Palette

Search for a command to run...

Conditional Logic

Edges in Treege support conditional logic based on field values. You can combine multiple conditions to create complex branching flow.

Basic Structure

A conditional edge uses type: "conditional" and carries its conditions inside data:

{
  id: "e1",
  type: "conditional",
  source: "source-node-id",
  target: "target-node-id",
  data: {
    conditions: [
      {
        field: "field-id",
        operator: "===", // "===" | "!==" | ">" | "<" | ">=" | "<="
        value: "expected-value",
        logicalOperator: "AND" // "AND" | "OR" — combines with the next condition
      }
    ]
  }
}

Each condition's logicalOperator defines how it combines with the next condition in the array. The last condition's logicalOperator is ignored.

You can also mark an edge as a fallback with data.isFallback: true — it is followed when no other conditional edge from the same source matches.

Supported Operators

OperatorDescriptionExample
===Equalsage === 18
!==Not equalsstatus !== "inactive"
>Greater thanscore > 80
<Less thanprice < 100
>=Greater or equalage >= 21
<=Less or equalitems <= 5

Examples

Simple Condition

{
  id: "e1",
  type: "conditional",
  source: "ticket-type",
  target: "meal-preference",
  data: {
    conditions: [
      { field: "ticket-type", operator: "===", value: "vip" }
    ]
  }
}

OR Conditions

{
  id: "e2",
  type: "conditional",
  source: "ticket-type",
  target: "meal-preference",
  data: {
    conditions: [
      { field: "ticket-type", operator: "===", value: "vip", logicalOperator: "OR" },
      { field: "ticket-type", operator: "===", value: "regular" }
    ]
  }
}

AND Conditions

{
  id: "e3",
  type: "conditional",
  source: "age",
  target: "alcohol-preference",
  data: {
    conditions: [
      { field: "age", operator: ">=", value: "21", logicalOperator: "AND" },
      { field: "country", operator: "===", value: "US" }
    ]
  }
}