Step Conditions

Create dynamic notification workflows using rule-based conditions. Control message delivery based on subscriber, payload, and workflow data.

Step conditions let you control whether a workflow step runs or is skipped. They allow you to build adaptive notification flows that respond to subscriber attributes, payload schema data, and outcomes from previous steps.

Conditions are configured per step and apply to both channel steps and action steps. This allows you to introduce branch logic into a workflow without duplicating steps or creating separate workflows.

Add step conditions

You configure step conditions from the Workflow Editor.

  1. Select a step in the Workflow Editor.
  2. In the Configure step panel, click Step Conditions. Step conditions
  3. Proceed to add your step conditions.

Step conditions

If the condition evaluates to true, the step runs. If it evaluates to false, the step is skipped and the workflow continues.

How the condition builder works

The step condition builder is rule-based and composed of three core elements:

  • Logical operators: Choose AND or OR to define how conditions are evaluated.
  • Conditions: Individual rules that compare a field, an operator, and a value.
  • Condition groups: Nested groups that allow more complex logic.

In the UI, you’ll see:

  • AND / OR selector buttons
  • + Add condition to add a rule
  • Add group to create nested condition groups

This structure allows you to model both simple checks and complex branching logic.

Supported operators

The condition builder supports a wide range of comparison operators:

OperatorDescriptionExample
=Equal tosubscriber.locale = "en-US"
!=Not equal tosubscriber.isOnline != true
<Less thanpayload.totalAmount < 100
>Greater thanpayload.totalAmount > 100
<=Less than or equal topayload.totalAmount <= 200
>=Greater than or equal topayload.totalAmount >= 200
containsContains a substringpayload.orderId contains "123"
begins withStarts withsubscriber.firstName begins with "J"
ends withEnds withsubscriber.email ends with "@xyz.com"
does not containDoes not contain a substringpayload.orderId does not contain "456"
does not begin withDoes not start withsubscriber.firstName does not begin with "M"
does not end withDoes not end withsubscriber.lastName does not end with "Smith"
is nullIs nullsubscriber.phone is null
is not nullIs not nullsubscriber.email is not null
inMatches one of several valuessubscriber.locale in ["en-US", "es-ES"]
not inDoes not match any of the listed valuessubscriber.locale not in ["fr-FR", "de-DE"]
betweenWithin a rangepayload.totalAmount between [50, 200]
not betweenOutside of a rangepayload.totalAmount not between [0, 50]

Data used for step conditions

Step conditions can evaluate data from several sources. Choose the source that best represents the decision you’re trying to make.

Subscriber data

Step conditions can use subscriber fields to tailor notifications based on user-specific data. For example, you can send an SMS only to users whose subscriber.isOnline is false.

To learn more about Subscribers model, refer to the Subscribers documentation

Payload data

You can use data from the payload schema or custom payload data passed during the workflow trigger call to the Novu API to configure step conditions. This allows you to define dynamic rules based on the data unique to each workflow execution.

Example payload data:

{
  "orderId": "12345",
  "totalAmount": 150,
  "orderStatus": "completed"
}

You can configure conditions such as:

  • payload.orderStatus = "completed"
  • payload.totalAmount > 100

Workflow variables

You can base conditions on workflow variables. These variables provide metadata about the workflow being executed and allow you to add conditional logic.

Workflow step conditions

The following workflow variables are available:

  • {{workflow.name}}: The name of the workflow.
  • {{workflow.description}}: The description of the workflow.
  • {{workflow.tags}}: An array of tags associated with the workflow.
  • {{workflow.severity}}: The severity level (high, medium, low, none) of the workflow.
  • {{workflow.workflowId}}: The unique identifier of the workflow.

Previous step result

For workflows involving sequential steps, conditions can also depend on the outcome of a previous step. For example, if the prior step was an in-app notification, then the condition could check:

  • steps.in-app-step.seen
  • steps.in-app-step.read
  • steps.in-app-step.lastSeenDate
  • steps.in-app-step.lastReadDate

This can be used for follow-up notifications. For instance, send an email only if the in-app notification was not read within 24 hours.

Context

You can use context variables in the Step conditions tab of a workflow step to add conditional logic to your notifications.

To learn more about context, refer to the Context documentation.

Dynamic data fields

The value field in a condition can also be a dynamic data field. This allows you to compare two data points dynamically rather than using static values.

For example:

{
  "operator": "AND",
  "conditions": [
    {
      "field": "payload.foo",
      "operator": "=",
      "value": "{{payload.bar}}"
    }
  ]
}

In this case, the step will execute only if payload.foo is equal to payload.bar at runtime. This enables flexible condition logic based on real-time data comparisons.

Advanced application state calculations
For more complex scenarios where you need to perform advanced calculations based on your application state, you can use the Novu Framework.

On this page

Edit this page on GitHub