Variants
Learn how to create and use multiple variants for workflow steps in Novu.
Variants is a workflow component that empowers users to create multiple versions of a given workflow step.
You can use variants to ensure that only specific versions of your workflow step (e.g Email) are sent to subscribers. These variants are linked to specific conditions. No variant can exist without a condition.
Variants are an integral component of our multi-tenancy feature.
Steps to create Variants
In this case, we’ll use a workflow Email step. Let’s create multiple variants for this step.
- Create an email step in your workflow.
Email step in workflow
- Add a variant to the step as shown below.
Add variant to workflow step
- A variant must have conditions set. Add a condition or multiple conditions.
Add conditions
In this case, we added a condition (as shown below) to check if the tenant identifier passed at the point of trigger is equal to edenlife
. This is now a multi-tenant variant!
Apply conditions to set it successfully.
Add conditions for the variant
The variant has been created. Click on the Update button.
Update the variant
- Head over to the email step again. You will see two variants: the root variant & v1 variant. The v1 variant is the one where you set the tenant condition while the root variant is the default version of the email step without a condition.
Root & v1 variants
- You can add different content to the two variants.
Root variant
v1 variant
During the notification sending phase, Novu’s logic will determine the appropriate variant based on the contextual information that was passed with the trigger event and the conditions applied to the variants.
In this case, if a tenant identifier with the value of edenlife
was passed with the trigger event, then Novu will select the v1 variant and send to subscribers.
On the other hand, if the tenant identifier has a different value or was not passed with the trigger event, then Novu will select the root variant and send to subscribers.
Variant Conditions
There are so many use cases for variants. It’s not limited to multi-tenancy.
You can set conditions based on the following data:
- Subscriber
- Payload
- Webhook
- Is online
- Last time was online
Sample Use Cases
-
If you’re looking to send a different type of email based on whether a subscriber is online, then variants are the right choice.
-
If you want to send different types of email to subscribers based on the specific type of payload or subscriber data passed with the trigger event, variants are a good choice!
Was this page helpful?