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

# Decisions node (Public Preview)

A decisions node is designed to manage and execute decision table, which is composed of a set of rules.  Each rules will be evaluated in order from top to bottom and the result of the first successful rule will be returned as the final result.

## Rule

Each rule includes two parts:

* **conditions**: A set of conditions to evaluate.
* **actions**: The results to return when **all** conditions are satisfied.

### Condition

Each condition includes a key and a value expression. To simplify condition building and ensure correct syntax, use the `DecisionsCondition` class.

<Expandable title="supported types">
  * `number`: Integer or floating-point values.
  * `string`: Text values.
  * `date`: Locale-sensitive date strings. Supported formats include:
    * `3/14/2020`
    * `March 25, 2025`
    * `2020-10-20`
    * For the full list, see [any-date-parser](https://www.npmjs.com/package/any-date-parser)
      <Note>
        **Note:**
        The default format is 'YYYY-MM-DD', for example, '2025-07-31'.
      </Note>
</Expandable>

<Expandable title="supported expressions">
  * **Range** (number and date): Set a range specifying the expression "min:max" enclosed by `( )` or `[ ]` or combination of `( [ ) ]`.
    * `(` and `)`: for exclusive range.
    * `[` and `]`: for inclusive range.
  * **Operators**: The follow operators are supported.
    * `==`: equal (number, date and string), e.g. `== 5`
    * `!=`: not equal (number, date and string)
    * `>`: greater than (number, date)
    * `>=`: equal or greater than (number, date)
    * `<`: less than (number, date)
    * `<=`: equal or less than (number, date)
    * `contains` (string): checks if the key includes the value
    * `doesNotContain` (string): checks if the key excludes the value
    * `startsWith` (string): checks if the key starts with the value
    * `endsWith` (string): checks if the key ends with the value
</Expandable>

The following example checks whether the value of revenue\_quote\_ratio falls within the range from 0 (inclusive) to 50 (exclusive).

```py Python theme={null}
"conditions": {
  "revenue_quote_ratio": "[0:50)"
}
```

### Action

An action defines the result when all conditions in a rule are satisfied. You can also define a default action to return when no rules match.

## Locale

You can specify a locale string (e.g., en-US, fr-FR, es-MX) to control how dates are parsed. Currently, locale only affects date parsing.

## Example

In this example (`get_insurance_rate`), you define a set of rules to calculate the insurance rate based on credit grade and loan amount:

```py Python [expandable] theme={null}
def build_decisions(aflow: Flow) -> DecisionsNode:
    """
    Build a Decisions Table programmatically as a node.
    e.g. read from an Excel spreadsheet or CSV and populate the decision table.
    """
    rules = []
    ## We will be build the rules programmatically.
    rule1 = DecisionsRule()
    rule1.condition("grade", DecisionsCondition().equal("A")).condition("loan_amount", DecisionsCondition().less_than(100000))
    rule1.action("insurance_required", False)
    rules.append(rule1)
    rule2 = DecisionsRule()
    rule2.condition("grade", DecisionsCondition().equal("A")).condition("loan_amount", DecisionsCondition().in_range(100000, 300000, True, False))
    rule2.action("insurance_required", True).action("insurance_rate", 0.001)
    rules.append(rule2)
    rule3 = DecisionsRule()
    rule3.condition("grade", DecisionsCondition().equal("A")).condition("loan_amount", DecisionsCondition().in_range(300000, 600000, True, False))
    rule3.action("insurance_required", True).action("insurance_rate", 0.003)
    rules.append(rule3)
    rule4 = DecisionsRule()
    rule4.condition("grade", DecisionsCondition().equal("A")).condition("loan_amount", DecisionsCondition().greater_than_or_equal(600000))
    rule4.action("insurance_required", True).action("insurance_rate", 0.005)
    rules.append(rule4)
    ## We will be build the rules programmatically.
    rule5 = DecisionsRule()
    rule5.condition("grade", DecisionsCondition().equal("B")).condition("loan_amount", DecisionsCondition().less_than(100000))
    rule5.action("insurance_required", False)
    rules.append(rule5)
    rule6 = DecisionsRule()
    rule6.condition("grade", DecisionsCondition().equal("B")).condition("loan_amount", DecisionsCondition().in_range(100000, 300000, True, False))
    rule6.action("insurance_required", True).action("insurance_rate", 0.0025)
    rules.append(rule6)
    rule7 = DecisionsRule()
    rule7.condition("grade", DecisionsCondition().equal("B")).condition("loan_amount", DecisionsCondition().in_range(300000, 600000, True, False))
    rule7.action("insurance_required", True).action("insurance_rate", 0.005)
    rules.append(rule7)
    rule8 = DecisionsRule()
    rule8.condition("grade", DecisionsCondition().equal("A")).condition("loan_amount", DecisionsCondition().greater_than_or_equal(600000))
    rule8.action("insurance_required", True).action("insurance_rate", 0.0075)
    rules.append(rule8)
    node = aflow.decisions(
        name="assess_insurance_rate",
        display_name="Assess insurance rate.",
        description="Based on credit rate and loan amount, assess insurance rate.",
        rules=rules,
        default_actions={
            "assessment_error": "Not assessed. Incorrect data submitted."
        },
        input_schema=AssessmentData,
        output_schema=Assessment
    )
    return node
```
