Workflow Concepts
Understanding n8n’s core concepts is essential for building effective automation workflows. This guide covers the fundamental building blocks you’ll use when integrating with Last Mile Intelligence.
Nodes are the fundamental building blocks of n8n workflows. Each node performs a specific task and passes data to the next node in the chain.
Types of Nodes
Section titled “Types of Nodes”Trigger Nodes
Section titled “Trigger Nodes”Start workflow execution. Common triggers include:
- Webhook - Execute when an HTTP request is received
- Schedule - Run at specified times (cron)
- LMI Trigger - React to LMI events (order created, task updated, etc.)
- Manual - Execute on-demand via the UI
Action Nodes
Section titled “Action Nodes”Perform operations on data:
- LMI Actions - CRUD operations on LMI resources
- HTTP Request - Call external APIs
- Code - Execute custom JavaScript/Python
- Database - Query databases directly
Flow Control Nodes
Section titled “Flow Control Nodes”Control workflow execution flow:
- IF - Conditional branching
- Switch - Multiple condition branches
- Merge - Combine multiple branches
- Loop - Iterate over items
- Wait - Pause execution
Data Transformation Nodes
Section titled “Data Transformation Nodes”Manipulate data between nodes:
- Set - Create or modify data fields
- Function - Custom data transformations
- Split Out - Separate array items
- Aggregate - Combine multiple items
Data Flow
Section titled “Data Flow”Items and JSON
Section titled “Items and JSON”Data flows between nodes as “items” - JSON objects with any structure:
{ "customerId": "cust_12345", "name": "Acme Propane", "tanks": [ { "id": "tank_001", "level": 45 }, { "id": "tank_002", "level": 72 } ]}Multiple Items
Section titled “Multiple Items”Nodes can output multiple items. Subsequent nodes process each item independently:
// Output from "Get Customers" node[ { "id": "cust_001", "name": "Customer A" }, { "id": "cust_002", "name": "Customer B" }, { "id": "cust_003", "name": "Customer C" }]Item Pairing
Section titled “Item Pairing”When merging branches, n8n pairs items by index or key fields.
Expressions
Section titled “Expressions”Expressions let you dynamically reference data from previous nodes.
Basic Syntax
Section titled “Basic Syntax”Access data using {{ }} syntax:
{{ $json.customerId }} // Current item field{{ $json.tanks[0].level }} // Nested array access{{ $node["Get Customer"].json.name }} // Specific node outputCommon Expressions
Section titled “Common Expressions”// String manipulation{{ $json.name.toLowerCase() }}{{ $json.firstName + ' ' + $json.lastName }}
// Date handling{{ new Date().toISOString() }}{{ DateTime.fromISO($json.createdAt).toFormat('yyyy-MM-dd') }}
// Conditional values{{ $json.status === 'active' ? 'Yes' : 'No' }}
// Array operations{{ $json.items.length }}{{ $json.items.map(i => i.name).join(', ') }}Special Variables
Section titled “Special Variables”| Variable | Description |
|---|---|
$json | Current item’s JSON data |
$binary | Current item’s binary data |
$node["Name"] | Access specific node output |
$input | All input items |
$execution | Execution metadata |
$workflow | Workflow metadata |
$now | Current timestamp |
$today | Today’s date |
Credentials
Section titled “Credentials”Credentials store authentication information securely.
How Credentials Work
Section titled “How Credentials Work”- Created in n8n’s credential manager
- Encrypted at rest
- Referenced by nodes (not stored in workflow)
- Can be shared across workflows
Credential Types
Section titled “Credential Types”Each integration has its own credential type:
- LastMile API - API key, URL, organization
- Samsara - API token
- Anova - API URL and token
- Fiserv - Merchant credentials
Execution Modes
Section titled “Execution Modes”Production Execution
Section titled “Production Execution”- Triggered automatically (webhooks, schedules)
- Runs in background
- Full error handling and retry logic
Manual Execution
Section titled “Manual Execution”- Triggered from n8n UI
- Interactive debugging
- View data at each step
Test Execution
Section titled “Test Execution”- Execute selected nodes only
- Pin test data for development
- Faster iteration during development
Error Handling
Section titled “Error Handling”Built-in Retry
Section titled “Built-in Retry”Configure automatic retries for failed nodes:
- Number of retry attempts
- Wait time between retries
- Exponential backoff
Error Workflow
Section titled “Error Workflow”Designate a workflow to handle errors:
- Create an error handling workflow
- Set it as the error workflow in settings
- Receive error notifications and take action
Try/Catch Pattern
Section titled “Try/Catch Pattern”Use the Error Trigger node in sub-workflows for granular error handling.
Workflow Patterns
Section titled “Workflow Patterns”Sequential Processing
Section titled “Sequential Processing”Nodes execute one after another:
Trigger → Get Data → Transform → Save → NotifyParallel Processing
Section titled “Parallel Processing”Split into multiple branches that execute simultaneously:
Trigger → Split ├→ Branch A → Merge └→ Branch B → Merge ↓ Combine ResultsConditional Branching
Section titled “Conditional Branching”Route execution based on conditions:
Trigger → Check Condition ├→ True Path → Action A └→ False Path → Action BLooping
Section titled “Looping”Process arrays of data:
Trigger → Get Items → Loop Over Items → Process Each → AggregateBest Practices
Section titled “Best Practices”Workflow Organization
Section titled “Workflow Organization”- Name workflows clearly - Use descriptive, searchable names
- Add notes - Document complex logic with sticky notes
- Use sub-workflows - Break large workflows into reusable pieces
- Version control - Export workflows and store in Git
Performance
Section titled “Performance”- Batch operations - Process multiple items in single API calls when possible
- Limit data - Only fetch fields you need
- Use pagination - Handle large datasets incrementally
- Avoid loops - Use built-in array operations when possible
Reliability
Section titled “Reliability”- Handle errors - Configure retries and error workflows
- Validate data - Check for required fields before processing
- Log important events - Use the “No Operation” node with notes for debugging
- Test thoroughly - Test with edge cases before activating
Next Steps
Section titled “Next Steps”- Custom Nodes - Explore available LMI integrations
- API Reference - Complete API documentation