Overview
These examples show how to use Rules for real business scenarios. Each example includes the complete facts, rules, and output, with explanations of key patterns used.E-commerce: Checkout Pricing
Calculate final pricing for an e-commerce checkout with tiered discounts, shipping, and tax.Business Context
An online store needs to:- Apply volume discounts (5% at $50, 10% at $100, 15% at $200)
- Calculate shipping ($0 if order > $50, otherwise $7.99)
- Apply state tax based on shipping location
- Show formatted prices for display
Implementation
Key Patterns Used
- Array processing with wildcards to calculate cart subtotal
- Tiered discounts with conditional outcomes
- Lookup tables for state tax rates
- Conditional logic for free shipping threshold
- String formatting for display values
CRM: Lead Scoring & Qualification
Score and qualify leads based on multiple criteria for sales prioritization.Business Context
A B2B SaaS company needs to:- Score leads based on company size, industry, and engagement
- Determine if lead is qualified (SQL - Sales Qualified Lead)
- Assign priority level for follow-up
- Calculate days until follow-up is needed
Implementation
Key Patterns Used
- Weighted scoring from multiple criteria
- Lookup tables for size and industry scores
- String matching for job title evaluation
- Multi-condition qualification with AND/OR logic
- Priority assignment based on score thresholds
- Date calculations for follow-up scheduling
Customer Support: Ticket Routing & Prioritization
Automatically route and prioritize support tickets based on content and customer data.Business Context
A customer support team needs to:- Determine ticket priority based on urgency words and customer tier
- Calculate SLA deadline
- Route to appropriate team
- Flag tickets requiring manager attention
Implementation
Key Patterns Used
- Text analysis with string matching for urgency detection
- Weighted scoring from multiple factors
- Priority calculation with threshold-based assignment
- SLA deadline calculation with date operations
- Dynamic routing based on ticket category
- Automatic tagging with generateArray pattern
Marketing: Campaign Eligibility
Determine which marketing campaigns a customer is eligible for based on their profile and behavior.Business Context
A marketing team needs to:- Check eligibility for multiple campaigns
- Calculate discount offers
- Generate personalized recommendations
- Track campaign assignments
Implementation
Key Patterns Used
- Multi-criteria eligibility with boolean flags
- Multiple campaign evaluation in parallel
- Best offer selection using max operator
- Dynamic list generation with generateArray
- Personalized messaging with string templates
- Product recommendations with category mapping
Financial: Loan Approval Decision
Evaluate loan applications based on credit score, income, and debt-to-income ratio.Business Context
A lending institution needs to:- Calculate debt-to-income ratio
- Determine approval status
- Set interest rate based on risk profile
- Calculate maximum loan amount
- Specify required documentation
Implementation
Key Patterns Used
- Financial ratio calculations (DTI, LTV)
- Multi-criteria approval with AND logic
- Risk-based tiering with multiple conditions
- Dynamic document requirements with generateArray
- Conditional calculations for approved amounts
- Validation with feedback showing decline reasons
Inventory Management: Stock Reorder Decision
Determine when to reorder inventory based on current stock, sales velocity, and lead times.Business Context
A warehouse needs to:- Calculate days of inventory remaining
- Determine if reorder is needed
- Calculate optimal reorder quantity
- Set priority level for procurement
- Estimate next stockout date
Implementation
Key Patterns Used
- Inventory calculations (days of inventory, reorder points)
- Risk assessment with tiered thresholds
- Dynamic reorder quantities based on min/max levels
- Date projections for stockout estimation
- Priority mapping for procurement urgency
- Conditional recommendations with string templates
What’s Next?
Rule Patterns
Learn the common patterns used in these examples
Operations Reference
Detailed reference for all operators used
Core Concepts
Understand the fundamentals behind these examples
Getting Started
Start building your own rules
Need Help? Visit our Help Center or join the Community for support.