import { workflow } from '@novu/framework';
workflow('id', async ({ step, payload }) => {
await step.digest('digest', async () => {
return {
amount: 1,
unit: 'hours',
}
});
});
Workflow Interface
import { workflow } from '@novu/framework';
workflow(
workflowId: string,
handler: WorkflowHandler,
options?: WorkflowOptions
): WorkflowInstance;
This id should be unique within your organization.
handler
(context: WorkflowContext) => Promise<void>
required
The definition function of the workflow.
An optional options object for workflow level configurations
The schema to validate the event payload against, can be used to provide default values.
Workflow Context
This context is passed by the workflow engine to provide contextual information about current workflow execution.
The id of the subscriber, as passed during /events/trigger
request.
Nullable, the first name of the subscriber.
Nullable, the last name of the subscriber.
The payload of the event that triggered the workflow, will be validated
against the payloadSchema
if provided.
The object that contains all the step functions, read more at Step
Functions.