Skip to main content
Arcanflows

Logic & Control

Control workflow execution with conditions, loops, and branching

Logic nodes control the flow of your workflow - branching, looping, and data transformation.

Condition Node

Branch your workflow based on conditions.

Basic Condition

        ┌─────────────┐
        │  Condition  │
        │  amount>100 │
        └──────┬──────┘
               │
       ┌───────┴───────┐
       ▼               ▼
   [Yes/True]     [No/False]
       │               │
       ▼               ▼
  [Premium]      [Standard]

Configuration

json
{
  "type": "condition",
  "conditions": [
    {
      "field": "{{ input.amount }}",
      "operator": "greater_than",
      "value": 100
    }
  ],
  "logic": "and"
}

Operators

OperatorDescriptionExample
equalsExact matchstatus equals "active"
not_equalsNot equaltype not_equals "test"
greater_thanGreater thanamount > 100
less_thanLess thancount < 10
containsString containsemail contains "@gmail"
starts_withString starts withname starts_with "Dr."
is_emptyNull or emptynotes is_empty
is_not_emptyHas valuephone is_not_empty
inIn arraystatus in ["active", "pending"]
matchesRegex matchemail matches ".*@company.com"

Multiple Conditions

json
{
  "conditions": [
    {
      "field": "{{ input.amount }}",
      "operator": "greater_than",
      "value": 1000
    },
    {
      "field": "{{ input.customer.tier }}",
      "operator": "equals",
      "value": "enterprise"
    }
  ],
  "logic": "or"
}

Switch Node

Multi-way branching based on a value.

Configuration

json
{
  "type": "switch",
  "value": "{{ input.status }}",
  "cases": [
    { "value": "pending", "output": "pending_branch" },
    { "value": "approved", "output": "approved_branch" },
    { "value": "rejected", "output": "rejected_branch" }
  ],
  "default": "unknown_branch"
}

Visual Flow

                ┌──────────────┐
                │    Switch    │
                │   (status)   │
                └──────┬───────┘
                       │
        ┌──────────────┼──────────────┐
        │              │              │
        ▼              ▼              ▼
   [pending]     [approved]    [rejected]
        │              │              │
        ▼              ▼              ▼
   [Process]     [Fulfill]      [Notify]

Loop Node

Iterate over arrays of data.

For Each Loop

Process each item in an array:

json
{
  "type": "loop",
  "mode": "for_each",
  "array": "{{ input.orders }}",
  "item_variable": "order",
  "max_iterations": 100
}

Access Loop Variables

Inside the loop:

javascript
{{ loop.item }}        // Current item
{{ loop.index }}       // Current index (0-based)
{{ loop.is_first }}    // True if first iteration
{{ loop.is_last }}     // True if last iteration
{{ loop.length }}      // Total items

Loop with Condition

json
{
  "type": "loop",
  "mode": "while",
  "condition": "{{ variables.retry_count < 3 }}",
  "max_iterations": 10
}

Parallel Processing

Process items in parallel:

json
{
  "type": "loop",
  "mode": "for_each",
  "array": "{{ input.orders }}",
  "parallel": true,
  "max_concurrency": 5
}

Delay Node

Pause workflow execution.

Fixed Delay

json
{
  "type": "delay",
  "duration": 5000,
  "unit": "milliseconds"
}

Units

UnitExample
milliseconds5000 = 5 seconds
seconds60 = 1 minute
minutes30 = 30 minutes
hours24 = 1 day

Dynamic Delay

json
{
  "type": "delay",
  "duration": "{{ input.wait_time }}",
  "unit": "seconds"
}

Wait Until

Wait until a specific time:

json
{
  "type": "delay",
  "mode": "until",
  "datetime": "{{ input.scheduled_time }}"
}

Transform Node

Modify data structure and values.

Map Operation

Transform array items:

json
{
  "type": "transform",
  "operation": "map",
  "source": "{{ input.users }}",
  "transform": {
    "id": "{{ item.id }}",
    "full_name": "{{ item.first_name }} {{ item.last_name }}",
    "email_domain": "{{ item.email.split('@')[1] }}"
  }
}

Filter Operation

Keep matching items:

json
{
  "type": "transform",
  "operation": "filter",
  "source": "{{ input.orders }}",
  "condition": "{{ item.total > 100 }}"
}

Reduce Operation

Aggregate values:

json
{
  "type": "transform",
  "operation": "reduce",
  "source": "{{ input.items }}",
  "initial": 0,
  "expression": "{{ accumulator + item.price }}"
}

Multiple Operations

Chain transformations:

json
{
  "type": "transform",
  "operations": [
    {
      "operation": "filter",
      "condition": "{{ item.status == 'active' }}"
    },
    {
      "operation": "map",
      "transform": {
        "name": "{{ item.name }}",
        "value": "{{ item.amount * 1.1 }}"
      }
    },
    {
      "operation": "sort",
      "field": "value",
      "order": "desc"
    }
  ]
}

Merge Node

Combine data from multiple branches.

Configuration

json
{
  "type": "merge",
  "mode": "combine",
  "inputs": ["branch_1", "branch_2", "branch_3"]
}

Merge Modes

ModeDescription
combineCombine all outputs into array
firstUse first completed branch
allWait for all branches

Parallel Node

Execute branches simultaneously.

Configuration

json
{
  "type": "parallel",
  "branches": [
    { "name": "get_user", "nodes": [...] },
    { "name": "get_orders", "nodes": [...] },
    { "name": "get_preferences", "nodes": [...] }
  ],
  "wait_for": "all"
}

Visual Flow

              ┌──────────┐
              │ Parallel │
              └────┬─────┘
                   │
     ┌─────────────┼─────────────┐
     │             │             │
     ▼             ▼             ▼
[Get User]   [Get Orders]  [Get Prefs]
     │             │             │
     └─────────────┼─────────────┘
                   │
                   ▼
              ┌──────────┐
              │  Merge   │
              └──────────┘

Approval Node

Human-in-the-loop approval.

Configuration

json
{
  "type": "approval",
  "title": "Approve Refund Request",
  "description": "Customer {{ input.customer_name }} requests refund of ${{ input.amount }}",
  "approvers": ["[email protected]"],
  "timeout_hours": 24,
  "actions": ["approve", "reject", "escalate"]
}

Approval Flow

[Request] → [Approval Node] → [Wait for Response]
                                      │
                    ┌─────────────────┼─────────────────┐
                    ▼                 ▼                 ▼
               [Approved]        [Rejected]       [Timeout]

Best Practices

Conditions

  • Keep conditions simple and readable
  • Use descriptive branch names
  • Always handle the "else" case

Loops

  • Set max iterations to prevent infinite loops
  • Use parallel processing for independent items
  • Break early when possible

Performance

  • Minimize nested loops
  • Use parallel execution for I/O-bound tasks
  • Cache repeated calculations

Next Steps