Workflow
Execute other workflows as reusable components within your current workflow
The Workflow block allows you to execute other workflows as reusable components within your current workflow. This powerful feature enables modular design, code reuse, and the creation of complex nested workflows that can be composed from smaller, focused workflows.
Workflow blocks enable modular design by allowing you to compose complex workflows from smaller, reusable components.
Overview
The Workflow block serves as a bridge between workflows, enabling you to:
Reuse existing workflows: Execute previously created workflows as components within new workflows
Create modular designs: Break down complex processes into smaller, manageable workflows
Maintain separation of concerns: Keep different business logic isolated in separate workflows
Enable team collaboration: Share and reuse workflows across different projects and team members
How It Works
The Workflow block:
- Takes a reference to another workflow in your workspace
- Passes input data from the current workflow to the child workflow
- Executes the child workflow in an isolated context
- Returns the results back to the parent workflow for further processing
Configuration Options
Workflow Selection
Choose which workflow to execute from a dropdown list of available workflows in your workspace. The list includes:
- All workflows you have access to in the current workspace
- Workflows shared with you by other team members
- Both enabled and disabled workflows (though only enabled workflows can be executed)
Input Data
Define the data to pass to the child workflow:
- Single Variable Input: Select a variable or block output to pass to the child workflow
- Variable References: Use
<variable.name>
to reference workflow variables - Block References: Use
<blockName.field>
to reference outputs from previous blocks - Automatic Mapping: The selected data is automatically available as
start.input
in the child workflow - Optional: The input field is optional - child workflows can run without input data
- Type Preservation: Variable types (strings, numbers, objects, etc.) are preserved when passed to the child workflow
Accessing Results
After a workflow executes, you can access its outputs:
<workflow.response>
: The complete output from the child workflow<workflow.name>
: The name of the executed child workflow<workflow.success>
: Boolean indicating successful completion<workflow.error>
: Error details if the workflow failed<workflow.execution_time>
: Time taken to execute the workflow
Execution Context
The child workflow executes with:
- Its own isolated execution context
- Access to the same workspace resources (API keys, environment variables)
- Proper workspace membership and permission checks
- Independent logging and monitoring
Safety and Limitations
To prevent infinite recursion and ensure system stability, the Workflow block includes several safety mechanisms:
Cycle Detection: The system automatically detects and prevents circular dependencies between workflows to avoid infinite loops.
- Maximum Depth Limit: Nested workflows are limited to a maximum depth of 10 levels
- Cycle Detection: Automatic detection and prevention of circular workflow dependencies
- Timeout Protection: Child workflows inherit timeout settings to prevent indefinite execution
- Resource Limits: Memory and execution time limits apply to prevent resource exhaustion
Advanced Features
Dynamic Workflow Selection
Select workflows dynamically based on runtime conditions:
// In a Function block before the Workflow block
const workflowId = <condition.result> ? 'premium-workflow' : 'standard-workflow';
return { selectedWorkflow: workflowId };
Error Handling and Fallbacks
Implement robust error handling for child workflows:
// In a Function block after the Workflow block
if (!<workflow.success>) {
console.error('Child workflow failed:', <workflow.error>);
// Implement fallback logic
return { fallback: true, error: <workflow.error> };
}
return <workflow.response>;
Workflow Chaining
Chain multiple workflows together:
// Pass output from one workflow to another
Workflow 1 Input: <start.input>
Workflow 2 Input: <workflow1.response>
Workflow 3 Input: <workflow2.response>
Inputs and Outputs
Workflow Selection: Choose which workflow to execute
Input Data: Variable or block reference to pass to child workflow
Execution Context: Isolated environment with workspace resources
workflow.response: Complete output from child workflow
workflow.name: Name of executed child workflow
workflow.success: Boolean indicating completion status
workflow.error: Error details if workflow failed
workflow.execution_time: Time taken to execute
Workflow Response: Primary output from child workflow
Execution Status: Success status and error information
Access: Available in blocks after the workflow
Example Use Cases
Modular Customer Onboarding
Scenario: Break down complex onboarding into reusable components
- Main workflow receives customer data
- Workflow block executes validation workflow
- Workflow block executes account setup workflow
- Workflow block executes welcome email workflow
Microservice Architecture
Scenario: Create independent service workflows
- Payment processing workflow handles transactions
- Inventory management workflow updates stock
- Notification workflow sends confirmations
- Main workflow orchestrates all services
Conditional Processing
Scenario: Execute different workflows based on conditions
- Condition block evaluates user type
- Enterprise users → Complex approval workflow
- Standard users → Simple approval workflow
- Free users → Basic processing workflow
Example: Customer Validation Workflow
// Main workflow passes customer data to validation workflow
const customerData = <start.input>;
// Validation workflow processes the data
const emailValid = /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(customerData.email);
const phoneValid = /^\+?[1-9]\d{1,14}$/.test(customerData.phone);
return {
customer: customerData,
validation: {
email: emailValid,
phone: phoneValid,
overall: emailValid && phoneValid
}
};
Best Practices
- Keep workflows focused: Design child workflows to handle specific, well-defined tasks with clear inputs and outputs
- Minimize nesting depth: Avoid deeply nested workflow hierarchies for better maintainability and performance
- Handle errors gracefully: Implement proper error handling for child workflow failures and provide fallback mechanisms
- Document dependencies: Clearly document which workflows depend on others and maintain dependency maps
- Test independently: Ensure child workflows can be tested and validated independently from parent workflows
- Monitor performance: Be aware that nested workflows can impact overall execution time and resource usage
- Use semantic naming: Give workflows descriptive names that clearly indicate their purpose and functionality