Preferences
Preferences conditions

Preference conditions

Power advanced conditional logic in your preferences.

Preference conditions are Knock condition models that are evaluated when computing the current state of your preferences during workflow execution.

Overview

Typically, a PreferenceSet evaluates to boolean values representing whether your recipient has opted in or out of receiving notifications on a given channel, workflow, or category.

With preference conditions you can add additional custom expressions to a PreferenceSet, where the notification is only sent if all preferences (including every condition in the preference conditions list) evaluate to true at runtime.

Below is an example of a workflow preference that has conditions applied to determine if the preference is true or false:

Set preference conditions for a user

Here's how to set preference conditions for a user.


Frequently asked questions

A condition can be applied at different points in the preference set:

  • Inside workflows, categories, or channel_types preferences
  • Inside an individual workflows[workflow].channel_types preference
  • Inside an individual categories[category].channel_types preference

Knock will capture conditions evaluation details for all preference conditions resolved while executing your workflows. See the guide on debugging conditions for more info.

Yes. You can use multiple conditions within a single preference conditions array. Note that all conditions in the array must evaluate to true in order for the notification to be sent; this is a logical AND operation.

No, this is not currently supported. Each condition in the conditions array must evaluate to true for a notification to be sent.