What you’ll build
A pricing rule that:- Gives Gold members 15% off orders over $100
- Gives Silver members 10% off orders over $100
- Gives all customers 5% off orders over $200
- Returns the best applicable discount
Step 1: Create a new decision
- BRMS (Web UI)
- Playground
- Open your GoRules BRMS instance
- Navigate to your project (or create one)
- Click on Open Editor
- Click New and select File
- Name it “Customer Discount” and press Enter
Step 2: Add an input node
- From the node palette, drag an Input node onto the canvas
- This is where your data enters the decision
Step 3: Add a decision table
- Drag a Decision Table onto the canvas
- Position it to the right of the Input node
- Connect the Input node to the Decision Table by dragging from the Input’s output handle to the Decision Table’s input handle
Input → Decision Table
Step 4: Define input columns
Click Edit table to open the editor. Add two input columns:- Click Add input.
- Set the field to
customer.tierand label it “Customer Tier” - Click Add input again
- Set the field to
order.subtotaland label it “Order Subtotal”
Step 5: Define output columns
Add one output column:- Click Add output
- Set the field to
discountand label it “Discount”
Step 6: Add your rules
Add rows to define the discount logic. For each row, enter the conditions and outcome:Inputs
Outputs
Step 7: Test your rule
Click Open Simulator in the toolbar. Create a test event and enter:| Test case | Expected discount |
|---|---|
| Gold member, $150 order | 0.15 |
| Silver member, $150 order | 0.10 |
| Bronze member, $250 order | 0.05 |
| Bronze member, $50 order | 0 |
Step 8: Integrate with your application
Now that your rule works, integrate it into your application.- BRMS (REST API)
- SDK (Embedded)
The local changes must be committed to
main branch before evaluation is possible.Node.js
{projectId} with your project ID and {documentPath} with the decision path (e.g., customer-discount).