await step.custom('custom', async () => {
    return {
        hello: 'world',
    }
}, {
    outputSchema: z.object({
        hello: z.string(),
    }),
});
const { hello } = await step.custom('custom', resolver);

The custom step allows you to execute any custom code as a step in the workflow and persist the result to the workflow state. This is useful when you need to ensure a step is executed only once, or when you need to execute a step that is not supported by the SDK.

The custom step is typically used when you need to retrieve data from your own system, such as user data, then use that data for content of subsequent channel step content. By using a custom step to persist data once, you can avoid making repeated calls to your system and improve the performance of your workflow whilst reducing load on your system.

await step.custom('custom', async () => {
    return {
        hello: 'world',
    }
}, {
    outputSchema: z.object({
        hello: z.string(),
    }),
});
const { hello } = await step.custom('custom', resolver);

Custom Step Outputs

object
object
required

The custom step is a unique step that allows you to specify the output of the step, the output is strongly typed using the outputSchema.

Custom Step Result

object
object

The custom step returns any object that you responded with in the step resolver function.

Was this page helpful?