Skip to main content
The If-Else command (Command Type: 1100) executes different sets of commands depending on whether a logical condition evaluates to true or false.

Command Type

Command Type ID: 1100

Parameters

ParameterTypeDescriptionRequired
conditionSimpleCondition or ComplexConditionThe logical condition to evaluateYes
trueCommandsArray of CommandCommands to execute if the condition evaluates to trueYes
timeoutnumberTimeout for the command in millisecondsYes
contextstringExecution context for evaluating the condition. Defaults to "CommandResult"No
falseCommandsArray of CommandCommands to execute if the condition evaluates to falseNo

SimpleCondition

FieldTypeDescriptionRequired
leftOperandLeft-side operandYes
operationOperationComparison operationYes
rightOperandRight-side operandYes

Operand Types

PropertyOperand — references a named property:
FieldTypeDescription
type"property"Fixed literal
valuestringProperty name
ValueOperand — a literal value:
FieldTypeDescription
type"value"Fixed literal
valuestring / number / boolean / arrayThe literal value

Operation Values

CategoryPossible Values
String"includes", "startsWith", "endsWith", "==", "!=", "===", "!=="
Number">", ">=", "<", "<=", "==", "!=", "===", "!=="
Array"includes", "==", "!=", "===", "!=="

ComplexCondition

Combines multiple simple or complex conditions:
FieldTypeDescriptionRequired
conditionsArray of SimpleCondition or ComplexConditionNested conditionsYes
operatorstring"AND" or "OR"Yes

Usage Examples

Simple String Check

{
  "command": "if-else",
  "params": {
    "condition": {
      "left": { "type": "property", "value": "status" },
      "operation": "==",
      "right": { "type": "value", "value": "active" }
    },
    "trueCommands": [
      { "id": 1, "type": "PARSE", "params": { ... } }
    ],
    "falseCommands": [],
    "timeout": 5000
  }
}

Complex AND Condition

{
  "command": "if-else",
  "params": {
    "condition": {
      "operator": "AND",
      "conditions": [
        {
          "left": { "type": "property", "value": "count" },
          "operation": ">",
          "right": { "type": "value", "value": 0 }
        },
        {
          "left": { "type": "property", "value": "status" },
          "operation": "==",
          "right": { "type": "value", "value": "live" }
        }
      ]
    },
    "trueCommands": [],
    "timeout": 5000
  }
}

Common Use Cases

  • Guard Clauses: Skip processing if data is empty or invalid
  • Branching Logic: Take different parse paths based on a field value
  • Conditional Sinking: Only publish to a sink when data meets a criteria