Core Concepts
Understanding the fundamental building blocks of Function Lab.Overview
Function Lab configurations consist of rules that evaluate conditions and execute events. Optional facts enable complex data transformations.Rules
A rule is the basic unit of logic in Function Lab.Structure
Required Fields
conditions: Object defining when the rule appliesevents: Array of actions to take when conditions are met
Optional Fields
facts: Named calculations for reuse in conditions and eventsif-not-events: Alternative events when conditions don’t match
Conditions
Conditions determine when a rule should fire. They query the input data using dot notation and predicates.Simple Condition
Multiple Conditions (AND)
OR Logic
Available Predicates
See Predicates Reference for complete list.
Events
Events define what happens when conditions match. Event structure depends on the function type.Product Discount Event
Multiple Events
A rule can have multiple events:Facts
Facts are named calculations that transform input data for reuse in conditions and events.Basic Fact
$ prefix references a fact in conditions.
Why Use Facts?
- Reusability: Calculate once, use everywhere
- Readability: Name complex expressions
- Performance: Avoid redundant calculations
- Power: Use JMESPath or custom filters for complex queries
Example: Collection Filtering
Input Data Structure
Function Lab receives cart and customer data from Shopify in a standardized format:Path Notation
Access nested data using dot notation:Array Access
Arrays are automatically traversed:Execution Flow
- Input Received: Shopify sends cart/checkout data
- Facts Computed: Named calculations evaluated once
- Conditions Evaluated: Check if rule should fire
- Events Executed: Generate discounts/operations
- Output Returned: Results sent back to Shopify
Next Steps
- How It Works - Detailed execution model
- Testing - Test and debug your functions
- Common Patterns - Real-world examples
- Function Types - Explore specific function types
