Back to Step Functions

invokeWorkflow

Intermediate

Embeds existing workflows within your current workflow, creating modular and reusable automation components with full context sharing.

overview

The invokeWorkflow function allows you to embed existing workflows within your current workflow, creating modular and reusable automation components. This powerful feature enables you to break down complex processes into smaller, manageable workflows that can be combined and reused across different scenarios.

Execute existing workflows inline within your current workflow, enabling modular design, code reuse, and sophisticated workflow composition while maintaining full context access and security boundaries.

Step Flattening: When you invoke a workflow, its steps are flattened and executed inline within your parent workflow. The invoked workflow has access to the full context of the parent workflow, including previous step outputs, global variables, and conversation context.

How It Works

1

Workflow Execution

The specified workflow is executed inline as part of your current workflow

2

Step Integration

Steps from the invoked workflow become available at the top level of your workflow context

3

Context Access

Invoked workflows have complete access to parent workflow context and variables

Key Benefits

Modularity

Break complex workflows into smaller, focused components that can be maintained and updated independently

  • Break complex workflows into smaller, manageable components
  • Create focused components with single responsibilities
  • Maintain and update components independently
  • Easier debugging and troubleshooting

Reusability

Create common workflow patterns once and reuse them across multiple workflows

  • Create common workflow patterns once
  • Reuse components across multiple workflows
  • Reduce code duplication and maintenance overhead
  • Ensure consistent logic across similar processes

Maintainability

Updates to invoked workflows automatically apply to all parent workflows that use them

  • Updates to invoked workflows automatically apply to all parent workflows
  • Centralized improvements and bug fixes
  • Easier version control and change management
  • Reduced maintenance overhead

Access Control

End users only need permissions for your main workflow - they don't need access to the invoked workflows

  • Users only need access to the main workflow
  • No need for permissions on invoked workflows
  • Simplified permission management
  • Secure workflow composition

input_parameters

ParameterTypeRequiredDescription
workflow_idstringThe slug/identifier of the workflow you want to invoke

Workflow ID Format: Use the workflow slug (e.g., 'customer-validation-workflow') exactly as it appears in the Vibes interface. The workflow must exist and you must have access to it.

Permission Requirements

Understanding permission requirements is crucial for successful workflow invocation:

Creator Permissions

You must have access to the workflow you're invoking. If you don't have permissions, the function will throw an error when executed.

  • Must have access to the workflow you're invoking
  • Function throws error if you don't have permissions
  • Validation occurs during workflow execution

End User Permissions

Users only need permissions to access your main workflow. They don't need direct access to the invoked workflows.

  • Users only need access to your main workflow
  • No direct access needed to invoked workflows
  • Simplified permission model for end users

Usage Examples

Basic Usage Example

Simple workflow that prompts for a database table and then queries it:

Database Table Query Workflow

Invoke workflows conditionally

Using conditionals to invoke different workflows based on context:

Request Type-Based Routing

Chaining Multiple Workflows

Create complex processing pipelines by invoking multiple workflows in sequence:

Multi-Stage Processing Pipeline

Customer Validation Example

Business process that validates customer information before proceeding with onboarding:

Customer Onboarding Pipeline

Document Processing Pipeline

Complex document analysis workflow that chains multiple specialized workflows:

Multi-Stage Document Analysis

Context and Variable Sharing

Invoked workflows have comprehensive access to the parent workflow's context and can share data seamlessly:

Available Context

  • Previous step outputs from the parent workflow
  • Global variables set in the parent workflow
  • Original conversation context and user inputs
  • File attachments and unique data

Step Reference Access

  • Standard step reference syntax (${steps.step_id.output})
  • Invoked workflow steps become available at top level
  • Direct access to invoked workflow step outputs
  • Seamless integration with parent workflow logic

Full Context Access

Global variables set in the parent workflow are available to invoked workflows:

Variable Inheritance Example

Accessing Invoked Workflow Steps

When a workflow is invoked, its steps become available at the top level of your workflow context:

Step Output Reference

Error Cases

Understanding common error scenarios helps with debugging and proper workflow design:

Permission Errors

When you don't have access to the workflow you're trying to invoke

Solution: Verify you can manually access the workflow in the Vibes interface and check workflow slug spelling

Workflow Not Found

When the specified workflow doesn't exist or has been renamed/deleted

Solution: Ensure the workflow exists, hasn't been deleted, and the slug is spelled correctly

Step Reference Issues

When you can't access steps from an invoked workflow in subsequent steps

Solution: Verify the step ID exists in the invoked workflow and that the workflow completed successfully

Error Handling Example

Implementing fallback workflows when primary workflows fail:

Fallback Workflow Pattern

Best Practices

Naming Conventions

Use clear, descriptive workflow IDs that indicate their purpose and maintain consistency across your organization.

  • Use clear, descriptive workflow IDs that indicate their purpose
  • Avoid generic names like 'workflow1' or 'helper'
  • Include the workflow's purpose in the ID (e.g., 'validate-customer-data')
  • Maintain consistent naming conventions across your organization

Modular Design

Design your invoked workflows to be self-contained and focused on specific tasks for maximum reusability.

  • Design invoked workflows to be self-contained and focused
  • Focus each workflow on a specific task or business process
  • Avoid overly broad workflows that try to do too many things
  • Create reusable components that can work in different contexts

Documentation

Document the expected inputs and outputs of workflows you plan to invoke for better maintainability.

  • Document what the invoked workflow expects as input
  • Document what outputs the workflow provides
  • Explain the workflow's purpose and when to use it
  • Maintain clear descriptions in workflow metadata

Security Considerations

Understand permission boundaries and ensure proper access control for workflow composition.

  • Verify you can manually access workflows before invoking them
  • Understand permission boundaries and security implications
  • Test workflow composition with different user permission levels
  • Monitor changes to invoked workflows that might affect parent workflows

Related Functions

These functions work well with invokeWorkflow for building sophisticated modular automation systems: