Rules can be a useful tool alongside machine learning. Your company may have unique business policies that you’d like to implement within Ravelin. For example, you may want to:
- Prevent all orders greater than $100 made from a customer who opened an account within the past 30 days
- Allow all orders from customers who are tagged as 'VIP'
Rules allow you to implement this business logic as specific actions to be taken whenever an order matches the conditions that you define.
For each rule, you'll need to select the action (Allow, Prevent, Review) triggered by the rule and define the conditions under which the rule is triggered.
A rule can contain up to eight conditions. A condition is made up of three parts:
- Attribute - The attribute of the order (e.g. the order value or the customer account age)
- Operator - The arithmetic that compares the criteria to the value (e.g. less than or equal to)
- Value - The value you wish to use (e.g. 100.00 GBP)
Creating Rules on the Dashboard
Only people who have Admin or Developer access are able to create rules.
You can create and manage rules in the Rules section of the dashboard. The Rules section can be found via this icon on the left menu:
To add a rule, click the blue Create rule button towards the top right of the Rules page.
Click Add condition and select the conditions that you want your rule to have. This includes choosing the attribute, operator and value for the condition. You can filter by types of conditions (for example all conditions to do with an Order or Customer) or you can search by condition name. Each condition has a description of what it is and an example.
Once you are happy with the conditions of the rule, you can set the action you want the rule to result in. You can set this to Allow, Review or Prevent.
In order to publish the rule, you first have to test the rule by selecting the ‘Estimate Rule Impact’ button. This will give you an indication of whether the criteria used are too strict or not strict enough.
The Estimate Rule Impact will show you the exact breakdown of active customers in the last 7 days that would be impacted by the rule. A visual summary of the recommendation, score distribution and manual reviews is also shown.
If the rule impact estimate is over 5% and the rule action is Prevent, you will not be able to create the rule.
Any Allow or Review rules up to 20% impact can now be created by Admins, with an added warning confirmation step to highlight the consequences of the rule being created.
Please contact us if you are unable to create a rule - Ravelin can do further analysis on the rule impact and discuss options for implementation.
Using AND/OR logic within Rules
By default, rule conditions are joined together with an AND operator. To switch this to OR, select the AND dropdown menu and choose OR:
To apply an AND/OR operator to groups of conditions, select the "Add condition group" option:
This allows you to achieve an example such as the following, where two AND groups of conditions are separated by an OR:
Creating Test Rules
Test Rules allow you to evaluate a rule without it impacting any customers. Test Rules will NOT result in a recommendation for a customer. For example, if you create a Test Rule and set the action to Prevent and a customer meets the criteria specified, you will be able to see that the customer would have been impacted by that rule but we won’t return that result when you score the customer.
Users with the Analyst role are access are able to create Test Rules, but only users with the Admin or Developer role can enable Live rules.
You will need to select the Estimate Rule Impact button, but you can add a Test Rule regardless of what the result is (unlike Live Rules).
To add a Test Rule, select Run in Test Mode when creating a rule - this can be found under the Publish Rule step.
Evaluating Test Rules
You can review which customers would have been affected by a Test Rule in Explore. Under the Customers and Orders list you can use the Test Rules filter to see which customers and orders would have been impacted by the rule if it were live.
Please note, the filter will not show you customers or orders who matched the criteria only. The filter will display customers and orders who matched the criteria AND where the rule would have been responsible for the recommendation.
You can also review Test Rule performance in Analytics by using the Test Rules segment.
If your Test Rule does not impact many customers taking into account other sources e.g. if on its own it does not have a significant impact then it may be worth reconsidering whether you want to promote that rule to Live Mode or not.
You can change a rule mode at any time by updating the rule. To do this, edit the Test Rule and change the selection to Run in Live Mode. To change the mode, you will need to run the Estimate Rule Impact again.
Managing Rules on the Dashboard
The Rules list page shows you the Live and Test Rules that are in place. You can search for specific rules by name using the search bar at the top left of the rules list page. Alternatively, you can also filter by Action and the user that created the rule by using the dropdown filters on the right of the rules list page.
To edit or delete a rule, select the menu option towards the right of each rule.
Processing Order
Each order will be evaluated against the rules you have created and processed in a specific order. In most cases, rules are processed in the following order unless you have specifically asked for the processing order to be altered for an individual rule:
- Allow
- Prevent
- Review
If a payment matches a rule's conditions, the rule's action is recommended and no other rules are processed. For example, if an Allow rule is triggered, no Prevent or Review rules will be processed. Allow rules should rarely be implemented as they override other rules in place.
Within the greater Ravelin system, manual reviews will always take precedence over rules. In addition, rules will always take precedence over Ravelin fraud scores.
Account Takeover Rules
If you are using the Account Takeover product you also have access to the see, create and edit account takeover rules.
Only people who have Admin or Developer access can create and edit rules.
Account takeover rules allow you to set specific actions to be taken when a login matches the conditions defined to combat account takeover.
You can also set account takeover rules at checkout.
For each rule, you'll need to select the action triggered by the rule and define the conditions under which the rule is triggered.
In the rules list page you will see rules grouped by checkpoint.
- Checkout (pre or post auth)
- Login
You will also be able to filter by rule type e.g. account takeover or payment fraud.
When creating rules you will need to select the checkpoint and the rule type that the rule relates to e.g. a checkout rule intended to prevent account takeover.
The conditions available at the different checkpoints will differ - at the login checkpoint the conditions will relate to login events rather than the customer more generally.
Creating a rule otherwise follows the steps outlined above:
- Add conditions
- Set the action
- Evaluate the impact
- Set the mode
- Include a name
- Publish the rule
Regular expressions in Rules
To write a regular expression, you use a combination of ordinary characters (such as letters and numbers) and special characters, which are known as metacharacters. These metacharacters have special meanings and are used to represent different sets of characters or to perform certain actions.
Here are some common metacharacters and their meanings:
.
(dot) - represents any single character*
- represents zero or more occurrences of the preceding character+
- represents one or more occurrences of the preceding character?
- represents zero or one occurrence of the preceding character^
- represents the beginning of a string$
- represents the end of a string[]
- represents a set of characters()
- group a set of characters or expressions
car
- would match the string "car"ca*r
- would match the strings "cr", "car", "caar", and so onca+r
- would match the strings "car", "caar", "caaar", and so onca?r
- would match the strings "cr" and "car"^car
- would match the string "car" if it appears at the beginning of a linecar$
- would match the string "car" if it appears at the end of a line[ct]ar
- would match the strings "car" and "tar"(ca)r
- would match the string "car" and capture the group "ca"