Sim Studio

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:

  1. Takes a reference to another workflow in your workspace
  2. Passes input data from the current workflow to the child workflow
  3. Executes the child workflow in an isolated context
  4. 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.response.field> to reference outputs from previous blocks
  • Automatic Mapping: The selected data is automatically available as start.response.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

Examples of Input References

  • <variable.customerData> - Pass a workflow variable
  • <dataProcessor.response.result> - Pass the result from a previous block
  • <start.response.input> - Pass the original workflow input
  • <apiCall.response.data.user> - Pass a specific field from an API response

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

Inputs and Outputs

  • Workflow ID: The identifier of the workflow to execute

  • Input Variable: Variable or block reference to pass to the child workflow (e.g., <variable.name> or <block.response.field>)

Example Usage

Here's an example of how a Workflow block might be used to create a modular customer onboarding process:

Parent Workflow: Customer Onboarding

# Main customer onboarding workflow
blocks:
  - type: workflow
    name: "Validate Customer Data"
    workflowId: "customer-validation-workflow"
    input: "<variable.newCustomer>"
  
  - type: workflow
    name: "Setup Customer Account"
    workflowId: "account-setup-workflow"
    input: "<Validate Customer Data.response.result>"
  
  - type: workflow
    name: "Send Welcome Email"
    workflowId: "welcome-email-workflow"
    input: "<Setup Customer Account.response.result.accountDetails>"

Child Workflow: Customer Validation

# Reusable customer validation workflow
# Access the input data using: start.response.input
blocks:
  - type: function
    name: "Validate Email"
    code: |
      const customerData = start.response.input;
      const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
      return emailRegex.test(customerData.email);
  
  - type: api
    name: "Check Credit Score"
    url: "https://api.creditcheck.com/score"
    method: "POST"
    body: "<start.response.input>"

Variable Reference Examples

# Using workflow variables
input: "<variable.customerInfo>"

# Using block outputs
input: "<dataProcessor.response.cleanedData>"

# Using nested object properties
input: "<apiCall.response.data.user.profile>"

# Using array elements (if supported by the resolver)
input: "<listProcessor.response.items[0]>"

Access Control and Permissions

The Workflow block respects workspace permissions and access controls:

  • Workspace Membership: Only workflows within the same workspace can be executed
  • Permission Inheritance: Child workflows inherit the execution permissions of the parent workflow
  • API Key Access: Child workflows have access to the same API keys and environment variables as the parent
  • User Context: The execution maintains the original user context for audit and logging purposes

Best Practices

  • Keep workflows focused: Design child workflows to handle specific, well-defined tasks
  • Minimize nesting depth: Avoid deeply nested workflow hierarchies for better maintainability
  • Handle errors gracefully: Implement proper error handling for child workflow failures
  • Document dependencies: Clearly document which workflows depend on others
  • Version control: Consider versioning strategies for workflows that are used as components
  • Test independently: Ensure child workflows can be tested and validated independently
  • Monitor performance: Be aware that nested workflows can impact overall execution time

Common Patterns

Microservice Architecture

Break down complex business processes into smaller, focused workflows that can be developed and maintained independently.

Reusable Components

Create library workflows for common operations like data validation, email sending, or API integrations that can be reused across multiple projects.

Conditional Execution

Use workflow blocks within conditional logic to execute different business processes based on runtime conditions.

Parallel Processing

Combine workflow blocks with parallel execution to run multiple child workflows simultaneously for improved performance.

When designing modular workflows, think of each workflow as a function with clear inputs, outputs, and a single responsibility.