AgentSkillsCN

n8n-automation

精通 n8n 工作流的构建,打造可投入生产环境的成熟工作流。整合 8 项专业技能,涵盖模板搜索、表达式、MCP 工具、模式、校验、节点配置、JavaScript 与 Python 代码。适用于创建、验证或调试 n8n 工作流时使用。

SKILL.md
--- frontmatter
name: n8n-automation
description: Master skill for building production-ready n8n workflows. Combines 8 specialized skills for template search, expressions, MCP tools, patterns, validation, node configuration, JavaScript and Python code. Use when creating, validating, or debugging n8n workflows.

n8n Automation Master Skill

Unified skill that orchestrates 8 specialized n8n skills to build production-ready workflows.


🔧 Sub-Skills Included

SkillPurposeWhen Activated
n8n-template-searchTemplate discoveryFinding workflow templates, examples
n8n-mcp-tools-expertMCP tool usageSearching nodes, templates, validating
n8n-workflow-patternsArchitectural patternsCreating new workflows
n8n-expression-syntaxExpression syntax$json, $node references
n8n-validation-expertError handlingValidation failures, debugging
n8n-node-configurationNode parametersConfiguring complex nodes
n8n-code-javascriptJavaScript codeCode node JS scripting
n8n-code-pythonPython codeCode node Python scripting

🎯 Quick Reference

Template Search (ALWAYS START HERE!)

MCP Template Library (2,709+ templates):

  • search_templates - Find by keyword, nodes, task, metadata
  • get_template - Get template JSON for deployment

Web Template Discovery (for recent/community templates):

  • Load n8n-template-search skill for comprehensive web search
  • Combines n8n.io, GitHub, forum sources

MCP Tools Available

Always Available (no n8n API needed):

  • search_nodes - Find nodes among 1,084+ available
  • get_node - Get node documentation and config
  • validate_node - Check node configuration
  • validate_workflow - Validate complete workflow
  • search_templates - Search 2,709 templates
  • get_template - Get workflow template JSON

Requires n8n API Key:

  • n8n_create_workflow - Deploy workflow
  • n8n_update_partial_workflow - Update workflow
  • n8n_validate_workflow - Validate by ID
  • n8n_deploy_template - Deploy template directly

nodeType Format (CRITICAL!)

javascript
// For search/validate tools: SHORT prefix
"nodes-base.slack"
"nodes-base.httpRequest"
"nodes-langchain.agent"

// For workflow tools: FULL prefix  
"n8n-nodes-base.slack"
"n8n-nodes-base.httpRequest"
"@n8n/n8n-nodes-langchain.agent"

📋 Workflow Creation Process

Step 0: Template Discovery (ALWAYS FIRST!) 🔍

CRITICAL: Before building anything, search for existing templates!

javascript
// Quick keyword search (MCP - fastest)
search_templates({query: "slack notification"})

// Search by specific nodes
search_templates({
  searchMode: "by_nodes",
  nodeTypes: ["n8n-nodes-base.webhook", "n8n-nodes-base.slack"]
})

// Search by workflow pattern
search_templates({searchMode: "by_task", task: "webhook_processing"})

// Search by complexity/time
search_templates({
  searchMode: "by_metadata",
  complexity: "simple",
  maxSetupMinutes: 15
})

// If MCP insufficient: Web search (load n8n-template-search skill)
WebFetch({
  url: "https://n8n.io/workflows/?search=slack",
  prompt: "Find Slack notification templates with descriptions"
})

Found suitable template?

  • ✅ YES → Deploy with n8n_deploy_template({templateId: XXX, autoFix: true})
  • ❌ NO → Continue to Step 1 (Node Discovery)

Step 1: Node Discovery (if no template fits)

javascript
// Search for nodes
search_nodes({query: "slack", includeExamples: true})

// Get node details
get_node({nodeType: "nodes-base.slack", detail: "standard"})

Step 3: Configuration & Validation

javascript
// Quick validation
validate_node({nodeType: "nodes-base.slack", config: {...}, mode: "minimal"})

// Full validation
validate_node({nodeType: "nodes-base.slack", config: {...}, profile: "runtime"})

Step 4: Build & Deploy

javascript
// Create workflow
n8n_create_workflow({name: "...", nodes: [...], connections: {...}})

// Or deploy template directly
n8n_deploy_template({templateId: 2947, autoFix: true})

Step 5: Validate Complete Workflow

javascript
validate_workflow(workflowJson)
n8n_validate_workflow({id: "workflow-id"})

⚠️ Critical Warnings

Never Trust Defaults

javascript
// ❌ FAILS at runtime - missing required params
{resource: "message", operation: "post", text: "Hello"}

// ✅ WORKS - all parameters explicit
{resource: "message", operation: "post", select: "channel", channelId: "C123", text: "Hello"}

IF Node Multi-Output Routing

javascript
// Use branch parameter for IF nodes
{
  type: "addConnection",
  source: "If Node",
  target: "True Handler",
  sourcePort: "main",
  targetPort: "main",
  branch: "true"  // ← CRITICAL!
}

addConnection Syntax

javascript
// ❌ WRONG - object format
{type: "addConnection", connection: {source: {...}}}

// ✅ CORRECT - four separate strings
{
  type: "addConnection",
  source: "node-id",
  target: "target-id", 
  sourcePort: "main",
  targetPort: "main"
}

🔗 Expression Syntax Quick Reference

javascript
// Access current item data
{{ $json.fieldName }}

// Access previous node
{{ $node["NodeName"].json.field }}

// Webhook data (CRITICAL: under .body)
{{ $json.body.fieldName }}

// Built-in variables
{{ $now }}      // Current datetime
{{ $env.KEY }}  // Environment variable
{{ $runIndex }} // Current run index

📊 Popular Nodes Reference

NodeTypePurpose
Webhookn8n-nodes-base.webhookHTTP trigger
HTTP Requestn8n-nodes-base.httpRequestAPI calls
Coden8n-nodes-base.codeJS/Python scripts
IFn8n-nodes-base.ifConditional routing
Setn8n-nodes-base.setData transformation
Slackn8n-nodes-base.slackSlack messaging
Gmailn8n-nodes-base.gmailEmail automation
Google Sheetsn8n-nodes-base.googleSheetsSpreadsheet ops
AI Agent@n8n/n8n-nodes-langchain.agentAI automation
OpenAI Chat@n8n/n8n-nodes-langchain.lmChatOpenAiChatGPT calls

🔍 When to Load Sub-Skills

Read the specific sub-skill when:

SituationLoad
Finding workflow templates/examplesn8n-template-search
Writing expressions with $jsonn8n-expression-syntax
Using MCP toolsn8n-mcp-tools-expert
Designing workflow architecturen8n-workflow-patterns
Validation errorsn8n-validation-expert
Configuring complex nodesn8n-node-configuration
Writing JavaScript in Code noden8n-code-javascript
Writing Python in Code noden8n-code-python

✅ Validation Checklist

Before deploying any workflow:

  • All nodes have unique IDs
  • All required parameters configured
  • Connections properly mapped
  • Expressions use correct syntax
  • Error handling implemented
  • validate_workflow passed
  • Tested in development first