While workflows in the ADK are similar in concept to Workflows in Botpress Studio, they behave differently and shouldn’t be treated as equivalent.
Creating a workflow
Create a workflow insrc/workflows/:
Scheduled workflows
Workflows can run on a schedule using cron syntax:Steps
By default, workflows time out after 2 minutes—if you need to run a workflow for longer, you should use thestep function. This lets you break the workflow up into a series of steps that each take only a few seconds to run individually:
You can nest steps inside other steps—each step will complete when each of its sub-steps complete.
Reference
Thestep object also provides many additional methods for workflow control:
Step reference
Learn about all available step methods
Handling failing steps
If a step (or a step method) fails, it’ll throw a rejected promise. This will fail not only the current step, but the entire workflow. To avoid this, make sure you catch errors gracefully:options.maxAttempts field, it’ll throw an error after the maximum number of retries has been exceeded. You can track the retries using the attempt parameter and catch any errors:
Output
Workflows can return an output that matches the output schema:Reference
Workflow props
Handler parameters
The handler function receives workflow context and provides step management:Methods
Workflows can be started and managed programmatically:workflow.start()
Start a new workflow instance:
workflow.getOrCreate()
Get an existing workflow or create a new one with deduplication:
workflow.asTool()
Convert a workflow into a tool for use with execute():
workflow.provide()
Provide data in response to a workflow data request (used with step.request()):