DecisionTable

Decision Table is apt when you have different outcome for different combo of conditions and want to create all outcomes in excel or table like view to edit / manage easily. In case of multiple matching rows, you can choose a policy to control how you want to run the rule.

In DecisionTable, you can determine when your rule should exit or continue, and how it presents the results. This documentation provides a step-by-step guide to help you understand and use DecisionTable effectively. Let's dive in and explore how to make the most of this powerful tool within Nected.

Creating a DecisionTable Rule:

Creating a DecisionTable rule in Nected allows you to establish multiple conditions for your dataset. To get started, log in to Nected using your Email ID and password. Then follow these straightforward steps to create a DecisionTable rule:

Step 1: Create new DecisonTable

After logging in, click on the "Rules" option in the left navigation panel. This will take you to the Rules page, where you can manage and create your rules.

  1. Click the + Create Rule button, which will display a popup with two options:

    • Build your own

    • Start from template

  2. Select Build your own to create a Decision Table from scratch:

    • Enter the Rule Name: Provide a concise, descriptive name that reflects the purpose of the Decision Table.

    • Provide a Rule Description (Optional): Add a brief description for context, useful for others or for future reference.

    • Select the Rule Type: Click on the Decision Table option. A Decision Table allows for the grouping of AND conditions and actions in a tabular format, suitable for handling complex scenarios where different actions are required for different conditions.

By choosing the right rule type, you can ensure that your decision-making process aligns with your specific use case. For more detailed information about each rule type and additional use cases they can address, please refer to the respective documentation links provided above.

Step 2: Define Decision Table rule Information

In this step, you need to provide essential information for your DecisionTable rule, including:

  1. Rule Name: Choose a unique and descriptive name for your DecisionTable rule. Ensure that the name is distinct throughout the Nected platform and does not contain spaces.

  2. Rule Description: Write a meaningful description that clearly conveys the purpose and function of your DecisionTable rule.

  3. Environment: Select either "Staging" or "Production" to determine the environment in which your DecisionTable rule will operate. Staging is a test environment where you can evaluate your rules before deploying them to production. Production is the live environment where your rules will be executed for your customers. By default, all new rules are created in staging.

  4. Rule Policy: Your rule's policy defines how it will execute. Choose from four policy options:

  1. First – The rule will exit after the first true value. For example, if you check for a BMW car of 2005 model in New York city in a table of cars, this policy will show only the first result even if the table has 5 entries that meet this condition.

  2. Unique – The rule will exit after finding the first unique true value. For example, if you check for a BMW car of 2005 model in New York city in a table of cars, this policy will not show any result because the table has multiple entries that meet this condition, thus it does not have a unique entry.

  3. Collect – The rule will collect all the true values. For example, if you check for a BMW car of 2005 model in New York city in a table of cars, this policy will show all 5 results in the exact same order as they are listed in the table.

  4. Order – The rule will display all the true values in the ascending order. For example, if you check for a BMW car of 2005 model in New York city in a table of cars, this policy will show all 5 results in the ascending order.

  5. Evaluate All - The rule will be executed anyhow even if the rules are not satisfied. The decision table result contains the output entries of all satisfied, unsatisfied and the rules with error in the order of the rule specified in the decision table.

These policies allow you to control the behavior of your DecisionTable rule and tailor it to your specific needs.

Step 3: Adding Source

Before configuring a rule in Nected, determine the data source that the rule will utilize. Nected offers versatility in data source definition:

  • Direct Input Attributes: With Nected, you can designate custom attributes tailored to your rule. These act as dynamic values supplied alongside API parameters during rule execution. For example, for a discount rule, you might use parameters like "customer type" and "purchase amount." Such parameters offer on-the-fly adjustments when invoking the rule via an API.

  • Fetch from your Database via DataSet: If you have an existing database, Nected lets you extract parameters directly from it through a dataset. By choosing a dataset, you can refer to its attributes within your rule conditions. For instance, for a rule assessing discounts from a customer's purchase history, you might use a sales dataset to access attributes such as "customer ID" or "total amount".

  • Fetch from any internal/external API: Over Nected, you can integrate with any 3rd party API to fetch input attributes & data directly to be used in the Rule. For instance, you can fetch customer's KYC, credit history or purchase data with your vendor, and you want to use those data points as well as in your business logic.

  • Combination of All: Merging custom input parameters with a dataset as well as API is the optimal method. It harnesses your dataset's structured data, let you combine 3rd party data but then also allows for specific parameter overrides when executing the rule. In the discount rule context, this means leveraging dataset information for general trends, while also accommodating unique discounts or promotions via custom parameters.

The right data source setup empowers your rules to span diverse scenarios, from utilizing historical data to making real-time adjustments based on distinct parameters.

Step 3.1: Add Custom Attributes

Should you need attributes absent from your dataset, or if you prefer a dataset-independent rule relying solely on custom attributes, you can define these as per your rule's needs.

  1. Just click on the "Add Input Attributes" Button and don't choose any dataset.

  2. Click on +Add Field and type in Key Name and choose Primitive Data Type from the dropdown. You won't need any Data Mapping as this is not from any dataset. You can choose the configuration if the field can be null, should be compared in case case-sensitive manner, and/or if it is optional. Eg - For the loan approval example, you might create attributes like customer_id, customer_location and product_name.These attributes will be used in evaluating rule conditions.

  3. Click on Save

Nected further offers an efficient approach to attribute definition, eliminating manual data source mapping. You can specify a primary identifier, which Rule uses to automatically retrieve the required data from the database via the dataset. Here's how to define custom input attributes with dataset attributes:

  1. Just click on the "Add Input Attributes" Button and select the dataset that you want to attach to the Rule.

  2. Click on +Add Field and type in the primary identifier or key name using which, all other corresponding data can be fetched from your dataset. This identifier acts as the anchor to retrieve related data automatically. For a loan approval rule, for instance, "customer_id" might be your choice.

  3. Click Type. Select the dataset from Import From Dataset.

  4. From the Data Mapping, choose the column name with which you want to map this primary identifier.

Primary Identifier is only needed if you have attached any dataset directly in the rule.

If you would type multiple data fields mapped, then the combo of all would be treated as the primary identifier.

Step 4: Define Rule Condition

In this step, you will need to define a decision condition. The decision condition is a set of rules that you can use to make decisions.

Step 4.1: Configure Row Conditions

In this step, you can configure the following rule properties:

  • Custom Functions: This is a JavaScript editor where you can write a JavaScript formula that includes attribute-based tokens to define conditions in the rule. Custom functions provide flexibility in specifying complex logic.

  • Input Attributes: Input attributes are the local attributes created for use within this rule. These attributes can be used in conditions and actions within the rule.

  • System Attributes: System attributes are provided by the system and are related to time and other system-related information.

  • {Dataset}: If you've selected a dataset as the source, you can use attributes from the dataset to form conditions within the rule. This allows you to leverage the data in your dataset for decision-making.

Step 4.2: Define Conditions and Operators

Conditions are the criteria that determine when the rule should take action. You can create conditions using a variety of operators. Nected supports the following types of operators:

  • Common/Generic: Any, Exists, Does Not Exist, Is Null, Not Null

  • Numeric Ops: Between, Not Between, Equals, Not Equals, Greater than, Less than etc.

  • String Ops: Equals, Not Equals, Contains, Does Not Contain, Starts With etc.

For more detail info about the operators, read this page Operators.

You can combine conditions using logical operators to form complex conditions. These logical operators include AND, OR, and NOT.

Step 4.2.1: Define the Values

Now after defining the operators for each properies, you need to define the values for them. Values can mostly be constants or tokens of the same datatype as property.

Step 4.3: Condition and Group Creation

To create a condition, you will need to specify the field that you want to evaluate, the operator, and the value. To create a group, you will need to click on the “+” button.

Unlike the SimpleRule, in the Decision Table you have only one logical operator i.e. “AND”.

Step 4.4: Customize the Conditions

To enable or disable any piece of condition, you just need to click the toggle button on the left side of a condition. Similarly, at the left side just beside the toggle button, there is a three dot drop down button. By clicking the drop down button you can

  1. Add a new row above or below of that exact row.

  2. Duplicate a condition

  3. Delete the condition

Just below of the condition table, there is a button “+Add additional Data”. Clicking this button will open a Javascript editor where you can add more information( static and tokenized) to customize your rule.

Step 5: Define Results and Actions

In this step, you need to define the results and actions of your DecisionTable rule. These results and actions are critical aspects of configuring your rule to make data-driven decisions. Here's how to do it:

Step 5.1: Defining Results

When you add results, you specify the type of data you expect from the rule. DecisionTable rules support various result data types, including:

To add Rule Result follow these steps:

  1. Go to the rule editor, and click + button on Result tab, and a dropdown will appear. From there choose the type of result you want to return when a specific condition met. Here are the types of data you can add: [Boolean, Numeric, String, Date, JSON, Custom JavaScript Formula]. The result will be denoted as key_name. Read Rule result, to know more about it.

  2. After configuring the Rule result, test it and check if they're working properly or not.

Step 5.2: Adding Actions

Adding actions allows you to specify what your rule should do when its conditions are met. Nected provides a wide array of action options, each tailored to serve different purposes. These actions can include sending notifications, updating a database, triggering external processes, and more. You can

  • Database Operations: As a rule action, you can perform operations on a database, such as inserting, updating, or deleting records. This is valuable for keeping your data up-to-date.

  • Triggering REST API: Rules can trigger REST API calls, enabling interactions with external systems. This action can be customized to send specific payloads and parameters as needed.

  • Slack: You can add Slack as well as a rule action, to trigger some functions like sending notification or something else.

  • Google Sheet: Same as database, you can also trigger a google sheet, to do CRUD operations in the sheet or some other operations.

To add actions in rule, follow these steps:

  1. In the rule editor, click on +Add Action button.

  2. Then from the dropdown, select the specific type of action. And then configure your action. For more detailed guide follow the steps shown in Rule Action.

  3. After configuring the Rule action, test it and check if they're working properly or not.

The choice of data type and action depends on the objectives of your rule. Consider your use case and desired outcomes to select the most appropriate options. For detailed information on adding actions, you can refer to the rule actions.

Step 6: Testing

Nected allows you to test rules in a staging environment before deploying them to production. This helps to ensure that your rules are working as expected. Also, testing your DecisionTable rule is a crucial step as without this, you wouldn't be able to publish / re-publish your rules.

To test a rule, click the Test button.

Testing scenarios

Nected supports a variety of testing scenarios, including:

  • Testing with different values for the input parameters.

  • Testing with null values for the input parameters.

  • Testing with optional input parameters.

Now, If a rule has nullable input parameters, you can test the rule with null values for those parameters. If a rule has optional input parameters, you can test the rule with and without those parameters.

Testing example

To test a rule with different values for the input parameters:

  1. Click the Test in Staging button.

  2. In the Test Rule dialog box, enter different values for the input parameters.

  3. Click the Test Now button.

  4. After the test is completed, it generates a JSON code as the output.

  5. If you see the success message (which you've given while adding data) in the code, that means your rule is ready to publish. If you see the failure message, that means your rule is not ready to publish.

Significance of testing

Testing is important to ensure that your rules are working as expected. By testing your rules in a staging environment before deploying them to production, you can prevent errors and ensure that your rules are not causing any unintended consequences.

Testing is mandatory to do on each edit before publishing to make sure that rule is behaving as expected and without errors.

Step 8: Publish the Decision Table

Once you are confident in the rule's functionality, publish it. This action makes the rule available for use within your Nected environment.

Step 9: Rule Access via API

Nected offers a powerful API that allows you to access and execute your rules programmatically. This means that you can integrate your rules with other systems and automate your decision-making process.

Now, for SimpleRules, DecisionTable and RuleSet the process of Rule Access via API is exactly the same. Read here to know how to trigger Rule via API in different environments.

Rule Status: Managing Your Rules

In Nected, rules can go through three distinct statuses (Draft, Tested, Published/Live), each serving a specific purpose in the rule creation and deployment process.

These three statuses - Draft, Tested, and Live - provide a clear and organized framework for managing your rules within Nected, allowing you to seamlessly develop, test, and deploy rule-based decisions for your applications while maintaining a structured workflow.


As you continue to work with Nected, you may also explore additional features like the Simple Rule Table and Rule Set. Simple Rule is ideal when you have. complex, nested if/else rules to set single outcome based on matching result. Rule Set provides a way to organize and execute multiple rules at once under a single umbrella.

Last updated