Sub Flow
Allows the creation of subflows within a main flow, aiding in the development of more organized and streamlined flows.
Common Properties
- Name - The custom name of the node.
- Color - The custom color of the node.
- Delay Before (sec) - Waits in seconds before executing the node.
- Delay After (sec) - Waits in seconds after executing node.
- Continue On Error - Automation will continue regardless of any error. The default value is false.
info
if ContinueOnError property is true, no error is caught when the project is executed even if Catch node is used.
Options
- Outputs - The number of outputs for the subflow.
How It Works
The Sub Flow node encapsulates a reusable workflow section with its own Begin and End nodes:
-
Initialization (first message only):
- Reads the subflow definition file from disk (.generated/subflows/
{{nodeGuid}}.flow) - Tries Git-based storage path first, falls back to S3 path if not found
- Identifies all Begin nodes within the subflow as entry points
- Wires End nodes to the corresponding outputs of the Sub Flow node
- Subscribes to error events from nodes within the subflow
- Marks initialization complete
- Reads the subflow definition file from disk (.generated/subflows/
-
Message Routing (every message):
- Compresses the incoming message
- Routes the message to all Begin nodes within the subflow
- Each Begin node starts execution of its branch
-
Error Handling:
- Catches errors from child nodes within the subflow
- If Continue On Error is enabled: errors are swallowed and flow continues
- If a Catch node exists in parent scope: error is propagated to parent
- Otherwise: error is logged as unhandled
-
Cleanup:
- Unsubscribes from all error subscriptions when the flow closes
Requirements
- A subflow definition file must exist at the expected path
- The subflow should contain at least one Begin node (entry point)
- The subflow should contain End nodes corresponding to the number of outputs
- Adequate file system access to read subflow definitions
Error Handling
| Error Code | Description | Solution |
|---|---|---|
| Core.Flow.SubFlow.ErrOnCreate | Failed to parse node configuration | Verify node configuration is valid JSON |
| Core.Flow.Subflow.ErrSubscribe | Failed to subscribe to error messages | Check messaging system is functioning |
| Core.Flow.SubFlow.OnMessage | Message parsing failed | Check input message format is valid |
| Core.Flow.SubFlow.OnMessage | Step back in debug mode | This is expected during debugging with step back |
| Core.Flow.SubFlow.ErrOnReadFlow | Failed to read subflow definition file | Verify subflow file exists in .generated/subflows directory |
| Core.Flow.SubFlow.ErrOnCompress | Failed to compress payload | Check message data is valid and serializable |
Usage Examples
Example 1: Reusable Data Validation
Create a validation subflow used across multiple workflows:
[Main Flow: Receive Customer Data]
↓
[Sub Flow: "ValidateCustomer"]
Inside Sub Flow:
- [Begin] → [Check Required Fields]
- [Validate Email Format]
- [Validate Phone Format]
- [End: Success] or [End: Failed]
↓ (Success output)
[Continue Processing]
↓ (Failed output)
[Log Error and Stop]
Example 2: Multi-Step Business Process
Organize complex business logic:
[Start Order Processing]
↓
[Sub Flow: "CheckInventory"]
- Queries database
- Validates stock levels
- Reserves items
↓
[Sub Flow: "ProcessPayment"]
- Validates payment method
- Charges customer
- Records transaction
↓
[Sub Flow: "GenerateInvoice"]
- Creates invoice
- Sends email
- Updates records
Example 3: Parallel Sub Flow Execution
Use with Fork Branch for parallel processing:
[Fork Branch: 3 branches]
↓
Branch 1: [Sub Flow: "ProcessOrders"]
Branch 2: [Sub Flow: "ProcessReturns"]
Branch 3: [Sub Flow: "ProcessInquiries"]
↓ (all branches complete)
[Merge Results]
Usage Notes
- When
Continue On Erroris enabled, errors within the subflow are not caught even if a Catch node is present - The subflow file is loaded from
.generated/subflows/{nodeGuid}.flow - Two storage paths are tried: Git-based path first, then S3-based path
- Initialization happens only once on the first message for performance
- Multiple Begin nodes in a subflow create parallel entry points
- End nodes must have an
sfPortproperty to map to the correct output - Subflows can be nested (subflows within subflows)
- Each subflow execution is isolated with its own scope
- Subflows can be part of libraries or specific to a flow/version
Tips
- Use Sub Flows to break complex workflows into manageable, testable pieces
- Create reusable Sub Flows for common operations (validation, logging, notifications)
- Name Sub Flows clearly to indicate their purpose
- Document Sub Flow inputs and outputs with Comment nodes
- Keep Sub Flows focused on a single responsibility
- Test Sub Flows independently before integrating into main flows
- Use multiple outputs to handle different result conditions (success, failure, etc.)
- Consider creating a library of standard Sub Flows for your organization
- Sub Flows improve maintainability - update once, affects all usages
- Use Sub Flows instead of copy-pasting similar node sequences
- Be mindful of nesting depth - too many levels can be hard to debug
- Monitor file system paths when using versioned flows or libraries
Related Nodes
- Fork Branch - For parallel execution of Sub Flows
- Go To - For flow control within workflows
- Stop - For terminating from within a Sub Flow
- Catch - For handling Sub Flow errors in parent scope