Skip to main content
In this quickstart, you’ll create a decision that calculates customer discounts based on order value and membership tier.

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

  1. Open your GoRules BRMS instance
  2. Navigate to your project (or create one)
  3. Click on Open Editor
  4. Click New and select File
  5. Name it “Customer Discount” and press Enter
The visual editor opens with an empty canvas.

Step 2: Add an input node

  1. From the node palette, drag an Input node onto the canvas
  2. This is where your data enters the decision

Step 3: Add a decision table

  1. Drag a Decision Table onto the canvas
  2. Position it to the right of the Input node
  3. Connect the Input node to the Decision Table by dragging from the Input’s output handle to the Decision Table’s input handle
Your graph now looks like: Input → Decision Table

Step 4: Define input columns

Click Edit table to open the editor. Add two input columns:
  1. Click Add input.
  2. Set the field to customer.tier and label it “Customer Tier”
  3. Click Add input again
  4. Set the field to order.subtotal and label it “Order Subtotal”

Step 5: Define output columns

Add one output column:
  1. Click Add output
  2. Set the field to discount and 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
Leave a cell empty to match any value. The last row acts as a default that catches all other cases.

Step 7: Test your rule

Click Open Simulator in the toolbar. Create a test event and enter:
{
  "customer": {
    "tier": "gold"
  },
  "order": {
    "subtotal": 150
  }
}
Click Run. You should see:
{
  "discount": 0.15
}
Try different inputs to verify your logic:
Test caseExpected discount
Gold member, $150 order0.15
Silver member, $150 order0.10
Bronze member, $250 order0.05
Bronze member, $50 order0

Step 8: Integrate with your application

Now that your rule works, integrate it into your application.
The local changes must be committed to main branch before evaluation is possible.
Call your decision via HTTP from the BRMS:
Node.js
const response = await fetch(
  'https://[your-brms-url]/api/projects/{projectId}/evaluate/{documentPath}',
  {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'X-Access-Token': '[your-project-token]'
    },
    body: JSON.stringify({
      context: {
        customer: { tier: 'gold' },
        order: { subtotal: 150 }
      }
    })
  }
);

const data = await response.json();
console.log(data.result);
// => { discount: 0.15 }
Replace {projectId} with your project ID and {documentPath} with the decision path (e.g., customer-discount).