> ## Documentation Index
> Fetch the complete documentation index at: https://docs.algoreg.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Rules

> Configure scoring rules for the transactions

To define a rule for the real-time system, you must open the Go!KYT rules page.

## enc\_U2FsdGVkX18ZWeFj6u4wYPuqPPWc3ZCMT0SXDcY0eGc=\_enc

Each rule is defined by the following fields, in addition to the decision tree that we will present later:

| Field name | Description |
| - | - |
| `name` | The name of the rule. |
| `code` | A computer friendly code of the rule. |
| `description` | The description of the rule. |
| `weight` | If not null, the rule will participate to the score average computation, if null the max score will be used (see final scoring) |
| `active` | If false, the rule will be processed but the score will be ignored, it can be use to dry run a rule |

### enc\_U2FsdGVkX1+vTLMF2T0mboIfCrEAFaYImozUYM3cWcCxg0i6HA6eLk3qCElmQPeo\_enc

enc\_U2FsdGVkX1/KEqu9fCyRrPm3WeN49BqAF9pqTPGRuYFFk07xIAhkdoJdWSj/D+JanIBeaUo/6K1XpGxJRnzG+P4+N4ovP+ObBfnThiYI3LZv+4KzBg1TfgvGgJ6a+43TakPZehFd+NIya4eJ1KI0FLm+IDMlYIEAIVd9t6SPN16GhLkADhEEwQm7D5s0rO1kkaw+JDgNwPtLWKqeE8qgiQ==\_enc

Using this set of rules applied to a transaction:

| Code | Description | Weight | Resulting score |
| - | - | - | - |
| `amount_threshold` | Transaction amount is more than 100 000 € | null | 80 |
| `is_pep` | Customer is PEP | 1 | 80 |
| `is_high_risk` | Customer is high risk | 2 | 100 |
| `incoming_payment_wrong_name` | Transaction defined recipient name doesn't match real recipient name | 1 | 0 |

Here first we compute the weighted average which is `(80 + 0 + 2 * 100) / 4 = 70`.
Then we take the max of the rules without weight and this average which leads to `max(70, 80) = 80`.
The final score for the transaction will be 80 and the transaction will be delayed (if transactions are delayed for score between 70 and 90, see [review](https://docs.algoreg.com/docs/gokyt/real-time/transactions-review.md) page).

### enc\_U2FsdGVkX1/ZlTU/eWrYF9fD/ESGvqcLSXEHDMygXoA=\_enc

enc\_U2FsdGVkX188Rg+HeMZwaI0pN8bIegFL6UkTTFEubZTvy6cgS+GIOYtb7HCb0SEjhPn/eAWWTZRMA3oZOpJiu57VLd5tcKfhRnG+uJ5i9rreO8ZIUWb6kFN6NtFMfAuVVE2/LKrVlqYS3d9o8YnW1OVKHSBfHzeXzF3MXjgapsYiIlV3U2FeJPmAy/uwgcTU\_enc

![Example of a rule decision tree](https://mintlify.s3.us-west-1.amazonaws.com/algoreg/_assets/images/empty.png%3Foriginal=U2FsdGVkX1/VB3g3Lsa8uJ7Q2dQ10HHUIcJzYuI8kVlyUBy7+vqaIIZNEa4gTTcSPu1vbfwK6I8379xxhEUBlQ==)

Example of a rule decision tree (Go!Risk)

#### enc\_U2FsdGVkX18emSOuXN9ONWfm/Xxa+72fFGXMHJW55xM=\_enc

A matrix node will compare a variable with a set of values, and output one of four values: "high", "medium", "low" or "undefined".

The matrix node works on `strings`, `numbers` and `booleans`.

It has the following options:

| Option name | Description |
| - | - |
| `variable` | The variable to compare. |
| `matrix_id` | The matrix to use. |
| `use_regex` | If true, the matrix will use regex to match the variable. |

#### enc\_U2FsdGVkX18zq3EHIHtfPl36+SjIzDZ2yzU26rmvXyU=\_enc

The comparison node will compare two variables, and output one of three values: "yes", "no" or "undefined".

The comparison node works on `strings`, `numbers` and `booleans`.

It has the following options:

| Option name | Description | Example |
| - | - | - |
| `variables` | The variables code (aggregated to a single value). It can also be a static arbitrary value. | `payment_method.code` |
| `comparator` | One of the following values: `=`, `!=`, `>`, `>=`, `<`, `<=`, `regex`. | `regex` |
| `value` | An arbitrary value used for the final comparison. | `/^FR.*$/` |

#### enc\_U2FsdGVkX18T4gVcJR7uUVqGQ4G/RS6iwgX8xL+ZePs=\_enc

The formula node will compute a number result from multiple variables, compare it to a value and output one of three values: "yes", "no" or "undefined".

The formula node works on `numbers` and `booleans`. Booleans are converted to `0` or `1`.

It has the following options:

| Option name | Description | Example |
| - | - | - |
| `variables` | A map of named variables. | `converted_amount` and `30d_average_amount` |
| `formula` | A formula using the variables, the formula must return a boolean value and use valid math function defined [here](.). | `(converted_amount - 30d_average_amount) / 30d_average_amount` |
| `comparator` | One of the following values: `=`, `!=`, `>`, `>=`, `<`, `<=`. | `>` |
| `value` | An arbitrary value used for the final comparison. | `1` |

#### enc\_U2FsdGVkX1+r9/bxVcEtijYbPZ0cW5hKaCdZalQ8yP4=\_enc

The API node will call an external API, and output one of three values: "yes", "no" or "undefined".

It has the following options:

| Option name | Description |
| - | - |
| `endpoint` | The URL of the API to call, we will send a JSON object containing the transaction details using POST. The reply must be a TEXT of the format `yes` or `no` or a number starting from 0. Any other reply means "undefined". |
| `timeout` | The timeout in milliseconds, max timeout is 5 seconds. |

> [!WARNING]
>
> enc\_U2FsdGVkX18sESb/2sb4Z7HAW0br0dB2cp4JMXScV4zrYJ2f5SZyGLle4puGk/GTWlr7Ycs9Lfx5PG7PDy7CAr/HhamnYnkL3owgEuDbdhSvY5yXXPoIz/f/2sneOIr4\_enc
> enc\_U2FsdGVkX19+4zjsVV3cAhd+SZF4GNjLH6hiCLf5UwG6crkq0SIY8qsmHrgKhcShNxwJngGU6C5lEpYHd6ov1DeOenTNzp6u/PBNUSXYRlxOfd7VrKQeKwP+Lbzwx48ShFNp/c85oFeE8MlQRcer9A==\_enc
> enc\_U2FsdGVkX18ssM4kxSDUAMWnhCPOihKM1qpRaN3jbzLA/vOmxFCBzYjrPVoMXmnew7fDbz5UnMA5QMEG3MkPuU8/cjONWfm8p1e1s1HK2UVq6vevHeKDIXhmI/rBcX8m\_enc

#### enc\_U2FsdGVkX1+4vAFy0ofZ2uoAq6fo2Vlwe93vgxT4CNM=\_enc

Leaf nodes must define the following parameters:

| Option name | Description |
| - | - |
| `score` | The score to output for the rule if the node is reached, between 0 and 100. |

### enc\_U2FsdGVkX1+P/OvWDAAoLNFBsZPbCPai8vCy/gwYJ7xkRHj3nGj6Q4lfT7tsqoue\_enc

#### enc\_U2FsdGVkX1/9iXSOqoLgL41IVBbVsg7ne7oSu7uS5PdUAq6F8mNDSpSWVng00M+a/xRkcKTuGBM+cCo+fM76lA==\_enc

Everything defined in the [transaction](https://docs.algoreg.com/docs/gokyt/data-definition.md) and its participants is available for the rule engine.
If the participants, or institutions matches a known customer in Algoreg, the customer data (participant or institution of participant) will be available too as well as:

| Product origin | Variables |
| - | - |
| **Go!Scan** | `maybe_san`, `is_san`, `maybe_pep`, `is_pep`. |
| **Go!Risk** | current value of a risk factor from Go!Risk using the `risk_factor.[risk_factor_code]` computed variables, or the `risk_factor.overall` variable (contains `UNDEFINED`, `LOW`, `MEDIUM`, or `HIGH` values). |
| **Go!Vid** | `is_kyc_complete`, a boolean. |
| **Go!Press** | `press_score`, a number between -10 and 10. |
| **Go!Chat** | `active_threads_tags`, a string containing a list of tags for all non-closed threads. |

#### enc\_U2FsdGVkX1/ZDHCQxpkrCCbqxgqSiisekD9LvjV39AE=\_enc

In addition to this variables, the following variables are available on the **transaction** object:

| Variable name | Description |
| - | - |
| `converted_amount` | The transaction amount converted in EUR, better suited for comparison and threshold. |
| `name_match_score` | If an external\_id was provided, we return a matching score between the customer and the name defined by the emiter of the transaction, 0% for no match, and 100% for exact match. The comparison uses the same algorithms as Go!Scan |
| `[edge\|from\|to].[in\|out\|all].[1\|3\|7\|15\|30\|60\|90\|120\|180\|270\|365\|all].[max\|min\|sum\|count]` | Amount on a rolling window of the from, to or the relation between both participants. Note: in `edge` mode, `out` means `from->to` |



This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.