Logical Gates in Workflows
Author:
Fluent Commerce
Changed on:
16 Jan 2025
Overview
An introduction to the concept of Logical Gates and examples of how to use these in a workflow.
Key points
- Logical Gates are a common workflow design pattern, and are used to control workflow execution flow.
- A logical gate can evaluate a simple condition that resolves to either TRUE or FALSE, or a condition with multiple possible paths such as evaluating an ENUM value.
- A Logical Gate ruleset should only ever produce a single outcome, typically an inline event to process the following ruleset.
Logical Gates
A Logical Gate is where the direction of the workflow execution depends on specific conditions being met, i.e., some logical condition that needs to be satisfied so that the workflow knows which branch to execute next.
Each Logical Gate involves a simple condition that evaluates to TRUE or FALSE. The diagram below represents this.
As seen in the diagram here:
- X is evaluated here, where X could be an Event Attribute, an Entity Field, etc.
- If X is found to be TRUE, then then X is sent to Branch A for further processing.
- Otherwise, it will be sent to Branch B for further processing.
A Logical Gate may also have multiple possible paths, such as evaluating an ENUM. Still, a Logical Gate's Ruleset only produces a single outcome, typically an inline event to process the next Ruleset. For example, evaluating X will help select one of the three branches (A, B, or C) to continue processing.
Example: The evaluation of the shipping method that was selected during the order process.
- Depending on what was selected, X will be sent to either branches A, B, or C for further processing.
Logical Gate Scenario
For this scenario, let's assume that the client has a simple requirement:
If the order is above $500, annotate it as High Value, check for Fraud, or book the order.
As you can see here, only one of those conditions can ever resolve to TRUE at any given time, thereby providing only a single output path from this Ruleset at any time.
Recommended Practices
- Logical Gates evaluate a simple condition by the composition of rules
- Only one event (ever) output from the Ruleset
- Used for flow control, no other actions or outcomes should be present