Create Simple Rule Flow
This tutorial will walk you through the creation of a Rule Flow.
Last updated
This tutorial will walk you through the creation of a Rule Flow.
Last updated
Let's advance one step at a time.
In this tutorial, you need to have knowledge of Decision Tables or Scripting Rules.
We have already learned how to create rules in previous tutorials, so let's skip it now and import these decision tables:
Clients - a rule that determines the maximum loan according to the client's age and salary
Loan Type - a rule that determines the maximum loan tax according to how much and for what the client wants to borrow
Bank Solver - a rule that calculates how much the client pays in total
How to import Decision Tables
You will be prompted to provide a name and choose between SAMPLE RULE or EMPTY RULE. The new rule will be created and its detail will be displayed. We will continue in the Rule Settings tab.
In our case, we recommend you select the empty rule.
When you click on RULE SETTINGS on the top left corner, the scripting rule's detail will appear first to set some information. We will change the name of our script. To do this, click on it's name, enter one you like and press Enter.
Since we do not want this rule to be available yet, we will change its status to "Pending". To do this, click on the current status "Published" and then select "Pending".
We will now create an input and output model, which will then be used to set conditions and results. You must be in Rule Flow Settings. There are 2 ways to create these models:
Simple editor: It is intended for inexperienced users who do not know the syntax of JSON files.
JSON editor: It is intended for an experienced user, with JSON knowledge.
First, we delete all created objects by clicking on the icon (in case you chose Sample Rule Flow). Then we will add our specified requirements (age, salary, loan, loanType). In our case, we create a root for each request by clicking on the button.
If our model were more complex, we would add descendants. More information is described here.
We set the output model similarly, where we set as root loan, tax, totalPay and message.
Output model Example:
First, we will create one object into which we will put other objects with our requirements. We will create one empty object for each request.
Our model is simple, these objects do not contain any others (embedded attributes). For more complex models, more information is here.
We set the output model similarly, where we set as root loan, tax, totalPay and message.
Output model Example:
Connect rules together and to input box and output box. In this case, the correct connect is as follows:
The rule should look as in the picture above.
To know, which data has to go where we have to map the data.
The example Rule Flow - Clients and Loan type works with user input data and subsequently, Bank solver works with input of user data and with outputs from previous rules makes the decision and sends final outputs to the output box.
Global variable means where the rule takes data from and output means what data. Because this rule is connected immediately after the input box, only user input data can enter it.
Correct mapping of Clients from example:
The loan type is also directly connected after the input box, so only input user data will also enter it.
Correct mapping of Loan type from example:
The bank solver is the final rule, that takes data from both the previous rules and the input box.
Correct mapping of Bank solver from example:
The final output can be data from any rule, so it is necessary to map the Output as well. In this example we want the following data to be in the output:
Loan - the amount the customer wants to borrow
Tax - tax of the loan
TotalPay - the amount the customer pays
Message - that confirming the loan or explaining its refusal
Correct mapping for output:
Now we can test our Rule Flow in Test Bench. Before testing the rule, we must change the status of the decision table to "Published" or have to debug mode ON. Debug mode allows you to test Rule Flow even when it is pending and at the same time writes data information to the debug mode console.
Now you can test your Rule Flow as you like, but for a positive result, it is necessary to have loanType set on "household", "car" or "vacation" because our bank does not lend to anything else.
You can add new loanType variables in the Loan Type rule via Preset values.
You can find more information about input and result at Solver API.
More information about Test Bench is here.
To display the rule creation pop-up click the button on the sidebar.
To apply these changes, we have to click on the button at the bottom of the page.
After creating an input or output model, we must always confirm the changes with the button
To create Rule Flow schema go to the Rule Flow Designer tab. At the start the canvas is empty. Add there input, output, and three empty rules with buttons in the top-right corner: ,,.
Click on the Empty rule to display the sidebar. By buttonchoose a rule, that will be in place of the empty rule.
If the rule has no inputs mapped. It borders in orange and displays a warning icon
Open data mapping by clicking on .