diff --git a/packages/server/src/threads/automation.ts b/packages/server/src/threads/automation.ts index fbb905307e..64ff392a8f 100644 --- a/packages/server/src/threads/automation.ts +++ b/packages/server/src/threads/automation.ts @@ -463,11 +463,11 @@ class Orchestrator { } private async executeBranchStep(branchStep: BranchStep): Promise { const { branches, children } = branchStep.inputs - const conditionMet = false + for (const branch of branches) { const condition = await this.evaluateBranchCondition(branch.condition) if (condition) { - let branchStatus = { + const branchStatus = { status: `${branch.name} branch taken`, success: true, } @@ -482,22 +482,20 @@ class Orchestrator { const branchSteps = children?.[branch.name] || [] await this.executeSteps(branchSteps) - break + return } } - if (!conditionMet) { - this.stopped = true - this.updateExecutionOutput( - branchStep.id, - branchStep.stepId, - branchStep.inputs, - { - success: false, - status: AutomationStatus.NO_CONDITION_MET, - } - ) - return - } + + this.stopped = true + this.updateExecutionOutput( + branchStep.id, + branchStep.stepId, + branchStep.inputs, + { + success: false, + status: AutomationStatus.NO_CONDITION_MET, + } + ) } private async evaluateBranchCondition(