Example Use Case: Enterprise Shipping Charges
Our enterprise shipping system has the following pricing rules:- Free shipping when:
- The order has 4+ items AND the total is $300+
- Standard shipping is selected (4-5 business days)
- Otherwise, shipping charges vary based on:
- Number of items
- Delivery speed (Next day, 2nd day, or Standard)
- Order total (less than 300+)
Version 1: Using Aletyx Playground
Step 1: Access Aletyx Playground
- Navigate to playground.aletyx.ai or run locally:
- From the welcome screen, click New Decision to create an empty DMN Decision (even if we’re not using it, this will be a quick way to incorporate project dependencies consistent for decisions.
- Click Apply Accelerator
- Select the Decisions Accelerator
- Now you can either download the project that would be configured for decisions or use Aletyx Playground to synchronize with Git. If you do the synchronization, you will be able to either Open with VSCode directly from Aletyx Playground or clone it from the created repository link.
Step 2: Create and Edit the Decision Table
- Create a new spreadsheet with the name
ShippingCharges.drland save it as the typexls. The reason for usingxlsoverxlsxis that the default settings for the Maven build will include the temporary file that Microsoft Office creates when a spreadsheet is actively opened. - In the new spreadsheet start adding the following starting in cell A1:
- Review and modify the first RuleTable for orders under $300:
- Review and modify the second RuleTable for orders of $300 or more:
Step 4: Create Required Java Classes
Create two Java files in your project: Order.javaStep 5: Test Your Decision Table
- Click Deploy to create a dev deployment
- Once deployed, use the test interface to submit test orders:
- Order 1: 2 items, 35)
- Order 2: 5 items, 0 - free shipping)
Version 2: Java 17 Project with Maven
Step 1: Create a Maven Project
- Create a new Maven project with the following structure:
- Set up your
pom.xml:
Step 2: Create the Model Classes
Create the Order and Charge classes in theai.aletyx.model package as shown in the Playground version.
Step 3: Create the Decision Table
Create the Excel decision table as described above and save it tosrc/main/resources/rules/ShippingCharges.drl.xlsx.
Step 4: Create the Application Class
CreateShippingChargesApp.java:
Step 5: Build and Run the Application
- Build the project:
- Run the application:
- Follow the interactive prompts to test different orders:
- Try an order with 2 items, $150 total, Next Day delivery
- Try an order with 5 items, $350 total, Standard delivery
Benefits of Excel Decision Tables
- Decision Analyst Friendly: Non-technical stakeholders can understand and modify rules
- Centralized Rule Management: All business rules in one visible location
- Easy Maintenance: Rules can be updated without code changes
- Version Control: Excel files can be versioned alongside code
- Rapid Iteration: Quick updates to business rules without recompilation