Building blocks
Each Novu workflow is composed of 3 main components:- Trigger - The event that will start the workflow.
- Channel steps - The delivery method of the notification with the content.
- Action steps - Actions that will happen before and after a given channel step is executed.
Trigger
The trigger is the event that will start the workflow. In our current example thesample-workflow identifier will be used as our trigger id.
Workflow identifiers should be unique to your application and should be descriptive of the workflow’s purpose.
Channel steps
Channel Steps are the delivery methods of the notification. In our example, we have an email Channel Step that will send an email with the subjectWelcome to Novu and the body Hello, welcome to Novu!.
Novu’s durable workflow execution engine will select the relevant delivery provider configured for this channel and send the notification with the specified content.
Novu supports a variety of common notification channels out-of-the-box, including email, SMS, push, inbox, and chat.
To read more about the full list of parameters, check out the full SDK reference.
Action steps
Action Steps are purpose built functions that help you manage the flow of your workflow. In our example, we have a delay Action Step that will pause the workflow for one day before sending the email. You can also use Action Steps to perform other tasks such as fetching data from an external API, updating a database, or sending a notification to another channel. Novu supported the following Action Steps: delay, custom and digest.Create a workflow
Here’s a bare-bones example of a workflow to send a notification in response to a trigger:Just-in-time data fetching
You can add any custom logic needed into your steps. For example, you might want to fetch more information about your new user from a database during the workflow execution. You can achieve this with the following changes:Multi-step workflow
What if you want to send another update to the same user in one week? But you don’t want to send the follow-up if the user opted out. We can add more steps to the workflow to achieve this.- Sent a new signup email
- Waited 1 week
- Sent a follow-up notification in-app
Read the section on Controls next to learn how to expose Novu’s no-code
editing capabilities to your peers.
Payload schema
Payload schema defines the payload passed during thenovu.trigger method. This is useful for ensuring that the payload is correctly formatted and that the data is valid.