You can start another workflow run inside a workflow and await its execution to complete.
This allows to orchestrate multiple workflows together without external synchronization.
When you use context.invoke
, invoking workflow will wait until the invoked workflow finishes before running the next step.
const {
body, // response from the invoked workflow
isFailed, // whether the invoked workflow was canceled
isCanceled // whether the invoked workflow failed
} = await context.invoke(
"analyze-content",
{
workflow: analyzeContent,
body: "test",
header: {...}, // headers to pass to anotherWorkflow (optional)
retries, // number of retries (optional, default: 3)
flowControl, // flow control settings (optional)
workflowRunId // workflowRunId to set (optional)
}
)
You can return a response from a workflow, which will be delivered to invoker workflow run.
You can navigate between the invoker and invoked workflow runs on the dashboard
You cannot create an infinite chain of workflow invocations. If you set up an ‘invoke loop’ where workflows continuously invoke each other, the process will fail once it reaches a depth of 100.