Rule Node
Last updated
Last updated
The Rule Node allows users to incorporate logical decision-making within their workflows. Two types of rules can be implemented within a Rule Node:
SimpleRule: A SimpleRule
evaluates a condition and splits the workflow into two paths: one for when the condition evaluates to true (True Node) and another for when it evaluates to false (False Node).
DecisionTable: A DecisionTable
allows for more complex decision structures where multiple conditions and outputs can be evaluated and decided in a tabular form.
RuleSet: A RuleSet is a collection of SimpleRules and DecisionTables used to filter and process input attributes or datasets based on specified conditions, By combining multiple rules, users can organize and apply filtering criteria effectively, achieving desired outcomes seamlessly
Note: To add a rule node, the rule is not required to be published, it can be in staging as well. However, publishing the rule is compulsory before publishing the workflow, else the workflow will not be published.
Input Params: The Input Params section looks different for different types of Nodes. In the respective field of nodes, you can feed in respective constant values(like string or number) or map any outcomes from any previous Nodes using tokens available in the dropdown list or can map directly the global variables using tokens.
Note: Only compatible data-type tokens are available in the dropdown to select.
In the dropdown, there are three types of tokens you can see:
Trigger Nodes: {{ Trigger.attribute_Name }}
for example: Trigger.sensor_id
Previous Nodes: {{perv_node_Name.attribute_Name}}
for example: SetVariable1.output.key_1
Global Attributes: {{globalVar.attribute_Name}}
for example: globalVar.edtechLeadsBucketD
System Attributes: systemVar.attribute_Name
for example: systemVar.NULL
By hovering on the specific attribute, you can see the value of that input param. This feature allows you to check the attribute value you're adding to the input param field.
Run In Loop: This checkbox allows the rule to be processed multiple times in a loop. If checked, an additional field "enter list or custom token" is enabled to input a list or a custom token created during the trigger configuration.
Test Result: Once you've entered the input parameters, you can test the node to ensure it functions as expected by just clicking the 'Test' button. You'll see the following sections:
Input section: For the rule node, there is an input section that appear to show you the inputs you've given to the rule node.
Output Section: In the output section, same as the rule result tab, you can see the execution result in JSON format, along with the Action name and status(if all conditions are met).
For loops, only the first 10 items are used for testing.
The Settings section allows you to define broader operational parameters and any additional options controlling the rule node's behavior. Like timeouts, retrials, limits, etc. In rule node, you'll see the following actions:
The Rule Action Toggle is used to execute actions when all the conditions of a rule are met. This document explains the functionality and configuration of the Rule Action Toggle, including the effects of its toggled states and the "Wait for action(s) to finish" control.
By Default (Off): When the Rule Action Toggle is off, only the rules are executed, and their associated actions are not triggered. The JSON response contains a null output for these actions. The user cannot see the action execution results, can only able to see rule outcomes. You can see in the image, that the action is null here. This means, the actions for the rule are not executed.
Wait for action(s) to finish (Default Off): When the "Wait for action(s) to finish" toggle is off, actions are executed asynchronously in the background. Rules execute independently without waiting for associated actions to be completed. The JSON output contains only the rule outcomes, with action traces visible in the output once they are complete.
Wait for action(s) to finish (On): When the "Wait for action(s) to finish" toggle is on, the rule waits for the action to finish its task before proceeding to the next node. This ensures a synchronous flow where actions are completed before moving on to the next node. The results of actions are included in the JSON output along with the rule outcome.
Timeout After: Set a timeout duration for the rule. E.g., entering '30' sets the rule to timeout after 30 seconds.
Save: After configuring the node, save your node. It's important to test the node before saving the node if you want to use the output of this node in any of the subsequent nodes.
After adding the rule node, you can select the specific version that you want to use in the workflow like this:
If you want to check how many rules the workflow is using and along with their versions, go to the Dependency Map tab to check all the tabs and check the entities the workflow is using like this:
Note: Parameters coming via API cannot be remapped in this section.
If you turn this setting on, then even if the rule node gets any error, the workflow will continue to execute the next node with the error.
Let's take an example:
Let's say we have these 3 nodes in our workflow:
The first one is a Formula node, the second one is a Rule node and the third one is a database node.
In the past, our workflow system was designed with a stringent error management approach. If any node within the workflow encountered an error at any point during its execution, the entire process would come to a complete halt. This meant that if the first node, for example, "modified_cart," experienced any error, the workflow would not proceed to the next node. Instead, it would stop immediately at the first node, requiring immediate intervention to address the error before the workflow could continue. This approach prioritized error verification and strict control over processes, but it also meant increased interruptions and potential delays as errors were resolved one at a time.
Our current system introduces a feature called "Continue on error," which can be toggled on or off for each node in the workflow. When this setting is activated, it allows the workflow to proceed to the next node even if an error occurs in the current node. Specifically, if the first node, like "modified_cart," encounters an error while this setting is enabled, the workflow will not be halted. Instead, it will advance to the subsequent node, such as the rule node, with the error details passed along from the previous node. This functionality facilitates the continuation of the workflow despite errors, promoting greater flexibility and resilience in managing workflows by allowing for potential error handling at later stages of the process.
You can use a RuleSet inside a workflow to run multiple rules in parallel, optimizing performance where tasks can be executed independently. In parallel processing, each rule operates simultaneously without waiting for the others to complete, unlike concurrent execution, which may involve interleaving rule executions based on available resources. This ensures that all rules within the RuleSet execute independently, significantly improving efficiency for larger workflows. To execute this follow the below steps:
Create a new RuleSet: Go to the rule section and create a new ruleset. Inside that ruleset, add the rules you want to run parallelly. After configuring the ruleset, test the ruleset and save it.
Configure & Save: Once the rule node is configured then just save it.
Add Response Node: To get the response of the ruleset node, use a response node.
Test the workflow: Once done, click on "Test in Staging" and test the workflow.
Now, if you want to run only one rule at a time, use the switch block instead.
Toggle On: When the Rule Action Toggle is on, the associated actions are executed asynchronously once the rule's conditions are satisfied. Users can simultaneously see the results of these actions and the rule outcome. Actions are executed and their results are included in the JSON response. After toggling on, now you can see the action details, as shown in the image below:
Add Rule Node in Workflow: Now, come back to the workflow editor, where you want the parallel execution of the rules. Now add a rule node and select the Ruleset from the available list like this: