The Branch state allows you to add conditions to the circuit's workflow and execute tasks based on those conditions. It decides the path of execution based on input to this Branch state. This is similar to having an 'If else' or 'switch' case.
A Branch state may have more than one 'Next' state, but only one of the branch states will be executed. A branch state cannot use 'End' state.
Use Case Example: In the case of employee onboarding, after the employee details are provided, the submitted documents undergo verification. To handle appropriate action after verification, the Branch state can be employed based on the input received. If the verification status is determined as 'success', the circuit will proceed to the next pre-configured state. On the other hand, if the verification status is identified as 'failure', the circuit will follow a different path to the configured state.
Let us see how to configure the Branch state in Builder View and Code View.
Builder view
To configure a Branch state to your circuit:
In Builder View, drag and drop the Branch state from the left pane into your circuit or click the required branch state of the circuit.
You can include branches within this state by selecting Add Condition. This feature allows you to incorporate a state and define conditions for its execution. Upon meeting the condition for each branch, the specified subsequent state will be executed.
In Condition add $.verification == 'success' field set the next Success state in Go To.
Similarly, you can add another condition as $.verification == 'failure' and set it to a Failure state in Go To.

Branch state has a default pathway that you can link with the next state of the circuit. If none of the conditions is followed, the state will be executed with the default branch.
The following 'Condition' operators are supported:
Operator | Description |
&& | And |
== | Boolean Equals |
!= | Not |
== | Numeric Equals |
> | Numeric Greater Than |
>= | Numeric Greater Than Or Equals |
< | Numeric Less Than |
<= | Numeric Less Than Or Equals |
|| | Or |
== | String Equals |
Code View
In Code View for Branch, each branch must have Condition and Next fields.
The JSON to configure the Branch state for the above example is:
"Action - Approve or Reject": {
"type": "branch",
"next": "Verified and Approved",
"branches": [
{
"condition": "$.verification == 'success'",
"next": "Verified and Approved"
},
{
"condition": "$.verification == 'failure'",
"next": "Verified and Rejected"
}
]
}
Related Articles
JSON Path
Path serves to locate specific parts or components within a JSON object. These paths start with the '$' symbol and follow JSONPath syntax. It is used to access particular elements or values within JSON objects passed in the Input Path, Output Path, ...
Error Selector and Error Path
Error Selector and Error Path are used to manage errors in a system. While Result Selector and Result Path control the output of a state upon successful execution, Error Selector and Error Path come into play when the are exceptional circumstances, ...
Sample Use Case - Configuring Input and Output Processing in Circuit console
Let's explore Input/Output Processing further by building a Circuit using the example of an Employee Onboarding Process. We initiate the process with the following state Input which contains information about the employee details for employee ...
Parallel
Parallel state allows you to process multiple states in parallel and perform simultaneous executions. The executions are initiated at the same time, and their input, output, and results are processed and generated concurrently. Additionally, the ...
Pass
The Pass state serves the purpose of forwarding data to the next specified state. It allows you to pass the input data as-is or include supplementary information if needed during the process. To put it differently, with this state, you can insert new ...