Contextual Rule Component

A Contextual Rule component is used to configure a custom rule that can be applied in a particular context dictated by the Gear component. For example, you can create a rule that filters out promotions in a Contextual Bandit campaign based on whether a user has an attribute that matches the eligible promotion's related catalog object. These filtering rules can be checked when applied to any campaign, bandit arm, or segment. If a rule is not applicable for a particular environment, the filter is not applied.

The following table describes the available methods and implementations for the Contextual Rule component.

genericThe type of data the Gear component uses to identify whether to apply this filter. Examples include string, if trying to determine a particular related catalog object's value or number, for a rule based on a user's LTV. Place the filter into the <> brackets when declaring a class that implements ContextualRule.
contextValue()A method that returns the value the rule needs to calculate whether it matches. The return type must correspond to the type declared as the generic.
matches()A method returning a boolean, which is the actual logic for the rule.
metadata()A method returning RuleMetadata, an object containing information about the rule itself, including the name category it applies to and its compatible environments. The rule is not applied in incompatible environments.
description()A method returning a string that summarizes the rule (for the UI).
abbreviatedDescription()A method returning a string corresponding to a very brief (one or two word) summary of the rule to appear in the template editor UI.
logo()An optional method to return a font awesome icon that appears in the UI.

The following is an example of a Contextual Rule configuration.