N8n workflows

From oyi77/1ai-skills · View interactive version

N8n workflows is an AI agent skill from the GitHub repository oyi77/1ai-skills. Use when n8n workflow automation — nodes, triggers, expressions, credentials, webhooks, error handling. Use when working with n8n workflows.

How to use this skill

Skill file

Overview

n8n is a fair-code licensed workflow automation tool. It provides 400+ integrations, visual workflow design, self-hosting options, and code flexibility with JavaScript/Python nodes.

Capabilities

When to Use

Trigger phrases:

When NOT to Use

Pseudo Code

Implementation patterns for common use cases with this skill.

Workflow Structure

Trigger → Set Variables → HTTP Request → IF Condition → Send Email / Slack
                                            ↓
                                      Code Node → Database

Expressions

// Access previous node data
{{ $json.fieldName }}
{{ $json.data.items[0].name }}

// Access trigger data
{{ $json.body.query }}

// Transform data
{{ $json.name.toUpperCase() }}
{{ $json.items.filter(i => i.active) }}

// Date
{{ $now.format('yyyy-MM-dd') }}
{{ $now.minus({ days: 7 }).toISO() }}

// Environment variables
{{ $env.API_KEY }}

Webhook Trigger

{
  "nodes": [{
    "type": "n8n-nodes-base.webhook",
    "parameters": {
      "httpMethod": "POST",
      "path": "my-webhook",
      "responseMode": "lastNode",
      "options": {}
    }
  }]
}

Code Node (JavaScript)

// Process items
const items = $input.all();
const results = items.map(item => ({
  json: {
    ...item.json,
    processed: true,
    timestamp: Date.now(),
  }
}));
return results;

Code Node (Python)

# Access input data
items = _input.all()

# Process
results = []
for item in items:
    results.append({
        "json": {
            **item["json"],
            "processed": True,
        }
    })

return results

Error Handling

{
  "settings": {
    "errorWorkflow": "workflow-id-for-error-handler"
  }
}
// Error workflow receives:
// - error.message
// - error.node.name
// - workflow.name
// - execution.id

Credentials

{
  "credentials": {
    "httpHeaderAuth": {
      "id": "1",
      "name": "My API",
      "type": "httpHeaderAuth",
      "data": {
        "name": "Authorization",
        "value": "Bearer {{ $env.API_TOKEN }}"
      }
    }
  }
}

Sub-Workflow

// Execute Workflow node
{
  "type": "n8n-nodes-base.executeWorkflow",
  "parameters": {
    "workflowId": "sub-workflow-id",
    "inputDataFieldName": "items"
  }
}

Common Patterns

| Pattern | When to Use |

|---------|------------|

| Webhook → Process → Response | API endpoint |

| Cron → Fetch → Transform → Store | Scheduled ETL |

| Email Trigger → Parse → Database | Email processing |

| IF → Branch A / Branch B | Conditional logic |

| SplitInBatches → Loop | Process large datasets |

| Error Trigger → Notify | Error alerting |

| Execute Workflow | Modular sub-workflows |

Error Handling

| Error | Cause | Fix |

|-------|-------|-----|

| Node execution failed | API error or timeout | Add retry on failure, increase timeout |

| Expression error | Invalid expression syntax | Check expression in editor |

| Credential expired | Token/key expired | Update credential |

| Workflow timeout | Long-running node | Increase execution timeout in settings |

Red Flags

Verification

Process

  1. Analyze the task requirements
  2. Apply domain expertise
  3. Verify output quality

Anti-Rationalization Table

| Rationalization | Reality |

|---|---|

| "Manual is faster for one-off tasks" | One-off tasks become recurring. Automate early, save time later. |

| "I will add error handling later" | You never do. Handle errors from day one. |

| "Automation is overkill" | If you do it twice, automate it. If you do it daily, it is critical infrastructure. |

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.