1. Expressions and Data Manipulation Accessing Data: {{ $json.propertyName }} : Access property from current item's JSON. {{ $item(index).$json.propertyName }} : Access property from a specific item by index. {{ $node["Node Name"].json.propertyName }} : Access property from a specific node's output. {{ $node["Node Name"].length }} : Get number of items from a node's output. Context Variables: {{ $index }} : Current item's index. {{ $workflow.id }} : Current workflow ID. {{ $workflow.name }} : Current workflow name. {{ $run.id }} : Current workflow run ID. {{ $env.VARIABLE_NAME }} : Access environment variables. Common Functions: {{ $json.myArray.join(', ') }} : Join array elements into a string. {{ $json.myDate.slice(0, 10) }} : Substring (e.g., for dates). {{ $json.myNumber + 10 }} : Basic arithmetic. {{ $json.myString.toLowerCase() }} : String manipulation. {{ (new Date()).toISOString() }} : Current timestamp. {{ JSON.stringify($json.myObject) }} : Convert object to JSON string. {{ JSON.parse($json.myString) }} : Convert JSON string to object. Conditional Logic: {{ $json.status === 'success' ? 'Task Complete' : 'Task Pending' }} : Ternary operator. Complex conditions often handled better with an IF node. 2. Workflow Design Patterns Error Handling: Try/Catch Blocks: Use "Error Trigger" node. Connect failing nodes to "Error" output, then process with "Error Trigger" and "Error" nodes. Continue On Fail: Option in many nodes to prevent workflow from stopping on single item failure. Notifications: Send alerts (email, Slack) on error. Looping and Iteration: Split In Batches: Process large datasets in chunks to avoid memory issues or API rate limits. Looping over items: Most nodes process items iteratively by default. Looping over conditions: Use a "Function" node with custom code or "Loop" node for specific conditions. Workflow Reusability: Sub-Workflows: Call one workflow from another using "Execute Workflow" node. Pass data via input/output. Workflow Templates: Save common patterns as templates. Data Aggregation: Merge Node: Combine items from different branches (e.g., "Merge By Index" or "Merge By Property"). Aggregate Node: Summarize data (e.g., count, sum, average). 3. Custom Code & Advanced Nodes Function Node: Execute custom JavaScript code. return items; : Return processed items. return [{json: {output: 'value'}}]; : Create new items. Access input: $json , $item . Access n8n library: const { get } = require('lodash'); Function Item Node: Processes each item individually. Access item: item.json.property . Modify item: item.json.newProperty = 'value'; . Code Node: More advanced JS environment, allows external NPM packages. return [{ json: { newProperty: 'value' }}]; Can use $parameters for node configuration. Execute Command Node: Run shell commands on the n8n host machine. Use with caution due to security implications. Webhooks: Response Mode: "Respond to Webhook" vs. "Respond to Webhook (asynchronously)". Custom Headers/Body: Configure for specific API integrations. Authentication: API Keys, Basic Auth. 4. Performance & Scalability Batch Processing: Use "Split In Batches" for large datasets. Rate Limiting: Implement delays (e.g., "Wait" node) when interacting with APIs that have rate limits. Lazy Loading Data: Fetch only necessary data. Database Operations: Use batch inserts/updates when possible. Error Handling: Robust error handling prevents workflow crashes that consume resources. Resource Management: Monitor server resources (CPU, RAM) if self-hosting. 5. Workflow Management & Best Practices Naming Conventions: Clear, descriptive names for nodes and workflows. Comments: Use "Comment" nodes to explain complex logic or workflow sections. Credential Management: Use n8n's secure credential storage. Version Control: Export workflows as JSON for external version control (Git). Logging: Utilize "Log" node for debugging. Testing: Test workflows thoroughly with various data inputs (success, edge cases, errors). Environment Variables: Use $env for sensitive data or configuration that changes between environments (dev/prod).