Overview

Break Down Workflows

Split large workflows into smaller, focused pieces for better maintainability and reuse

Reference Workflows

Use workflows from other workflows to create modular automation

Share Patterns

Create common workflow patterns that can be reused across your organization

Create Libraries

Build workflow libraries to standardize processes and reduce duplication

Workflow References

Reference other workflows to create modular, reusable automation:

workflow:
  tasks:
    - id: process_document
      workflow: ./workflows/document-processor.yaml
      with:
        document: "{{ trigger.document }}"

Input Mapping

When referencing workflows, map inputs using the with property:

workflow:
  tasks:
    - id: validate_data
      workflow: ./workflows/validator.yaml
      with:
        data: "{{ trigger.payload }}"
        options:
          strict: true

Workflow Libraries

Create reusable workflow libraries to share common patterns:

# workflows/document-processing.yaml
name: "Document Processing"
version: "1.0.0"

workflow:
  tasks:
    - id: validate
      use: task(schema_validator)
    - id: process
      use: task(content_processor)

Reference workflows from libraries:

workflow:
  tasks:
    - id: handle_document
      workflow: ./workflows/document-processing.yaml
      with:
        document: "{{ trigger.document }}"

Shared Context

Share context between composed workflows through:

  1. Input/Output Mapping
workflow:
  tasks:
    - id: first_workflow
      workflow: ./workflows/first.yaml
      with:
        context: "{{ trigger.context }}"

    - id: second_workflow
      workflow: ./workflows/second.yaml
      with:
        previous_results: "{{ tasks.first_workflow.output }}"
  1. Environment Variables
workflow:
  env:
    API_KEY: "{{ env.SHARED_API_KEY }}"
    ENVIRONMENT: "production"
  tasks:
    - id: sub_workflow
      workflow: ./workflows/sub-workflow.yaml
      # Environment variables are automatically available

Best Practices

  1. Workflow Organization

    • Keep workflows focused and single-purpose
    • Use clear, descriptive names
    • Maintain a consistent directory structure
    • Document requirements
    • Version your workflow libraries
  2. Input/Output

    • Define clear input contracts
    • Document expected formats
    • Handle optional parameters
    • Maintain consistent output structures
  3. Error Handling

    • Implement consistent error handling
    • Provide clear error messages
    • Clean up resources properly

References