This example shows a workflow with two automated steps. The body function of each step can either be defined inline (using the lambda keyword) or as a separate function.
Body functions can use the context (ctx) to access data from previous steps or external systems. Read more in the context section.
The return value of each function can be accessed by subsequent steps using ctx.get_step_result("step-id").
The return value of screen steps is the value passed into the result field of the handleComplete function. In the example above (see greeting-screen.tsx), the return value will be the string "confirmed".
See the screens section for more information on how to create and customize screens.
Every step in a workflow can return a value. This value can be accessed by subsequent steps using ctx.get_step_result("step-id").
IMPORTANT: All outputs from workflow steps must be JSON serializable. This is critical for Sample Workflows to function properly, as step outputs are stored and passed between steps in a serialized format.
# ❌ Bad - Not JSON serializabledef process_data(ctx): return { "user": User(id=123, name="John"), # Class instance "callback": lambda x: x * 2, # Function "created_at": datetime.now() # Date object }
If you need to work with non-serializable data, convert it to a serializable format before returning from the step.
Sample Workflows are version controlled through Git, making it easy to track changes, collaborate with team members, and maintain different versions of your workflows.