n8n
Build, test, and deploy n8n workflows via REST API with incremental testing. Expert automation for n8n. USE THIS SKILL WHEN user says "create workflow", "build automation", "deploy to n8n", "activate workflow", needs to list, update, delete, or test workflows, mentions webhook execution, checking executions, debugging workflow runs, asks about n8n nodes, expressions, credentials, or Code nodes, needs JavaScript or Python code for n8n Code nodes, mentions expressions, $json, $input, or $node references, or asks about AI Agent, OpenAI, Anthropic, Google Sheets, Airtable, Slack, or other n8n nodes.
By- name:
- n8n
- description:
- Build, test, and deploy n8n workflows via REST API with incremental testing. Expert automation for n8n. USE THIS SKILL WHEN user says "create workflow", "build automation", "deploy to n8n", "activate workflow", needs to list, update, delete, or test workflows, mentions webhook execution, checking executions, debugging workflow runs, asks about n8n nodes, expressions, credentials, or Code nodes, needs JavaScript or Python code for n8n Code nodes, mentions expressions, $json, $input, or $node references, or asks about AI Agent, OpenAI, Anthropic, Google Sheets, Airtable, Slack, or other n8n nodes.
n8n Automation Skill
Build, test, and deploy n8n workflows via REST API with incremental testing.
When This Skill Loads (DO THIS IMMEDIATELY)
Step 1: Read Reference Files
Use the Read tool to read these files NOW:
1. Read references/pitfalls.md (critical command format rules)
2. Read references/build-process.md (step-by-step build workflow)
Step 2: Check .env Configuration
Read the .env file in the working directory to verify:
- N8N_API_URL is set
- N8N_API_KEY is set
- N8N_CREDENTIALS_TEMPLATE_URL is set
If any values are missing, ask the user for ALL of them in a single prompt.
Step 3: Create a Todo List
After understanding the user's request, create a todo list using TaskCreate.
SKILL LOADS -> READ FILES IMMEDIATELY -> CHECK .env -> THEN respond to user
Critical Rules
1. USE THE TOOLS THE USER SPECIFIES
If the user mentions specific tools, nodes, or services - YOU MUST USE THEM.
User says "use Apify" -> You use Apify node
User says "use OpenAI" -> You use OpenAI Chat Model
Never substitute, skip, or defer user-requested tools.
2. NEVER Simplify When Hitting Errors - FIX THE ISSUE
Loop node has error -> Debug why -> Fix the loop configuration
Don't switch to "simpler" approaches. Keep the correct architecture.
3. Only Use Nodes From Credentials Template
Never add nodes requiring authentication unless:
- The node exists in the user's credentials template, OR
- The user explicitly asks to use that specific tool/service
4. Only Use Node Types/Versions That Are INSTALLED
Always copy type AND typeVersion from the credentials template.
5. One Node at a Time
ADD NODE -> TEST -> ADD NEXT NODE -> TEST -> REPEAT
NEVER add 2+ nodes without testing between them.
6. NEVER Delete or Deactivate Workflows - UPDATE Instead
Node fails -> Debug the error -> Update the same workflow (PUT)
One workflow ID for the entire build process.
7. Use Native Nodes First
| Priority | Use When |
|---|---|
| 1. Native node | Built-in exists (Slack, Sheets, etc.) |
| 2. AI Agent node | For ANY AI/LLM task |
| 3. Loop node | For processing multiple items |
| 4. HTTP Request | Native has issues OR no node exists |
| 5. Code node | Complex logic only |
8. No Mock Data
Never use placeholder URLs, fake IDs, or "REPLACE_ME" values.
9. Test with 2 Items
Always set limit=2 on data-fetching nodes for fast testing.
10. Only Work With User-Specified Workflows
Never check, run, or modify workflows the user didn't mention.
Build Process
Step 0: Fetch Schema (If Database Involved)
1. Create temp workflow: Webhook + getSchema/getAll node
2. Execute to fetch actual field names
3. Use exact field names in main workflow
Step 1: Create Workflow with Trigger
1. Read references/triggers.md
2. Create workflow with trigger only
3. Test trigger
Step 2: Add Each Node
1. Read relevant reference file for this node type
2. Add ONE node to workflow
3. Test workflow
4. If ERROR -> fix -> retry
5. If SUCCESS -> move to next node
Step 3: Final Verification
1. All nodes added and tested
2. Workflow activated
3. Report success to user
API Methods Quick Reference
| Operation | Method | Endpoint |
|---|---|---|
| Create | POST | /api/v1/workflows |
| Update | PUT | /api/v1/workflows/{id} |
| Activate | POST | /api/v1/workflows/{id}/activate |
| Deactivate | POST | /api/v1/workflows/{id}/deactivate |
| Delete | DELETE | /api/v1/workflows/{id} |
| Execute | POST | /webhook/{path} |
API Call Format
CRITICAL RULES:
- NEVER write JSON files to disk - Always use API directly
- NEVER use
\line continuations - Causes errors - Always single-line commands - Or heredoc for large JSON
GET:
export $(cat .env | grep -v '^#' | xargs) && curl -s "${N8N_API_URL}/api/v1/ENDPOINT" -H "X-N8N-API-KEY: ${N8N_API_KEY}" | jq .
POST/PUT (large JSON):
export $(cat .env | grep -v '^#' | xargs) && curl -s -X POST "${N8N_API_URL}/api/v1/workflows" -H "X-N8N-API-KEY: ${N8N_API_KEY}" -H "Content-Type: application/json" -d "$(cat <<'EOF'
{
"name": "My Workflow",
"nodes": [...],
"connections": {},
"settings": {"executionOrder": "v1"}
}
EOF
)"
Workflow JSON Structure
{
"name": "Workflow Name",
"nodes": [
{
"id": "unique-node-id",
"name": "Node Display Name",
"type": "n8n-nodes-base.nodeName",
"typeVersion": 1,
"position": [250, 300],
"parameters": {},
"credentials": {}
}
],
"connections": {
"Source Node Name": {
"main": [[{"node": "Target Node Name", "type": "main", "index": 0}]]
}
},
"settings": {"executionOrder": "v1"}
}
Reference Files
Read these files as needed using the Read tool:
Core API & Build Process
| File | Contents |
|---|---|
| references/api-reference.md | All API commands (CRUD, executions, tags, variables) |
| references/build-process.md | Step-by-step build-test workflow |
| references/pitfalls.md | CRITICAL: Command format rules, common mistakes |
Node Reference
| File | Contents |
|---|---|
| references/triggers.md | Webhook, Schedule, Form, Chat, and service triggers |
| references/ai-nodes.md | AI Agent, OpenAI/Anthropic Chat Models, Memory, Vector Store |
| references/data-nodes.md | Google Sheets, Airtable, Notion, Postgres, Slack, Gmail, etc. |
| references/transform-nodes.md | Set, If, Switch, Filter, Merge, Code, HTTP Request, Loops |
Code & Expressions
| File | Contents |
|---|---|
| references/javascript.md | JavaScript patterns for Code nodes |
| references/python.md | Python patterns for Code nodes |
| references/node-config.md | Node configurations and workflow patterns |
| references/expressions.md | Expression syntax ({{ $json.field }}) |
| references/credentials.md | Credential template usage |
Node Selection Flow
Before adding ANY node:
1. Read the relevant reference file (triggers.md, ai-nodes.md, etc.)
2. Check if node is in credentials template
3. Get correct typeVersion and parameters
4. If DATABASE node -> FETCH SCHEMA first
5. Add node with correct config
Expression Quick Reference
// Webhook body (CRITICAL - data is under .body!)
{{ $json.body.fieldName }}
// Other node reference
{{ $('Node Name').item.json.field }}
// Default value
{{ $json.field ?? 'default' }}
// Safe access
{{ $json.obj?.nested?.field }}
// Current date
{{ $now.toFormat('yyyy-MM-dd') }}
In Code nodes, use plain JavaScript - NOT {{ }}:
const data = $input.first().json.body;
return [{ json: { result: data.fieldName } }];
Code Node Quick Reference
JavaScript
// Input access
const items = $input.all();
const first = $input.first().json;
// Other nodes
const data = $('Node Name').first().json;
// Return (MUST be array with json key)
return [{ json: { result: 'value' } }];
Python
# Input access
items = _input.all()
first = _input.first().json
# Return (MUST be list)
return [{"json": {"result": "value"}}]
Testing After Each Node
# 1. Activate
curl -X POST "${N8N_API_URL}/api/v1/workflows/{id}/activate"
# 2. Execute
curl -X POST "${N8N_API_URL}/webhook/{path}" -d '{}'
# 3. Check status
curl "${N8N_API_URL}/api/v1/executions?limit=1" | jq '.data[0].status'
# 4. Verify node ran
curl "${N8N_API_URL}/api/v1/executions/{id}?includeData=true" | jq '.data.resultData.runData | keys'
Do NOT proceed until status = "success" and new node appears in runData.
What to Report to User
After successful build:
Build Progress:
1. Webhook trigger - working
2. HTTP Request - working (2 results)
3. Google Sheets - working
- Workflow: My Workflow
- URL: https://n8n.example.com/workflow/abc123
- Status: Active
If manual config needed:
Workflow built and partially tested!
Google Sheets requires manual setup:
- Open workflow in n8n UI
- Select your spreadsheet
- Save
Open this reference as its own page
AI Nodes
LangChain-powered AI nodes for agents, chat models, embeddings, memory, and vector stores.
Contents
- AI Agent
- OpenAI Chat Model
- Anthropic Chat Model
- OpenAI Embeddings
- Simple Memory
- Simple Vector Store
- Connection Patterns
AI Agent
{
"id": "ai-agent-1",
"name": "AI Agent",
"type": "@n8n/n8n-nodes-langchain.agent",
"typeVersion": 3.1,
"position": [650, 300],
"parameters": {
"promptType": "define",
"text": "={{ $json.body.message }}",
"hasOutputParser": false,
"options": {
"systemMessage": "You are a helpful assistant. Answer questions concisely."
}
}
}
Prompt source options:
auto- Connected Chat Trigger Node (default)define- Define prompt manually
Important: The AI Agent requires a chat model connected via ai_languageModel input.
OpenAI Chat Model
{
"id": "openai-chat-1",
"name": "OpenAI Chat Model",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"typeVersion": 1.2,
"position": [450, 500],
"parameters": {
"model": {
"__rl": true,
"mode": "list",
"value": "gpt-4o",
"cachedResultName": "gpt-4o"
},
"options": {
"temperature": 0.7
}
},
"credentials": {
"openAiApi": {
"id": "cred-id",
"name": "OpenAI API"
}
}
}
Available models: gpt-4o, gpt-4o-mini, gpt-4-turbo, gpt-3.5-turbo, o1, o1-mini
Anthropic Chat Model
{
"id": "anthropic-chat-1",
"name": "Anthropic Chat Model",
"type": "@n8n/n8n-nodes-langchain.lmChatAnthropic",
"typeVersion": 1.3,
"position": [450, 500],
"parameters": {
"model": {
"__rl": true,
"mode": "id",
"value": "claude-sonnet-4-5-20250929"
},
"options": {
"temperature": 0.7
}
},
"credentials": {
"anthropicApi": {
"id": "cred-id",
"name": "Anthropic API"
}
}
}
Available models:
claude-sonnet-4-5-20250929- Claude 4.5 Sonnet (latest)claude-3-5-sonnet-20241022- Claude 3.5 Sonnetclaude-3-opus-20240229- Claude 3 Opusclaude-3-5-haiku-20241022- Claude 3.5 Haikuclaude-3-haiku-20240307- Claude 3 Haiku
OpenAI Embeddings
{
"id": "embeddings-1",
"name": "Embeddings OpenAI",
"type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
"typeVersion": 1.1,
"position": [450, 500],
"parameters": {
"model": "text-embedding-3-small",
"options": {}
},
"credentials": {
"openAiApi": {
"id": "cred-id",
"name": "OpenAI API"
}
}
}
Embedding models: text-embedding-3-small, text-embedding-3-large, text-embedding-ada-002
Simple Memory
Stores conversation history in n8n memory (no external setup required).
{
"id": "memory-1",
"name": "Simple Memory",
"type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
"typeVersion": 1.3,
"position": [450, 400],
"parameters": {
"sessionIdType": "fromInput",
"contextWindowLength": 5
}
}
With custom session key:
{
"parameters": {
"sessionIdType": "customKey",
"sessionKey": "={{ $json.userId }}",
"contextWindowLength": 10
}
}
Session ID options:
fromInput- From connected Chat Trigger (default)customKey- Define custom session key
Simple Vector Store
In-memory vector store for experimentation (no external setup required).
Insert documents:
{
"id": "vector-store-1",
"name": "Simple Vector Store",
"type": "@n8n/n8n-nodes-langchain.vectorStoreInMemory",
"typeVersion": 1.3,
"position": [650, 400],
"parameters": {
"mode": "insert",
"memoryKey": {
"__rl": true,
"mode": "id",
"value": "my_vector_store"
},
"clearStore": false
}
}
Retrieve as tool for AI Agent:
{
"parameters": {
"mode": "retrieve-as-tool",
"memoryKey": {
"__rl": true,
"mode": "id",
"value": "my_vector_store"
},
"toolDescription": "Search knowledge base for relevant documents"
}
}
Operation modes:
insert- Insert documents into storeload- Get many documents by promptretrieve- Retrieve as vector store for chainretrieve-as-tool- Retrieve as tool for AI Agent
Connection Patterns
AI Agent with Chat Model
{
"connections": {
"Webhook": {
"main": [[{ "node": "AI Agent", "type": "main", "index": 0 }]]
},
"OpenAI Chat Model": {
"ai_languageModel": [[{ "node": "AI Agent", "type": "ai_languageModel", "index": 0 }]]
}
}
}
AI Agent with Memory
{
"connections": {
"OpenAI Chat Model": {
"ai_languageModel": [[{ "node": "AI Agent", "type": "ai_languageModel", "index": 0 }]]
},
"Simple Memory": {
"ai_memory": [[{ "node": "AI Agent", "type": "ai_memory", "index": 0 }]]
}
}
}
AI Agent with Tools
{
"connections": {
"OpenAI Chat Model": {
"ai_languageModel": [[{ "node": "AI Agent", "type": "ai_languageModel", "index": 0 }]]
},
"Calculator": {
"ai_tool": [[{ "node": "AI Agent", "type": "ai_tool", "index": 0 }]]
},
"Simple Vector Store": {
"ai_tool": [[{ "node": "AI Agent", "type": "ai_tool", "index": 0 }]]
}
}
}
Note: AI connections use special types: ai_languageModel, ai_memory, ai_tool, ai_outputParser
Quick Reference: AI Node typeVersions
| Node | typeVersion |
|---|---|
| AI Agent | 3.1 |
| OpenAI Chat Model | 1.2 |
| Anthropic Chat Model | 1.3 |
| OpenAI Embeddings | 1.1 |
| Simple Memory | 1.3 |
| Simple Vector Store | 1.3 |
Open this reference as its own page
API Reference
Complete list of n8n REST API commands.
Contents
Workflows
List All Workflows
export $(cat .env | grep -v '^#' | xargs) && curl -s "${N8N_API_URL}/api/v1/workflows" -H "X-N8N-API-KEY: ${N8N_API_KEY}" | jq .
Get Workflow by ID
export $(cat .env | grep -v '^#' | xargs) && curl -s "${N8N_API_URL}/api/v1/workflows/{WORKFLOW_ID}" -H "X-N8N-API-KEY: ${N8N_API_KEY}" | jq .
Create Workflow
export $(cat .env | grep -v '^#' | xargs) && curl -s -X POST "${N8N_API_URL}/api/v1/workflows" -H "X-N8N-API-KEY: ${N8N_API_KEY}" -H "Content-Type: application/json" -d '{
"name": "My Workflow",
"nodes": [],
"connections": {},
"settings": {"executionOrder": "v1"}
}' | jq .
Update Workflow (PUT, not PATCH!)
export $(cat .env | grep -v '^#' | xargs) && curl -s -X PUT "${N8N_API_URL}/api/v1/workflows/{WORKFLOW_ID}" -H "X-N8N-API-KEY: ${N8N_API_KEY}" -H "Content-Type: application/json" -d '{
"name": "Updated Name",
"nodes": [],
"connections": {},
"settings": {"executionOrder": "v1"}
}' | jq .
Delete Workflow
export $(cat .env | grep -v '^#' | xargs) && curl -s -X DELETE "${N8N_API_URL}/api/v1/workflows/{WORKFLOW_ID}" -H "X-N8N-API-KEY: ${N8N_API_KEY}" | jq .
Activate Workflow
export $(cat .env | grep -v '^#' | xargs) && curl -s -X POST "${N8N_API_URL}/api/v1/workflows/{WORKFLOW_ID}/activate" -H "X-N8N-API-KEY: ${N8N_API_KEY}" | jq .
Deactivate Workflow
⚠️ WARNING: NEVER deactivate workflows during the build process. Just use PUT to update directly. Deactivation is only for when you intentionally want to stop a workflow from running.
export $(cat .env | grep -v '^#' | xargs) && curl -s -X POST "${N8N_API_URL}/api/v1/workflows/{WORKFLOW_ID}/deactivate" -H "X-N8N-API-KEY: ${N8N_API_KEY}" | jq .
Executions
List Executions (always use limit!)
export $(cat .env | grep -v '^#' | xargs) && curl -s "${N8N_API_URL}/api/v1/executions?limit=2" -H "X-N8N-API-KEY: ${N8N_API_KEY}" | jq .
Filter by Workflow
export $(cat .env | grep -v '^#' | xargs) && curl -s "${N8N_API_URL}/api/v1/executions?workflowId={WORKFLOW_ID}&limit=2" -H "X-N8N-API-KEY: ${N8N_API_KEY}" | jq .
Get Execution with Data
export $(cat .env | grep -v '^#' | xargs) && curl -s "${N8N_API_URL}/api/v1/executions/{EXECUTION_ID}?includeData=true" -H "X-N8N-API-KEY: ${N8N_API_KEY}" | jq .
Get Execution Status Only
export $(cat .env | grep -v '^#' | xargs) && curl -s "${N8N_API_URL}/api/v1/executions?limit=1" -H "X-N8N-API-KEY: ${N8N_API_KEY}" | jq '.data[0] | {id, status}'
Get Which Nodes Ran
export $(cat .env | grep -v '^#' | xargs) && curl -s "${N8N_API_URL}/api/v1/executions/{EXECUTION_ID}?includeData=true" -H "X-N8N-API-KEY: ${N8N_API_KEY}" | jq '.data.resultData.runData | keys'
Get Error Details
export $(cat .env | grep -v '^#' | xargs) && curl -s "${N8N_API_URL}/api/v1/executions/{EXECUTION_ID}?includeData=true" -H "X-N8N-API-KEY: ${N8N_API_KEY}" | jq '.data.resultData.error'
Tags
List Tags
export $(cat .env | grep -v '^#' | xargs) && curl -s "${N8N_API_URL}/api/v1/tags" -H "X-N8N-API-KEY: ${N8N_API_KEY}" | jq .
Create Tag
export $(cat .env | grep -v '^#' | xargs) && curl -s -X POST "${N8N_API_URL}/api/v1/tags" -H "X-N8N-API-KEY: ${N8N_API_KEY}" -H "Content-Type: application/json" -d '{"name": "production"}' | jq .
Variables
List Variables
export $(cat .env | grep -v '^#' | xargs) && curl -s "${N8N_API_URL}/api/v1/variables" -H "X-N8N-API-KEY: ${N8N_API_KEY}" | jq .
Create Variable
export $(cat .env | grep -v '^#' | xargs) && curl -s -X POST "${N8N_API_URL}/api/v1/variables" -H "X-N8N-API-KEY: ${N8N_API_KEY}" -H "Content-Type: application/json" -d '{"key": "MY_VAR", "value": "my-value"}' | jq .
Delete Variable
export $(cat .env | grep -v '^#' | xargs) && curl -s -X DELETE "${N8N_API_URL}/api/v1/variables/{VARIABLE_ID}" -H "X-N8N-API-KEY: ${N8N_API_KEY}" | jq .
Source Control
Pull from Remote
export $(cat .env | grep -v '^#' | xargs) && curl -s -X POST "${N8N_API_URL}/api/v1/source-control/pull" -H "X-N8N-API-KEY: ${N8N_API_KEY}" -H "Content-Type: application/json" -d '{"force": false}' | jq .
Push to Remote
export $(cat .env | grep -v '^#' | xargs) && curl -s -X POST "${N8N_API_URL}/api/v1/source-control/push" -H "X-N8N-API-KEY: ${N8N_API_KEY}" -H "Content-Type: application/json" -d '{"message": "Update workflows"}' | jq .
Webhook Execution
Execute via Production Webhook
Workflow must be ACTIVATED first.
export $(cat .env | grep -v '^#' | xargs) && curl -s -X POST "${N8N_API_URL}/webhook/{WEBHOOK_PATH}" -H "Content-Type: application/json" -d '{"key": "value"}' | jq .
Execute via Test Webhook
Workflow must be OPEN in n8n UI with "Listening for test events".
export $(cat .env | grep -v '^#' | xargs) && curl -s -X POST "${N8N_API_URL}/webhook-test/{WEBHOOK_PATH}" -H "Content-Type: application/json" -d '{"key": "value"}' | jq .
Webhook Node Configuration
ALWAYS use responseMode: "onReceived" (Respond Immediately) by default.
{
"id": "webhook-trigger",
"name": "Webhook",
"type": "n8n-nodes-base.webhook",
"typeVersion": 2,
"position": [250, 300],
"parameters": {
"path": "my-webhook-path",
"httpMethod": "POST",
"responseMode": "onReceived"
},
"webhookId": "unique-webhook-id"
}
Response modes:
onReceived- PREFERRED - Respond immediately, workflow runs in backgroundlastNode- Wait for workflow to completeresponseNode- Wait for Respond to Webhook node
Why onReceived is preferred:
- Caller doesn't wait for long-running workflows
- No timeout issues on complex workflows
- Workflow runs reliably in background
Open this reference as its own page
Build Process
Step-by-step workflow for building n8n workflows incrementally.
Contents
The Golden Rule
ADD ONE NODE → TEST → ADD ONE NODE → TEST → REPEAT
NEVER add 2 or more nodes at once. NEVER.
❌ ABSOLUTELY WRONG:
Add Webhook → Add Scraper → Add Transform → Add Sheets → Test → Error
(Which node failed? Nobody knows. Start over.)
✅ THE ONLY CORRECT WAY:
Add Webhook → Test ✓
Add Scraper → Test ✓
Add Transform → Test ✓
Add Sheets → Test ✓
Done!
Step-by-Step Process
Step 1: Create Workflow with Trigger Only
export $(cat .env | grep -v '^#' | xargs) && curl -s -X POST "${N8N_API_URL}/api/v1/workflows" -H "X-N8N-API-KEY: ${N8N_API_KEY}" -H "Content-Type: application/json" -d '{
"name": "My Workflow",
"nodes": [{
"id": "webhook-1",
"name": "Webhook",
"type": "n8n-nodes-base.webhook",
"typeVersion": 2,
"position": [250, 300],
"parameters": {"path": "my-workflow", "httpMethod": "POST"}
}],
"connections": {},
"settings": {"executionOrder": "v1"}
}' | jq '{id, name}'
Save the workflow ID - use it for ALL updates.
Step 2: Activate the Workflow
export $(cat .env | grep -v '^#' | xargs) && curl -s -X POST "${N8N_API_URL}/api/v1/workflows/{WORKFLOW_ID}/activate" -H "X-N8N-API-KEY: ${N8N_API_KEY}" | jq '{id, active}'
Step 3: Test the Trigger
export $(cat .env | grep -v '^#' | xargs) && curl -s -X POST "${N8N_API_URL}/webhook/{WEBHOOK_PATH}" -H "Content-Type: application/json" -d '{"test": "data"}'
Step 4: Verify Execution
export $(cat .env | grep -v '^#' | xargs) && curl -s "${N8N_API_URL}/api/v1/executions?limit=1" -H "X-N8N-API-KEY: ${N8N_API_KEY}" | jq '.data[0] | {id, status}'
STOP if status ≠ "success". Debug before continuing.
Step 5: Add Next Node (PUT to update)
export $(cat .env | grep -v '^#' | xargs) && curl -s -X PUT "${N8N_API_URL}/api/v1/workflows/{WORKFLOW_ID}" -H "X-N8N-API-KEY: ${N8N_API_KEY}" -H "Content-Type: application/json" -d '{
... existing nodes + new node + updated connections ...
}'
Step 6: Test Again
export $(cat .env | grep -v '^#' | xargs) && curl -s -X POST "${N8N_API_URL}/webhook/{WEBHOOK_PATH}" -H "Content-Type: application/json" -d '{"test": "data"}'
Step 7: Verify New Node Executed
export $(cat .env | grep -v '^#' | xargs) && curl -s "${N8N_API_URL}/api/v1/executions?limit=1" -H "X-N8N-API-KEY: ${N8N_API_KEY}" | jq '.data[0] | {id, status}'
Check which nodes ran:
export $(cat .env | grep -v '^#' | xargs) && curl -s "${N8N_API_URL}/api/v1/executions/{EXECUTION_ID}?includeData=true" -H "X-N8N-API-KEY: ${N8N_API_KEY}" | jq '.data.resultData.runData | keys'
STOP if status ≠ "success" or new node not in runData.
Step 8: Repeat Steps 5-7 for Each Node
NEVER skip the test step. NEVER add multiple nodes without testing.
Testing Requirements
Test with 2 Real Data Items
❌ WRONG: Limit search to 1 item (not enough to verify loops)
❌ WRONG: Use mock/placeholder data
❌ WRONG: Test with empty payload
✅ RIGHT: Set limit=2 or maxResults=2 (fast but verifies multiple items)
✅ RIGHT: Use real API endpoints
✅ RIGHT: Verify all 2 items flow through
When configuring data-fetching nodes:
- Apify/scraper nodes:
maxResults: 2 - HTTP Request to APIs:
?limit=2 - Database queries:
LIMIT 2 - Search nodes: Set limit to 2
One Workflow, Keep Updating
- Create workflow ONCE with POST → get workflow ID
- All changes use PUT to the SAME workflow ID
- Never create new workflow to test or fix
Example Build
✓ Step 1: Create workflow with Webhook
✓ Step 2: Activate
✓ Step 3: Test → Execute webhook
✓ Step 4: Verify → status: success, runData: ["Webhook"]
✓ Step 5: Add Apify Scraper node (PUT)
✓ Step 6: Test → Execute webhook
✓ Step 7: Verify → status: success, runData: ["Webhook", "Apify Scraper"]
✓ Step 5: Add Transform node (PUT)
✓ Step 6: Test → Execute webhook
✓ Step 7: Verify → status: success, runData: ["Webhook", "Apify Scraper", "Transform"]
✓ Step 5: Add Google Sheets node (PUT)
✓ Step 6: Test → Execute webhook
✓ Step 7: Verify → status: success, runData: ["Webhook", "Apify Scraper", "Transform", "Google Sheets"]
✓ Final: All nodes tested and working → Report to user
WRONG vs RIGHT
WRONG:
Add Webhook → Add Scraper → Add AI → Add Sheets → Test → Error → ???
RIGHT:
Add Webhook → Test ✓ → Add Scraper → Test ✓ → Add AI → Test ✓ → Add Sheets → Test ✓ → Done
Open this reference as its own page
n8n Credentials Reference
Extract and use node configurations from a credentials template workflow.
What is a Credentials Template?
A Credentials Template is a workflow you create in n8n that contains nodes with all your configured credentials AND working parameters. This allows the skill to:
- Fetch the template workflow
- Extract full node configurations (credentials + parameters + typeVersion)
- Apply those configurations to new workflows
Configuration
Required .env variables:
N8N_API_URL=https://your-n8n.app.n8n.cloud
N8N_API_KEY=your-api-key
N8N_CREDENTIALS_TEMPLATE_URL=https://your-n8n.app.n8n.cloud/workflow/abc123
Template Workflow Structure
Create a workflow in n8n with nodes for each service you use:
[Slack Node] -> [Google Sheets Node] -> [HTTP Request Node] -> [OpenAI Node]
| | | |
Slack API Google OAuth2 API Key Auth OpenAI API
Each node should have:
- Credentials configured
- Parameters set to common/default values you use
- The template doesn't need to be active
Fetching Node Configurations
Get all configured nodes
export $(cat .env | grep -v '^#' | xargs) && curl -s "${N8N_API_URL}/api/v1/workflows/{WORKFLOW_ID}" -H "X-N8N-API-KEY: ${N8N_API_KEY}" | jq '.nodes[] | select(.credentials)'
Get specific node type
export $(cat .env | grep -v '^#' | xargs) && curl -s "${N8N_API_URL}/api/v1/workflows/{WORKFLOW_ID}" -H "X-N8N-API-KEY: ${N8N_API_KEY}" | jq '.nodes[] | select(.type | contains("slack"))'
Get node config for reuse
export $(cat .env | grep -v '^#' | xargs) && curl -s "${N8N_API_URL}/api/v1/workflows/{WORKFLOW_ID}" -H "X-N8N-API-KEY: ${N8N_API_KEY}" | jq '.nodes[] | select(.type == "n8n-nodes-base.slack") | {type, typeVersion, parameters, credentials}'
CRITICAL: Copy Full Configuration
IMPORTANT: When using template nodes, copy the ENTIRE node configuration, not just credentials:
| What to Copy | Why |
|---|---|
credentials |
Authentication for the service |
parameters |
All settings (resource, operation, options, etc.) |
typeVersion |
Ensures compatibility with your n8n version |
Example: Using Template Configuration
Template returns:
{
"type": "n8n-nodes-base.slack",
"typeVersion": 2.2,
"parameters": {
"resource": "message",
"operation": "post",
"channel": {
"__rl": true,
"mode": "name",
"value": "#general"
},
"text": "Hello!"
},
"credentials": {
"slackApi": {
"id": "abc123",
"name": "Slack Production"
}
}
}
New node using template:
{
"id": "new-unique-id",
"name": "Send Notification",
"type": "n8n-nodes-base.slack",
"typeVersion": 2.2,
"position": [450, 300],
"parameters": {
"resource": "message",
"operation": "post",
"channel": {
"__rl": true,
"mode": "name",
"value": "#alerts"
},
"text": "={{ $json.message }}"
},
"credentials": {
"slackApi": {
"id": "abc123",
"name": "Slack Production"
}
}
}
Credential Types Reference
Common credential type names used in n8n:
| Service | Credential Type |
|---|---|
| Slack | slackApi, slackOAuth2Api |
| Google Sheets | googleSheetsOAuth2Api |
| Gmail | gmailOAuth2 |
| OpenAI | openAiApi |
| HTTP Request | httpHeaderAuth, httpBasicAuth, httpQueryAuth |
| PostgreSQL | postgres |
| MySQL | mySql |
| Airtable | airtableTokenApi |
| Notion | notionApi |
| GitHub | githubApi, githubOAuth2Api |
| Stripe | stripeApi |
| Twilio | twilioApi |
| SendGrid | sendGridApi |
| AWS | aws |
| Apify | apifyApi |
| Anthropic | anthropicApi |
Common Pitfalls
1. Copying only credentials, not parameters
- Wrong: Just copy
credentialsand guess atparameters - Right: Copy full node config including
parametersandtypeVersion
2. Using wrong typeVersion
- Wrong: Hardcode
typeVersion: 1 - Right: Use the exact
typeVersionfrom the template node
3. Missing parameter structure
- Wrong:
"channel": "#general"(simple string) - Right: Copy the exact structure from template (may need
__rl,mode, etc.)
4. Not checking if node exists in template
- Wrong: Assume all node types exist in template
- Right: First list available nodes, inform user if requested type is missing
Error Handling
Template Not Found
Error: Could not fetch credentials template.
Check that:
1. N8N_CREDENTIALS_TEMPLATE_URL in .env is correct
2. The workflow exists and hasn't been deleted
3. Your API key has access to this workflow
Node Type Not in Template
Note: No node found in template for type: n8n-nodes-base.{type}
Options:
1. Add a {type} node with credentials to your template workflow
2. Ask user if they want to proceed without template config
3. Manually configure the node (may require UI setup for some nodes)
Open this reference as its own page
Data & Communication Nodes
Nodes for storing data, databases, and sending messages.
Contents
Auto-Create Tables
Google Sheets can create new spreadsheets/sheets via API.
Airtable CANNOT create tables via n8n. User must create tables manually in Airtable UI first.
When the user requests a workflow that saves to a spreadsheet:
- Use the "create" operations first (Google Sheets only)
- Then proceed with append/update operations
Google Sheets
Create new spreadsheet:
{
"id": "sheets-create-1",
"name": "Create Spreadsheet",
"type": "n8n-nodes-base.googleSheets",
"typeVersion": 4.5,
"position": [450, 300],
"parameters": {
"operation": "create",
"title": "={{ $json.spreadsheetName ?? 'New Spreadsheet' }}",
"sheetName": "Sheet1",
"options": {}
},
"credentials": {
"googleSheetsOAuth2Api": {
"id": "cred-id",
"name": "Google Sheets OAuth2"
}
}
}
Create new sheet (tab) in existing spreadsheet:
{
"parameters": {
"resource": "sheet",
"operation": "create",
"documentId": {
"__rl": true,
"mode": "id",
"value": "existing-spreadsheet-id"
},
"title": "New Sheet Tab",
"options": {}
}
}
Append rows:
{
"id": "sheets-1",
"name": "Google Sheets",
"type": "n8n-nodes-base.googleSheets",
"typeVersion": 4.5,
"position": [850, 300],
"parameters": {
"operation": "append",
"documentId": {
"__rl": true,
"mode": "id",
"value": "1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms"
},
"sheetName": {
"__rl": true,
"mode": "name",
"value": "Sheet1"
},
"columns": {
"mappingMode": "autoMapInputData",
"value": {}
},
"options": {}
},
"credentials": {
"googleSheetsOAuth2Api": {
"id": "cred-id",
"name": "Google Sheets OAuth2"
}
}
}
Update rows:
{
"parameters": {
"operation": "update",
"documentId": {
"__rl": true,
"mode": "id",
"value": "SPREADSHEET_ID"
},
"sheetName": {
"__rl": true,
"mode": "name",
"value": "Sheet1"
},
"columns": {
"mappingMode": "defineBelow",
"value": {
"id": "={{ $json.id }}",
"status": "={{ $json.status }}"
},
"matchingColumns": ["id"]
}
}
}
Airtable
CRITICAL: Required Parameters (COPY EXACTLY)
Every Airtable node MUST have these parameters or it will fail:
{
"parameters": {
"authentication": "airtableOAuth2Api", // REQUIRED - without this, defaults to wrong auth type
"resource": "base", // REQUIRED for getSchema - without this, WorkflowHasIssuesError
"operation": "getSchema",
"base": {...}
},
"credentials": {
"airtableOAuth2Api": {...} // MUST match authentication parameter
}
}
Common errors from missing parameters:
- Missing
authentication→ "Node does not have any credentials set for airtableTokenApi" - Missing
resource→ "WorkflowHasIssuesError: The workflow has issues"
Airtable Resources and Operations
n8n Airtable v2 node only has TWO resources:
base→getMany,getSchemaoperationsrecord→create,delete,get,search,update,upsertoperations
There is NO table resource. You CANNOT create tables via n8n.
User must create tables manually in Airtable UI.
CRITICAL: Field Names Must Match EXACTLY
Field names are case-sensitive and space-sensitive:
❌ WRONG: "GoogleMapsURL" → Error: Unknown field name
✅ RIGHT: "Google Maps URL" → Works (matches Airtable field)
❌ WRONG: "FitScore" → Error: Unknown field name
✅ RIGHT: "Fit Score" → Works (matches Airtable field)
ALWAYS use getSchema first to get exact field names before creating records.
CRITICAL: Parameter Names
Use base and table, NOT baseId and tableId:
❌ WRONG: "baseId", "tableId" → Error: WorkflowHasIssuesError
✅ RIGHT: "base", "table" → Works
Step 1: Get Schema (ALWAYS DO THIS FIRST)
Before writing records, fetch the exact field names:
{
"id": "airtable-schema-1",
"name": "Get Base Schema",
"type": "n8n-nodes-base.airtable",
"typeVersion": 2.1,
"position": [450, 300],
"parameters": {
"authentication": "airtableOAuth2Api",
"resource": "base",
"operation": "getSchema",
"base": {
"__rl": true,
"value": "appXXXXXXXXXXXXXX",
"mode": "list",
"cachedResultName": "My Base Name",
"cachedResultUrl": "https://airtable.com/appXXXXXXXXXXXXXX"
}
},
"credentials": {
"airtableOAuth2Api": {
"id": "cred-id",
"name": "Airtable OAuth2"
}
}
}
Note: The cachedResultName and cachedResultUrl are optional UI hints. You can also use "mode": "id" if you only have the base ID.
This returns all tables and their exact field names.
Step 2: Create Record (use exact field names from schema)
{
"id": "airtable-1",
"name": "Airtable",
"type": "n8n-nodes-base.airtable",
"typeVersion": 2.1,
"position": [650, 300],
"parameters": {
"authentication": "airtableOAuth2Api",
"operation": "create",
"base": {
"__rl": true,
"value": "appXXXXXXXXXXXXXX",
"mode": "list",
"cachedResultName": "My Base Name",
"cachedResultUrl": "https://airtable.com/appXXXXXXXXXXXXXX"
},
"table": {
"__rl": true,
"value": "tblXXXXXXXXXXXXXX",
"mode": "list",
"cachedResultName": "My Table Name",
"cachedResultUrl": "https://airtable.com/appXXXXXXXXXXXXXX/tblXXXXXXXXXXXXXX"
},
"columns": {
"mappingMode": "defineBelow",
"value": {
"Name": "={{ $json.name }}",
"Email": "={{ $json.email }}",
"Status": "Active"
}
},
"options": {}
},
"credentials": {
"airtableOAuth2Api": {
"id": "cred-id",
"name": "Airtable OAuth2"
}
}
}
Airtable Workflow Pattern
1. User provides base ID and table ID
2. FIRST: Add getSchema node → test → get exact field names
3. THEN: Add record create node using exact field names from schema
4. Test with real data
Other Operations
Search records:
{
"parameters": {
"authentication": "airtableOAuth2Api",
"operation": "search",
"base": {"__rl": true, "value": "appXXX", "mode": "list"},
"table": {"__rl": true, "value": "tblXXX", "mode": "list"},
"filterByFormula": "={Status}='Active'",
"options": {"limit": 10}
}
}
Update record:
{
"parameters": {
"authentication": "airtableOAuth2Api",
"operation": "update",
"base": {"__rl": true, "value": "appXXX", "mode": "list"},
"table": {"__rl": true, "value": "tblXXX", "mode": "list"},
"id": "={{ $json.recordId }}",
"columns": {
"mappingMode": "defineBelow",
"value": {
"Status": "Completed"
}
}
}
}
Operations: create, delete, get, search, update, upsert
Notion
Create page:
{
"id": "notion-1",
"name": "Notion",
"type": "n8n-nodes-base.notion",
"typeVersion": 2.2,
"position": [650, 300],
"parameters": {
"resource": "page",
"operation": "create",
"databaseId": {
"__rl": true,
"mode": "id",
"value": "database-id-here"
},
"propertiesUi": {
"propertyValues": [
{
"key": "Name",
"title": "={{ $json.title }}"
},
{
"key": "Status",
"select": "In Progress"
}
]
}
},
"credentials": {
"notionApi": {
"id": "cred-id",
"name": "Notion API"
}
}
}
Postgres
Execute query:
{
"id": "postgres-1",
"name": "Postgres",
"type": "n8n-nodes-base.postgres",
"typeVersion": 2.6,
"position": [650, 300],
"parameters": {
"operation": "executeQuery",
"query": "SELECT * FROM users WHERE status = $1 LIMIT 10",
"options": {
"queryParameters": "active"
}
},
"credentials": {
"postgres": {
"id": "cred-id",
"name": "Postgres"
}
}
}
Insert rows:
{
"parameters": {
"operation": "insert",
"table": {
"__rl": true,
"mode": "list",
"value": "users"
},
"columns": {
"mappingMode": "autoMapInputData",
"value": {}
},
"options": {}
}
}
Update rows:
{
"parameters": {
"operation": "update",
"table": {
"__rl": true,
"mode": "list",
"value": "users"
},
"columns": {
"mappingMode": "defineBelow",
"value": {
"status": "={{ $json.status }}",
"updated_at": "={{ $now.toISO() }}"
},
"matchingColumns": ["id"]
}
}
}
Upsert (Insert or Update):
{
"parameters": {
"operation": "upsert",
"table": {
"__rl": true,
"mode": "list",
"value": "users"
},
"columns": {
"mappingMode": "autoMapInputData",
"value": {},
"matchingColumns": ["email"]
}
}
}
Operations: executeQuery, insert, update, upsert, select, deleteTable
MySQL
Execute query:
{
"id": "mysql-1",
"name": "MySQL",
"type": "n8n-nodes-base.mySql",
"typeVersion": 2.5,
"position": [650, 300],
"parameters": {
"operation": "executeQuery",
"query": "SELECT * FROM products WHERE category = ? LIMIT 10",
"options": {
"queryParameters": "electronics"
}
},
"credentials": {
"mySql": {
"id": "cred-id",
"name": "MySQL"
}
}
}
Insert rows:
{
"parameters": {
"operation": "insert",
"table": {
"__rl": true,
"mode": "list",
"value": "orders"
},
"columns": {
"mappingMode": "autoMapInputData",
"value": {}
},
"options": {}
}
}
Operations: executeQuery, insert, update, upsert, select, deleteTable
Slack
Send message:
{
"id": "slack-1",
"name": "Slack",
"type": "n8n-nodes-base.slack",
"typeVersion": 2.2,
"position": [650, 300],
"parameters": {
"resource": "message",
"operation": "post",
"channel": {
"__rl": true,
"mode": "name",
"value": "#general"
},
"text": "={{ $json.message }}",
"otherOptions": {}
},
"credentials": {
"slackApi": {
"id": "cred-id",
"name": "Slack API"
}
}
}
Gmail
Send email:
{
"id": "gmail-1",
"name": "Gmail",
"type": "n8n-nodes-base.gmail",
"typeVersion": 2.1,
"position": [650, 300],
"parameters": {
"operation": "send",
"sendTo": "={{ $json.email }}",
"subject": "={{ $json.subject }}",
"message": "={{ $json.body }}",
"options": {}
},
"credentials": {
"gmailOAuth2": {
"id": "cred-id",
"name": "Gmail OAuth2"
}
}
}
Send and wait for approval:
{
"parameters": {
"operation": "sendAndWait",
"sendTo": "approver@example.com",
"subject": "Approval Required: {{ $json.title }}",
"message": "={{ $json.details }}",
"approvalOptions": {
"values": {
"approvalType": "double"
}
},
"options": {
"limitWaitTime": {
"values": {
"resumeUnit": "minutes",
"resumeAmount": 60
}
}
}
}
}
Telegram
Send message:
{
"id": "telegram-1",
"name": "Telegram",
"type": "n8n-nodes-base.telegram",
"typeVersion": 1.2,
"position": [650, 300],
"parameters": {
"resource": "message",
"operation": "sendMessage",
"chatId": "={{ $json.chatId }}",
"text": "={{ $json.message }}",
"additionalFields": {}
},
"credentials": {
"telegramApi": {
"id": "cred-id",
"name": "Telegram API"
}
}
}
Send photo:
{
"parameters": {
"resource": "message",
"operation": "sendPhoto",
"chatId": "={{ $json.chatId }}",
"file": "={{ $json.imageUrl }}",
"additionalFields": {
"caption": "={{ $json.caption }}"
}
}
}
Send document:
{
"parameters": {
"resource": "message",
"operation": "sendDocument",
"chatId": "={{ $json.chatId }}",
"file": "={{ $json.fileUrl }}",
"additionalFields": {}
}
}
Resources: chat, callback, file, message
Message operations: sendMessage, sendPhoto, sendDocument, sendVideo, sendAudio, sendAnimation, sendSticker, sendLocation, sendMediaGroup, deleteMessage, pinChatMessage, unpinChatMessage
Discord
Send message:
{
"id": "discord-1",
"name": "Discord",
"type": "n8n-nodes-base.discord",
"typeVersion": 2,
"position": [650, 300],
"parameters": {
"authentication": "botToken",
"resource": "message",
"operation": "send",
"guildId": {
"__rl": true,
"mode": "list",
"value": "SERVER_ID"
},
"channelId": {
"__rl": true,
"mode": "list",
"value": "CHANNEL_ID"
},
"content": "={{ $json.message }}"
},
"credentials": {
"discordBotApi": {
"id": "cred-id",
"name": "Discord Bot"
}
}
}
Send via webhook (no bot required):
{
"parameters": {
"authentication": "webhook",
"content": "={{ $json.message }}",
"options": {
"username": "Notification Bot",
"avatarUrl": "https://example.com/avatar.png"
}
},
"credentials": {
"discordWebhookApi": {
"id": "cred-id",
"name": "Discord Webhook"
}
}
}
Connection types:
botToken- Bot Token (full API access)oAuth2- OAuth2 (user-level access)webhook- Webhook (simple message sending)
Operations: send, get, getAll, deleteMessage, react
Quick Reference: Data Node typeVersions
| Node | typeVersion |
|---|---|
| Google Sheets | 4.5 |
| Airtable | 2.1 |
| Notion | 2.2 |
| Postgres | 2.6 |
| MySQL | 2.5 |
| Slack | 2.2 |
| Gmail | 2.1 |
| Telegram | 1.2 |
| Discord | 2 |
Open this reference as its own page
n8n Expressions Reference
Master n8n's expression language for dynamic data access and transformation.
The Fundamental Rule
All dynamic content requires double curly braces:
{{ expression }}
Without braces = static text. With braces = evaluated expression.
Core Variables
| Variable | Purpose | Example |
|---|---|---|
$json |
Current node's input data | {{ $json.name }} |
$node |
Reference other nodes | {{ $node["Node Name"].json.field }} |
$input |
Input items (Code nodes) | $input.all() |
$now |
Current timestamp | {{ $now.toISO() }} |
$env |
Environment variables | {{ $env.API_KEY }} |
$execution |
Execution metadata | {{ $execution.id }} |
$workflow |
Workflow metadata | {{ $workflow.name }} |
CRITICAL: Webhook Data Location
This is the #1 mistake. Webhook data is NOT at $json root!
User-submitted data from webhooks lives under .body:
// WRONG - will be undefined
{{ $json.name }}
{{ $json.email }}
// CORRECT - webhook data is under .body
{{ $json.body.name }}
{{ $json.body.email }}
Webhook Data Structure
{
"headers": { "content-type": "application/json", ... },
"params": { },
"query": { "id": "123" },
"body": {
"name": "John",
"email": "john@example.com"
}
}
Access patterns:
- Body data:
{{ $json.body.fieldName }} - Query params:
{{ $json.query.paramName }} - Headers:
{{ $json.headers["header-name"] }}
Cross-Node References
Method 1: $node syntax
{{ $node["HTTP Request"].json.data }}
{{ $node["Get User"].json.user.id }}
Method 2: $() function (recommended)
{{ $('HTTP Request').item.json.data }}
{{ $('Get User').first().json.user.id }}
Important: Node names are case-sensitive and must match exactly!
Field Access Patterns
Simple field
{{ $json.fieldName }}
Nested field
{{ $json.user.address.city }}
Array element
{{ $json.items[0].name }}
{{ $json.results[0] }}
Field with spaces (bracket notation)
{{ $json["field name"] }}
{{ $json.user["first name"] }}
Dynamic field access
{{ $json[$json.fieldKey] }}
Conditional Expressions
Ternary operator
{{ $json.status === 'active' ? 'Yes' : 'No' }}
{{ $json.score > 80 ? 'Pass' : 'Fail' }}
Nullish coalescing (default values)
{{ $json.name ?? 'Unknown' }}
{{ $json.count ?? 0 }}
Optional chaining (safe access)
{{ $json.user?.address?.city ?? 'N/A' }}
{{ $json.items?.[0]?.name }}
String Operations
// Concatenation
{{ $json.firstName + ' ' + $json.lastName }}
{{ 'Hello, ' + $json.name + '!' }}
// Case conversion
{{ $json.name.toUpperCase() }}
{{ $json.name.toLowerCase() }}
// Trimming
{{ $json.input.trim() }}
// Substring
{{ $json.text.substring(0, 100) }}
// Replace
{{ $json.text.replace('old', 'new') }}
{{ $json.text.replaceAll('-', '_') }}
// Split
{{ $json.csv.split(',') }}
// Check contains
{{ $json.text.includes('keyword') }}
Number Operations
// Basic math
{{ $json.price * $json.quantity }}
{{ $json.total / 100 }}
{{ $json.value + 10 }}
// Rounding
{{ Math.round($json.value) }}
{{ Math.floor($json.value) }}
{{ Math.ceil($json.value) }}
// Formatting
{{ $json.price.toFixed(2) }}
// Parse string to number
{{ parseInt($json.stringNum) }}
{{ parseFloat($json.decimalString) }}
Array Operations
// Length
{{ $json.items.length }}
// First/Last
{{ $json.items[0] }}
{{ $json.items[$json.items.length - 1] }}
// Map (transform)
{{ $json.users.map(u => u.name) }}
// Filter
{{ $json.items.filter(i => i.active) }}
// Find
{{ $json.users.find(u => u.id === 123) }}
// Join
{{ $json.tags.join(', ') }}
// Includes
{{ $json.roles.includes('admin') }}
Date/Time with Luxon
n8n uses Luxon's DateTime. $now is a DateTime object.
// Current time
{{ $now }}
{{ $now.toISO() }}
{{ $now.toFormat('yyyy-MM-dd') }}
// Formatting
{{ $now.toFormat('dd/MM/yyyy HH:mm') }}
{{ $now.toFormat('MMMM d, yyyy') }}
// Add/Subtract time
{{ $now.plus({ days: 7 }).toISO() }}
{{ $now.minus({ hours: 2 }).toISO() }}
// Parse date string
{{ DateTime.fromISO($json.dateString) }}
{{ DateTime.fromFormat($json.date, 'dd/MM/yyyy') }}
// Compare dates
{{ DateTime.fromISO($json.date) > $now }}
// Get parts
{{ $now.year }}
{{ $now.month }}
{{ $now.day }}
{{ $now.hour }}
{{ $now.weekday }}
Where NOT to Use Expressions
Do NOT use {{ }} in these contexts:
- Code node JavaScript - Use plain JS variables
- Webhook path field - Static text only
- Credential fields - Use n8n's credential system
- Node names - Static identifiers
Debugging Expressions
Test in Set node
Create a Set node to test expressions before using in complex nodes.
Check for undefined
{{ $json.field ?? 'FIELD_IS_UNDEFINED' }}
Log structure
Use Code node to inspect:
console.log(JSON.stringify($input.first().json, null, 2));
return $input.all();
Common error messages
| Error | Cause | Fix |
|---|---|---|
| "Cannot read property 'x' of undefined" | Parent object doesn't exist | Use optional chaining: $json.parent?.x |
| "x is not a function" | Calling method on wrong type | Check data type first |
| "Unexpected token" | Syntax error in expression | Check brackets and quotes |
Quick Reference
// Webhook body
{{ $json.body.fieldName }}
// Other node
{{ $('Node Name').item.json.field }}
// Default value
{{ $json.field ?? 'default' }}
// Safe access
{{ $json.obj?.nested?.field }}
// Conditional
{{ $json.x ? 'yes' : 'no' }}
// Format date
{{ $now.toFormat('yyyy-MM-dd') }}
// Array first item
{{ $json.items[0] }}
Open this reference as its own page
JavaScript in Code Nodes
Complete reference for JavaScript code in n8n Code nodes.
Contents
- Accessing Input Data
- Returning Data
- Working with All Items
- Filtering Items
- Aggregating Data
- Accessing Other Nodes
- Environment Variables
- Making HTTP Requests
- Working with Dates
- Error Handling
- Common Patterns
- Common Mistakes
- Debugging
Accessing Input Data
// Get all input items
const items = $input.all();
// Get first item
const firstItem = $input.first();
// Get item data
const data = $input.first().json;
const name = $input.first().json.name;
// Get specific field from first item
const email = $input.first().json.body.email;
Returning Data
Every Code node MUST return an array of items.
// Return single item
return [{ json: { result: 'success' } }];
// Return multiple items
return [
{ json: { id: 1, name: 'First' } },
{ json: { id: 2, name: 'Second' } }
];
// Transform and return all items
return $input.all().map(item => ({
json: {
...item.json,
processed: true,
timestamp: new Date().toISOString()
}
}));
Working with All Items
// Process each item
const results = [];
for (const item of $input.all()) {
results.push({
json: {
original: item.json.name,
uppercase: item.json.name.toUpperCase()
}
});
}
return results;
// Using map (cleaner)
return $input.all().map(item => ({
json: {
original: item.json.name,
uppercase: item.json.name.toUpperCase()
}
}));
Filtering Items
// Filter items
return $input.all().filter(item => item.json.status === 'active');
// Filter and transform
return $input.all()
.filter(item => item.json.score > 80)
.map(item => ({
json: {
name: item.json.name,
passed: true
}
}));
Aggregating Data
// Sum values
const total = $input.all().reduce((sum, item) => sum + item.json.amount, 0);
return [{ json: { total } }];
// Group by field
const grouped = {};
for (const item of $input.all()) {
const key = item.json.category;
if (!grouped[key]) grouped[key] = [];
grouped[key].push(item.json);
}
return [{ json: grouped }];
// Count items
const count = $input.all().length;
return [{ json: { count } }];
Accessing Other Nodes
// Get data from specific node
const httpData = $('HTTP Request').first().json;
const allHttpItems = $('HTTP Request').all();
// Get data from previous node
const prevData = $input.first().json;
// Check if node has data
if ($('HTTP Request').all().length > 0) {
// Node has output
}
Environment Variables
// Access environment variables
const apiKey = $env.API_KEY;
const baseUrl = $env.BASE_URL;
// Use in API calls
const response = await fetch(`${$env.API_URL}/endpoint`, {
headers: { 'Authorization': `Bearer ${$env.API_KEY}` }
});
Making HTTP Requests
// GET request
const response = await fetch('https://api.example.com/data');
const data = await response.json();
return [{ json: data }];
// POST request
const response = await fetch('https://api.example.com/users', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ name: 'John', email: 'john@example.com' })
});
const result = await response.json();
return [{ json: result }];
// With error handling
try {
const response = await fetch('https://api.example.com/data');
if (!response.ok) {
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
}
const data = await response.json();
return [{ json: { success: true, data } }];
} catch (error) {
return [{ json: { success: false, error: error.message } }];
}
Working with Dates
// Current date
const now = new Date();
const isoString = now.toISOString();
// Using Luxon (available in n8n)
const { DateTime } = require('luxon');
const today = DateTime.now().toFormat('yyyy-MM-dd');
const nextWeek = DateTime.now().plus({ days: 7 }).toISO();
// Parse date string
const parsed = DateTime.fromISO($input.first().json.dateString);
const formatted = parsed.toFormat('dd/MM/yyyy');
return [{ json: { today, nextWeek, formatted } }];
Error Handling
// Try-catch pattern
try {
const data = $input.first().json;
if (!data.required_field) {
throw new Error('Missing required_field');
}
// Process data
return [{ json: { success: true, result: data.required_field } }];
} catch (error) {
// Return error info instead of failing
return [{ json: { success: false, error: error.message } }];
}
// Validate input
const item = $input.first().json;
if (!item.email || !item.email.includes('@')) {
throw new Error('Invalid email address');
}
Common Patterns
// Deduplicate array
const unique = [...new Set($input.all().map(i => i.json.email))];
return unique.map(email => ({ json: { email } }));
// Flatten nested arrays
const nested = $input.first().json.items; // [[1,2], [3,4]]
const flat = nested.flat();
return [{ json: { flat } }];
// Sort items
const sorted = $input.all().sort((a, b) =>
a.json.name.localeCompare(b.json.name)
);
return sorted;
// Merge objects
const merged = Object.assign({},
$('Node1').first().json,
$('Node2').first().json
);
return [{ json: merged }];
// Safe property access
const city = $input.first().json?.user?.address?.city ?? 'Unknown';
return [{ json: { city } }];
Common Mistakes
Mistake 1: Not Returning Array
// WRONG - returns single object
return { json: { result: 'done' } };
// CORRECT - returns array of items
return [{ json: { result: 'done' } }];
Mistake 2: Missing json Wrapper
// WRONG - missing json property
return [{ name: 'John' }];
// CORRECT - wrapped in json
return [{ json: { name: 'John' } }];
Mistake 3: Using Expression Syntax
// WRONG - expression syntax
const data = {{ $json.body }};
// CORRECT - Code node syntax
const data = $input.first().json.body;
Mistake 4: Forgetting Async/Await
// WRONG - fetch returns Promise
const response = fetch('https://api.example.com');
const data = response.json(); // Error!
// CORRECT - await the Promise
const response = await fetch('https://api.example.com');
const data = await response.json();
return [{ json: data }];
Mistake 5: Not Handling Empty Input
// WRONG - crashes if no input
const name = $input.first().json.name;
// CORRECT - check first
const items = $input.all();
if (items.length === 0) {
return [{ json: { error: 'No input data' } }];
}
const name = items[0].json.name;
Mistake 6: Modifying Input Directly
// WRONG - modifies original
const item = $input.first();
item.json.newField = 'value';
return [item];
// CORRECT - create new object
const item = $input.first();
return [{
json: {
...item.json,
newField: 'value'
}
}];
Debugging
Console Logging
// Log to execution output
console.log('Input data:', JSON.stringify($input.first().json, null, 2));
// Log all items
console.log('Item count:', $input.all().length);
for (const item of $input.all()) {
console.log('Item:', item.json);
}
// Always return something
return $input.all();
Inspect Data Structure
// Return input structure for debugging
return [{
json: {
itemCount: $input.all().length,
firstItem: $input.first()?.json,
allKeys: Object.keys($input.first()?.json || {}),
rawInput: $input.all().map(i => i.json)
}
}];
Step-by-Step Debugging
const results = { steps: [] };
// Step 1
const input = $input.first().json;
results.steps.push({ step: 1, input });
// Step 2
const processed = input.name?.toUpperCase();
results.steps.push({ step: 2, processed });
// Step 3
const final = { name: processed, timestamp: new Date().toISOString() };
results.steps.push({ step: 3, final });
return [{ json: results }];
Open this reference as its own page
Node Configuration Patterns
Common node configurations and workflow patterns.
Contents
Node Configurations
Webhook Node
{
"type": "n8n-nodes-base.webhook",
"typeVersion": 2,
"parameters": {
"path": "my-webhook-path",
"httpMethod": "POST",
"responseMode": "responseNode",
"options": {}
}
}
Key settings:
path: Unique URL path (no leading slash)httpMethod: GET, POST, PUT, DELETEresponseMode:onReceived(immediate) orresponseNode(wait for Respond node)
HTTP Request Node
{
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.2,
"parameters": {
"method": "POST",
"url": "https://api.example.com/endpoint",
"authentication": "genericCredentialType",
"genericAuthType": "httpHeaderAuth",
"sendHeaders": true,
"headerParameters": {
"parameters": [
{ "name": "Content-Type", "value": "application/json" }
]
},
"sendBody": true,
"bodyParameters": {
"parameters": [
{ "name": "key", "value": "={{ $json.value }}" }
]
}
}
}
Set Node (Add/Modify Fields)
{
"type": "n8n-nodes-base.set",
"typeVersion": 3.4,
"parameters": {
"mode": "manual",
"duplicateItem": false,
"assignments": {
"assignments": [
{
"id": "field1",
"name": "newField",
"value": "={{ $json.existingField }}",
"type": "string"
}
]
},
"includeOtherFields": true
}
}
If Node (Conditional)
{
"type": "n8n-nodes-base.if",
"typeVersion": 2,
"parameters": {
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict"
},
"conditions": [
{
"leftValue": "={{ $json.status }}",
"rightValue": "active",
"operator": {
"type": "string",
"operation": "equals"
}
}
],
"combinator": "and"
}
}
}
Switch Node (Multiple Branches)
{
"type": "n8n-nodes-base.switch",
"typeVersion": 3,
"parameters": {
"mode": "rules",
"rules": {
"rules": [
{
"outputKey": "high",
"conditions": {
"conditions": [
{
"leftValue": "={{ $json.priority }}",
"rightValue": "high",
"operator": { "type": "string", "operation": "equals" }
}
]
}
},
{
"outputKey": "low",
"conditions": {
"conditions": [
{
"leftValue": "={{ $json.priority }}",
"rightValue": "low",
"operator": { "type": "string", "operation": "equals" }
}
]
}
}
]
}
}
}
Loop Over Items Node
{
"type": "n8n-nodes-base.splitInBatches",
"typeVersion": 3,
"parameters": {
"batchSize": 10,
"options": {}
}
}
Merge Node
{
"type": "n8n-nodes-base.merge",
"typeVersion": 3,
"parameters": {
"mode": "combine",
"mergeByFields": {
"values": [
{ "field1": "id", "field2": "userId" }
]
},
"options": {}
}
}
Merge modes:
append: Combine all items from both inputscombine: Match items by field valueschooseBranch: Select one input based on condition
Workflow Patterns
Pattern 1: Webhook + Process + Respond
[Webhook] -> [Code/Set] -> [Respond to Webhook]
Standard request-response pattern. Set webhook responseMode: "responseNode".
Pattern 2: Fan-out/Fan-in
-> [Process A] -
[Split Items] -| |-> [Merge] -> [Output]
-> [Process B] -
Process items in parallel branches, then combine results.
Pattern 3: Error Handling Branch
[Main Process] --success--> [Continue]
|
+--error--> [Error Handler] -> [Notify]
Configure node with continueOnFail: true and check for errors.
Pattern 4: Retry with Backoff
{
"type": "n8n-nodes-base.httpRequest",
"retryOnFail": true,
"maxTries": 3,
"waitBetweenTries": 1000
}
Pattern 5: Pagination Loop
[HTTP Request] -> [Check Has More] --yes--> [Update Page] -> [HTTP Request]
|
+--no--> [Aggregate Results]
For APIs that return paginated results.
Pattern 6: Conditional Execution
[Webhook] -> [If Condition] --true--> [Action A]
|
+--false--> [Action B]
Pattern 7: Data Enrichment
[Get Base Data] -> [Loop] -> [Fetch Details] -> [Merge] -> [Output]
Fetch main records, then enrich each with additional API calls.
Pattern 8: Scheduled Sync
[Schedule Trigger] -> [Get New Records] -> [If Has Records] -> [Process] -> [Update Sync Timestamp]
Open this reference as its own page
Common Pitfalls
Mistakes to avoid and how to debug errors.
Contents
- Command Format Mistakes
- Node Not Installed Errors
- Airtable Mistakes
- Critical Mistakes
- API Mistakes
- Build Process Mistakes
- Error Handling
- Debugging
Command Format Mistakes
NEVER Write JSON Files to Disk
❌ Wrong: Writing workflow JSON to a file, then using -d @file.json
# WRONG - Don't do this!
Write(workflow.json)
curl -X POST ... -d @workflow.json
✅ Right: Use the API directly with inline JSON or heredoc
# RIGHT - Direct API call with inline JSON
export $(cat .env | grep -v '^#' | xargs) && curl -s -X POST "${N8N_API_URL}/api/v1/workflows" -H "X-N8N-API-KEY: ${N8N_API_KEY}" -H "Content-Type: application/json" -d '{"name": "My Workflow", "nodes": [...], "connections": {}}'
NEVER Use Line Continuations in Curl
❌ Wrong: Using \ to break lines (causes "blank argument" errors)
# WRONG - Line continuations break in Claude Code
curl -s -X POST "${URL}" \
-H "Header: value" \
-d '{...}'
✅ Right: Single line commands OR heredoc for large JSON
# RIGHT - Single line
export $(cat .env | grep -v '^#' | xargs) && curl -s -X POST "${N8N_API_URL}/api/v1/workflows" -H "X-N8N-API-KEY: ${N8N_API_KEY}" -H "Content-Type: application/json" -d '{"name": "Test"}'
# RIGHT - Heredoc for large JSON (note: no line breaks in the curl part)
export $(cat .env | grep -v '^#' | xargs) && curl -s -X POST "${N8N_API_URL}/api/v1/workflows" -H "X-N8N-API-KEY: ${N8N_API_KEY}" -H "Content-Type: application/json" -d "$(cat <<'EOF'
{
"name": "My Workflow",
"nodes": [{"id": "1", "name": "Webhook", "type": "n8n-nodes-base.webhook", "typeVersion": 2, "position": [0,0], "parameters": {"path": "test"}}],
"connections": {},
"settings": {"executionOrder": "v1"}
}
EOF
)"
NEVER Use source .env
❌ Wrong: Using source .env (unreliable with special characters)
# WRONG
source .env && curl ...
✅ Right: Use export with grep
# RIGHT - Always use this format
export $(cat .env | grep -v '^#' | xargs) && curl ...
NEVER Use != in jq Filters
❌ Wrong: Using != null in jq (shell interprets ! as history expansion)
# WRONG - causes "unexpected INVALID_CHARACTER" error
jq '.nodes[] | select(.credentials != null)'
✅ Right: Use truthiness check instead
# RIGHT - same result, no shell issues
jq '.nodes[] | select(.credentials)'
Why: Bash interprets ! for history expansion even inside quotes, turning != into \!= which jq can't parse.
Node Not Installed Errors (CRITICAL)
"Install this node to use it" / "Cannot read properties of undefined (reading 'execute')"
This error means the node type or version is NOT INSTALLED on the user's n8n instance. The workflow cannot be activated.
Common causes:
- Using a
typeVersionthat's newer than what's installed - Using community/custom nodes that aren't installed
- Using nodes from a newer n8n version
How to avoid:
- ALWAYS get node configs from the credentials template - The template contains nodes that ARE installed and working
- Use the exact
typeVersionfrom the template - Don't guess or use documentation versions - If a node fails to activate - Check the template for the correct version
Example - HTTP Request node:
❌ WRONG: typeVersion: 4.4 → May not be installed
✅ RIGHT: Use typeVersion from credentials template (e.g., 4.2)
Debugging:
- Error during activation:
"Cannot read properties of undefined (reading 'execute')" - This usually means a node type/version doesn't exist
- Check the workflow in n8n UI - uninstalled nodes show "Install this node to use it"
Solution:
- Fetch credentials template
- Find the node type you need
- Copy the EXACT
typeandtypeVersionfrom the template - If not in template, ask user what version they have installed
Split In Batches Loop Mistakes (CRITICAL)
Wrong Output Index - Loop Doesn't Run
THIS IS THE #1 LOOP MISTAKE. Output 0 and Output 1 are NOT interchangeable!
Split In Batches outputs:
- Output 0 = DONE (items go here AFTER all processing completes)
- Output 1 = LOOP (current batch goes here for processing)
❌ Wrong: Connecting processing to output 0
"Loop Over Items": {
"main": [
[{ "node": "Process Item", "type": "main", "index": 0 }], // WRONG! This is output 0 (done)
[]
]
}
// Result: Loop runs once then stops, processing node may not execute
✅ Right: Connecting processing to output 1
"Loop Over Items": {
"main": [
[], // Output 0: done (empty or final step)
[{ "node": "Process Item", "type": "main", "index": 0 }] // Output 1: loop (processing here!)
]
}
// Result: Loop processes all items correctly
Symptoms of wrong output:
- Loop only runs once
- Processing node doesn't execute
- Error:
"Cannot read properties of undefined (reading 'execute')" - Workflow activates but items aren't processed
Always verify:
- Output 1 (second array) connects to your processing nodes
- Processing nodes connect BACK to Loop node input
- Output 0 (first array) connects to "done" step or is empty
Airtable Mistakes (CRITICAL)
Airtable Does NOT Support Table Creation
❌ Wrong: Trying to use resource: "table" with operation: "create"
{
"resource": "table",
"operation": "create"
}
// ERROR: "Could not get parameter: operation"
✅ Right: User must create tables manually in Airtable UI. n8n only supports:
resource: "base"→getMany,getSchemaresource: "record"→create,delete,get,search,update,upsert
Wrong Parameter Names - Data Node vs Trigger
Airtable data node (v2.1) and Airtable Trigger (v1) use DIFFERENT parameter names!
| Node Type | Base Parameter | Table Parameter |
|---|---|---|
| Airtable (data node v2.1) | base |
table |
| Airtable Trigger (v1) | baseId |
tableId |
For Airtable DATA node:
❌ Wrong: Using baseId and tableId
{
"baseId": {"__rl": true, "mode": "id", "value": "appXXX"},
"tableId": {"__rl": true, "mode": "id", "value": "tblXXX"}
}
// ERROR: WorkflowHasIssuesError
✅ Right: Use base and table
{
"base": {"__rl": true, "mode": "id", "value": "appXXX"},
"table": {"__rl": true, "mode": "id", "value": "tblXXX"}
}
For Airtable TRIGGER node: Use baseId and tableId (the trigger uses different parameter names).
Field Names Must Match EXACTLY
❌ Wrong: Using camelCase or incorrect spacing
{
"GoogleMapsURL": "...",
"FitScore": "..."
}
// ERROR: Unknown field name: "GoogleMapsURL"
✅ Right: Use EXACT field names from Airtable (with spaces)
{
"Google Maps URL": "...",
"Fit Score": "..."
}
Solution: Always use getSchema operation first to fetch exact field names before creating records.
Critical Mistakes
Using HTTP Request When Native Node Exists
❌ Wrong: Using HTTP Request to call Slack API when n8n-nodes-base.slack exists
✅ Right: Use native Slack node with credentials from template
Exception: Native node has known bug or missing feature
Using Mock/Placeholder Data
❌ Wrong:
"url": "https://api.example.com/placeholder"
"documentId": "REPLACE_ME"
"apiKey": "your-api-key-here"
✅ Right: Use real URLs, real IDs, real credential references from template
If missing: Ask user for real values, don't guess or mock
Adding Multiple Nodes Before Testing
❌ Wrong: Add Node A → Add Node B → Add Node C → Test → Error (which failed?)
✅ Right: Add ONE node → Test → Add ONE node → Test → Repeat
API Mistakes
Using PATCH Instead of PUT
❌ Wrong: curl -X PATCH /api/v1/workflows/{id}
✅ Right: curl -X PUT /api/v1/workflows/{id}
Trying to Activate with PUT
❌ Wrong: curl -X PUT /api/v1/workflows/{id} -d '{"active": true}'
✅ Right: curl -X POST /api/v1/workflows/{id}/activate
Trying to Execute Manual Trigger via API
❌ Wrong: Expecting POST /api/v1/workflows/{id}/run to exist
✅ Right: Add webhook trigger, activate workflow, call webhook URL
Executing Webhook Before Activating
❌ Wrong: POST /webhook/path on inactive workflow
✅ Right: First activate, then call webhook
Fetching All Executions
❌ Wrong: GET /api/v1/executions (fetches everything)
✅ Right: GET /api/v1/executions?limit=2 (only recent)
Build Process Mistakes
Telling User to Test Instead of Testing Yourself
❌ Wrong: "Workflow created! Please test it."
✅ Right: Test it yourself, debug failures, report only after confirmed working
Reporting Success Without Testing
❌ Wrong: "Workflow is ready to use!" (without executing)
✅ Right: Execute workflow, verify status=success, then report
Not Verifying Each Node Executed
❌ Wrong: Check only final status, assume all nodes ran
✅ Right: Check runData | keys to verify each node
Creating New Workflows Instead of Updating
❌ Wrong: Create new workflow each time you add a node
✅ Right: Create ONE workflow, use PUT to update incrementally
Leaving Google Sheets documentId Empty
❌ Wrong: Creating workflow with empty documentId.value and executing
✅ Right: Get spreadsheet ID from user, or warn about manual UI config
Error Handling
Common API Errors
| Status | Meaning | Solution |
|---|---|---|
| 401 | Unauthorized | Check API key is valid |
| 404 | Not found | Check workflow/execution ID exists |
| 400 | Bad request | Validate JSON structure |
| 409 | Conflict | Workflow name may be duplicate |
| "method not allowed" | Wrong HTTP method | Use PUT for updates, POST for activate |
WorkflowHasIssuesError
If execution fails with WorkflowHasIssuesError:
- Check for nodes with incomplete configuration (empty required fields)
- Common cause: Google Sheets without documentId selected
- User must open workflow in n8n UI to complete configuration
Google Sheets Configuration
Placeholder (will cause error if executed):
{
"documentId": {"__rl": true, "mode": "list", "value": ""},
"sheetName": {"__rl": true, "mode": "list", "value": ""}
}
If user provides spreadsheet URL:
{
"documentId": {"__rl": true, "mode": "id", "value": "SPREADSHEET_ID_FROM_URL"},
"sheetName": {"__rl": true, "mode": "name", "value": "Sheet1"}
}
Debugging
List Recent Executions (limit to 2)
export $(cat .env | grep -v '^#' | xargs) && curl -s "${N8N_API_URL}/api/v1/executions?limit=2" -H "X-N8N-API-KEY: ${N8N_API_KEY}" | jq '.data[] | {id, status, startedAt, workflowId}'
Get Error Details
export $(cat .env | grep -v '^#' | xargs) && curl -s "${N8N_API_URL}/api/v1/executions/{EXECUTION_ID}?includeData=true" -H "X-N8N-API-KEY: ${N8N_API_KEY}" | jq '.data.resultData.error'
Check Which Nodes Ran
export $(cat .env | grep -v '^#' | xargs) && curl -s "${N8N_API_URL}/api/v1/executions/{EXECUTION_ID}?includeData=true" -H "X-N8N-API-KEY: ${N8N_API_KEY}" | jq '.data.resultData.runData | keys'
Get Node Output Data
export $(cat .env | grep -v '^#' | xargs) && curl -s "${N8N_API_URL}/api/v1/executions/{EXECUTION_ID}?includeData=true" -H "X-N8N-API-KEY: ${N8N_API_KEY}" | jq '.data.resultData.runData["Node Name"]'
Open this reference as its own page
Python in Code Nodes
Complete reference for Python code in n8n Code nodes.
Contents
- Basic Syntax
- Processing Items
- Filtering
- Data Processing
- Working with JSON
- Date Handling
- Error Handling
Basic Syntax
Key difference from JavaScript: Use _input instead of $input
# Access input data
items = _input.all()
first_item = _input.first()
data = _input.first().json
# Return data (MUST be a list)
return [{"json": {"result": "success"}}]
Processing Items
# Transform all items
results = []
for item in _input.all():
results.append({
"json": {
"original": item.json["name"],
"upper": item.json["name"].upper()
}
})
return results
# List comprehension (cleaner)
return [
{"json": {"name": item.json["name"].upper()}}
for item in _input.all()
]
Filtering
# Filter items
active_items = [
item for item in _input.all()
if item.json.get("status") == "active"
]
return [{"json": item.json} for item in active_items]
# Filter with multiple conditions
filtered = [
item for item in _input.all()
if item.json.get("status") == "active"
and item.json.get("score", 0) > 80
]
return [{"json": item.json} for item in filtered]
Data Processing
# Sum values
total = sum(item.json["amount"] for item in _input.all())
return [{"json": {"total": total}}]
# Group by category
from collections import defaultdict
grouped = defaultdict(list)
for item in _input.all():
grouped[item.json["category"]].append(item.json)
return [{"json": dict(grouped)}]
# Count items
count = len(_input.all())
return [{"json": {"count": count}}]
# Find min/max
values = [item.json["value"] for item in _input.all()]
return [{"json": {
"min": min(values),
"max": max(values),
"avg": sum(values) / len(values)
}}]
Working with JSON
import json
# Parse JSON string
data = json.loads(_input.first().json["json_string"])
# Stringify object
json_str = json.dumps({"key": "value"})
# Pretty print
pretty = json.dumps(data, indent=2)
return [{"json": {"parsed": data, "stringified": json_str}}]
Date Handling
from datetime import datetime, timedelta
# Current date
now = datetime.now()
iso_string = now.isoformat()
# Parse date
date_str = _input.first().json["date"]
parsed = datetime.fromisoformat(date_str)
# Add days
next_week = now + timedelta(days=7)
# Format date
formatted = now.strftime("%Y-%m-%d %H:%M:%S")
return [{"json": {
"now": iso_string,
"next_week": next_week.isoformat(),
"formatted": formatted
}}]
Error Handling
try:
data = _input.first().json
if "required_field" not in data:
raise ValueError("Missing required_field")
result = data["required_field"].upper()
return [{"json": {"success": True, "result": result}}]
except Exception as e:
return [{"json": {"success": False, "error": str(e)}}]
Safe Property Access
# Use .get() for safe access
data = _input.first().json
name = data.get("name", "Unknown")
email = data.get("user", {}).get("email", "no-email")
return [{"json": {"name": name, "email": email}}]
Quick Reference
# Input
items = _input.all()
first = _input.first().json
field = _input.first().json["fieldName"]
safe_field = _input.first().json.get("fieldName", "default")
# Return (MUST be list)
return [{"json": {"result": "value"}}]
# Multiple items
return [
{"json": {"id": 1}},
{"json": {"id": 2}}
]
# Transform all
return [{"json": {**item.json, "new": "field"}} for item in _input.all()]
Open this reference as its own page
Transform & Utility Nodes
Nodes for data transformation, logic, and workflow control.
Contents
- Set
- If
- Switch
- Filter
- Sort
- Split Out
- Merge
- Code
- HTTP Request
- Wait
- Split In Batches
- Respond to Webhook
- Connection Patterns
Set
Add/modify fields:
{
"id": "set-1",
"name": "Set",
"type": "n8n-nodes-base.set",
"typeVersion": 3.4,
"position": [450, 300],
"parameters": {
"mode": "manual",
"duplicateItem": false,
"assignments": {
"assignments": [
{
"id": "uuid-1",
"name": "fullName",
"value": "={{ $json.firstName }} {{ $json.lastName }}",
"type": "string"
},
{
"id": "uuid-2",
"name": "processed",
"value": true,
"type": "boolean"
}
]
},
"includeOtherFields": true,
"options": {}
}
}
If
Conditional branching:
{
"id": "if-1",
"name": "If",
"type": "n8n-nodes-base.if",
"typeVersion": 2.2,
"position": [450, 300],
"parameters": {
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict",
"version": 2
},
"conditions": [
{
"id": "condition-1",
"leftValue": "={{ $json.status }}",
"rightValue": "active",
"operator": {
"type": "string",
"operation": "equals"
}
}
],
"combinator": "and"
},
"options": {}
}
}
Switch
Multiple branches:
{
"id": "switch-1",
"name": "Switch",
"type": "n8n-nodes-base.switch",
"typeVersion": 3.2,
"position": [450, 300],
"parameters": {
"mode": "rules",
"rules": {
"values": [
{
"outputKey": "high",
"conditions": {
"options": { "version": 2, "caseSensitive": true, "typeValidation": "strict" },
"conditions": [
{
"leftValue": "={{ $json.priority }}",
"rightValue": "high",
"operator": { "type": "string", "operation": "equals" }
}
],
"combinator": "and"
},
"renameOutput": true
},
{
"outputKey": "low",
"conditions": {
"options": { "version": 2, "caseSensitive": true, "typeValidation": "strict" },
"conditions": [
{
"leftValue": "={{ $json.priority }}",
"rightValue": "low",
"operator": { "type": "string", "operation": "equals" }
}
],
"combinator": "and"
},
"renameOutput": true
}
]
},
"options": {}
}
}
Filter
Remove items that don't match conditions:
{
"id": "filter-1",
"name": "Filter",
"type": "n8n-nodes-base.filter",
"typeVersion": 2.3,
"position": [450, 300],
"parameters": {
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict",
"version": 2
},
"conditions": [
{
"id": "condition-1",
"leftValue": "={{ $json.status }}",
"rightValue": "active",
"operator": {
"type": "string",
"operation": "equals"
}
}
],
"combinator": "and"
},
"looseTypeValidation": false
}
}
Multiple conditions:
{
"parameters": {
"conditions": {
"options": {
"version": 2,
"caseSensitive": true,
"typeValidation": "strict"
},
"conditions": [
{
"leftValue": "={{ $json.price }}",
"rightValue": 100,
"operator": { "type": "number", "operation": "gt" }
},
{
"leftValue": "={{ $json.inStock }}",
"rightValue": true,
"operator": { "type": "boolean", "operation": "equals" }
}
],
"combinator": "and"
}
}
}
Operators:
- String:
equals,notEquals,contains,notContains,startsWith,endsWith,regex - Number:
equals,notEquals,gt,gte,lt,lte - Boolean:
equals,notEquals
Sort
Sort by field:
{
"id": "sort-1",
"name": "Sort",
"type": "n8n-nodes-base.sort",
"typeVersion": 1,
"position": [450, 300],
"parameters": {
"type": "simple",
"sortFieldsUi": {
"sortField": [
{
"fieldName": "createdAt",
"order": "descending"
}
]
},
"options": {}
}
}
Sort by multiple fields:
{
"parameters": {
"type": "simple",
"sortFieldsUi": {
"sortField": [
{
"fieldName": "priority",
"order": "ascending"
},
{
"fieldName": "createdAt",
"order": "descending"
}
]
}
}
}
Random shuffle:
{
"parameters": {
"type": "random"
}
}
Custom code sort:
{
"parameters": {
"type": "code",
"code": "fieldName = 'score';\n\nif (a.json[fieldName] < b.json[fieldName]) {\n return -1;\n}\nif (a.json[fieldName] > b.json[fieldName]) {\n return 1;\n}\nreturn 0;"
}
}
Sort types: simple, random, code
Split Out
Turn a list inside items into separate items:
{
"id": "split-out-1",
"name": "Split Out",
"type": "n8n-nodes-base.splitOut",
"typeVersion": 1,
"position": [450, 300],
"parameters": {
"fieldToSplitOut": "items",
"include": "noOtherFields",
"options": {}
}
}
Include other fields:
{
"parameters": {
"fieldToSplitOut": "products",
"include": "allOtherFields"
}
}
Include specific fields:
{
"parameters": {
"fieldToSplitOut": "tags",
"include": "selectedOtherFields",
"fieldsToInclude": "id, name, category"
}
}
Include options:
noOtherFields- Only the split out fieldallOtherFields- Include all other fieldsselectedOtherFields- Include specific fields
Merge
Combine by position:
{
"id": "merge-1",
"name": "Merge",
"type": "n8n-nodes-base.merge",
"typeVersion": 3,
"position": [650, 300],
"parameters": {
"mode": "combine",
"combineBy": "combineByPosition",
"options": {
"includeUnpaired": true
}
}
}
Choose branch:
{
"parameters": {
"mode": "chooseBranch",
"numberInputs": 2
}
}
Code
JavaScript:
{
"id": "code-1",
"name": "Code",
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [450, 300],
"parameters": {
"language": "javaScript",
"mode": "runOnceForAllItems",
"jsCode": "const results = [];\n\nfor (const item of $input.all()) {\n results.push({\n json: {\n ...item.json,\n processed: true,\n timestamp: new Date().toISOString()\n }\n });\n}\n\nreturn results;"
}
}
Python:
{
"parameters": {
"language": "pythonNative",
"mode": "runOnceForAllItems",
"pythonCode": "results = []\n\nfor item in _input.all():\n results.append({\n \"json\": {\n **item.json,\n \"processed\": True\n }\n })\n\nreturn results"
}
}
HTTP Request
{
"id": "http-1",
"name": "HTTP Request",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.4,
"position": [450, 300],
"parameters": {
"method": "POST",
"url": "https://api.example.com/endpoint",
"authentication": "genericCredentialType",
"genericAuthType": "httpHeaderAuth",
"sendHeaders": true,
"headerParameters": {
"parameters": [
{
"name": "Content-Type",
"value": "application/json"
}
]
},
"sendBody": true,
"specifyBody": "json",
"jsonBody": "{\n \"key\": \"{{ $json.value }}\"\n}",
"options": {}
},
"credentials": {
"httpHeaderAuth": {
"id": "cred-id",
"name": "API Key"
}
}
}
GET request:
{
"parameters": {
"method": "GET",
"url": "https://api.example.com/data",
"authentication": "none",
"sendQuery": true,
"queryParameters": {
"parameters": [
{ "name": "limit", "value": "10" },
{ "name": "offset", "value": "={{ $json.offset }}" }
]
},
"options": {}
}
}
Methods: GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS
Body types:
json- JSON bodyform-urlencoded- Form URL encodedmultipart-form-data- Form data (file uploads)raw- Raw contentbinaryData- Binary file
Authentication types:
none- No authenticationpredefinedCredentialType- Use predefined credentials (OAuth, API keys)genericCredentialType- Generic header/query/basic auth
Wait
Time interval:
{
"id": "wait-1",
"name": "Wait",
"type": "n8n-nodes-base.wait",
"typeVersion": 1.1,
"position": [450, 300],
"parameters": {
"resume": "timeInterval",
"amount": 5,
"unit": "seconds"
}
}
Wait for webhook:
{
"parameters": {
"resume": "webhook",
"responseData": "allEntries",
"options": {}
}
}
Split In Batches
{
"id": "batch-1",
"name": "Split In Batches",
"type": "n8n-nodes-base.splitInBatches",
"typeVersion": 3,
"position": [450, 300],
"parameters": {
"batchSize": 10,
"options": {}
}
}
Respond to Webhook
{
"id": "respond-1",
"name": "Respond to Webhook",
"type": "n8n-nodes-base.respondToWebhook",
"typeVersion": 1.1,
"position": [850, 300],
"parameters": {
"respondWith": "json",
"responseBody": "={{ JSON.stringify({ success: true, data: $json }) }}",
"options": {}
}
}
Connection Patterns
Basic Linear Connection
{
"connections": {
"Webhook": {
"main": [[{ "node": "Set", "type": "main", "index": 0 }]]
},
"Set": {
"main": [[{ "node": "Google Sheets", "type": "main", "index": 0 }]]
}
}
}
If Node (Two Branches)
{
"connections": {
"If": {
"main": [
[{ "node": "True Branch", "type": "main", "index": 0 }],
[{ "node": "False Branch", "type": "main", "index": 0 }]
]
}
}
}
Switch Node (Multiple Branches)
{
"connections": {
"Switch": {
"main": [
[{ "node": "High Priority", "type": "main", "index": 0 }],
[{ "node": "Medium Priority", "type": "main", "index": 0 }],
[{ "node": "Low Priority", "type": "main", "index": 0 }]
]
}
}
}
Merge (Multiple Inputs)
{
"connections": {
"Branch A": {
"main": [[{ "node": "Merge", "type": "main", "index": 0 }]]
},
"Branch B": {
"main": [[{ "node": "Merge", "type": "main", "index": 1 }]]
}
}
}
Looping Patterns
ALWAYS prefer the Loop node (Split In Batches) for processing multiple items.
Why Loop node is preferred:
- Visually cleaner in the n8n UI
- Easy to understand the flow
- Built-in batch size control
- Clear "done" vs "loop" outputs
- Better than Code node loops or manual iteration
Split In Batches Loop (PREFERRED - Most Common)
⚠️ CRITICAL: Split In Batches Output Indexes
THIS IS THE #1 MISTAKE WITH LOOPS. GET THIS RIGHT OR THE LOOP WON'T WORK!
Split In Batches has TWO outputs:
┌─────────────────────────────┐
│ Split In Batches │
│ │
│ Output 0 ──→ "DONE" │ ← Items go here AFTER all items processed
│ Output 1 ──→ "LOOP" │ ← Current batch goes here (CONNECT PROCESSING HERE!)
└─────────────────────────────┘
Output 0 = DONE - Empty during loop, receives all items when loop completes Output 1 = LOOP - Receives current batch item(s) for processing
❌ WRONG - Connecting processing to output 0:
"Loop Over Items": {
"main": [
[{ "node": "Process Item", "type": "main", "index": 0 }], // OUTPUT 0 - WRONG!
[]
]
}
✅ CORRECT - Connecting processing to output 1:
"Loop Over Items": {
"main": [
[], // OUTPUT 0 - empty or "Done" node
[{ "node": "Process Item", "type": "main", "index": 0 }] // OUTPUT 1 - processing goes here!
]
}
Complete Loop Example
Use case: Process items one at a time, with processing node in between.
{
"nodes": [
{
"id": "loop-1",
"name": "Loop Over Items",
"type": "n8n-nodes-base.splitInBatches",
"typeVersion": 3,
"position": [450, 300],
"parameters": {
"batchSize": 1,
"options": {}
}
},
{
"id": "process-1",
"name": "Process Item",
"type": "n8n-nodes-base.set",
"typeVersion": 3.4,
"position": [650, 400],
"parameters": {
"mode": "manual",
"assignments": {
"assignments": [
{
"id": "uuid-1",
"name": "processed",
"value": true,
"type": "boolean"
}
]
}
}
},
{
"id": "done-1",
"name": "Loop Done",
"type": "n8n-nodes-base.set",
"typeVersion": 3.4,
"position": [650, 200],
"parameters": {
"mode": "manual",
"assignments": {
"assignments": [
{
"id": "uuid-done",
"name": "status",
"value": "completed",
"type": "string"
}
]
}
}
}
],
"connections": {
"Get Items": {
"main": [[{ "node": "Loop Over Items", "type": "main", "index": 0 }]]
},
"Loop Over Items": {
"main": [
[{ "node": "Loop Done", "type": "main", "index": 0 }],
[{ "node": "Process Item", "type": "main", "index": 0 }]
]
},
"Process Item": {
"main": [[{ "node": "Loop Over Items", "type": "main", "index": 0 }]]
}
}
}
Key points:
- Output 0 → "Loop Done" node (runs AFTER all items processed)
- Output 1 → "Process Item" node (runs for EACH item)
- "Process Item" connects BACK to "Loop Over Items" input (loops back)
- Loop continues until all items processed, then exits via output 0
Visual connection pattern:
┌──→ [Output 0: DONE] → "Loop Done" → Continue workflow
│
Get Items → Loop Over Items ─────┤
│
└──→ [Output 1: LOOP] → "Process Item" ─┐
↑ │
└──────────────────────────┘
Minimal Loop (No Done Handler)
If you don't need to do anything after the loop, output 0 can be empty:
{
"connections": {
"Loop Over Items": {
"main": [
[], // Output 0: empty (loop just ends)
[{ "node": "Process Item", "type": "main", "index": 0 }] // Output 1: processing
]
},
"Process Item": {
"main": [[{ "node": "Loop Over Items", "type": "main", "index": 0 }]]
}
}
}
If/Else Branch with Loop Back
Use case: Check condition, process if needed, loop back for retry or continuation.
{
"connections": {
"Check Condition": {
"main": [
[{ "node": "Process New", "type": "main", "index": 0 }],
[{ "node": "Skip Existing", "type": "main", "index": 0 }]
]
},
"Process New": {
"main": [[{ "node": "Save Result", "type": "main", "index": 0 }]]
},
"Save Result": {
"main": [[{ "node": "Loop Over Items", "type": "main", "index": 0 }]]
},
"Skip Existing": {
"main": [[{ "node": "Loop Over Items", "type": "main", "index": 0 }]]
}
}
}
Key points:
- Both branches (true and false) loop back to Split In Batches
- Ensures every item is processed and loop continues
Wait + Retry Loop
Use case: Wait between API calls, retry on failure.
{
"nodes": [
{
"id": "wait-1",
"name": "Wait Between Calls",
"type": "n8n-nodes-base.wait",
"typeVersion": 1.1,
"position": [450, 300],
"parameters": {
"resume": "timeInterval",
"amount": 2,
"unit": "seconds"
}
}
],
"connections": {
"API Call": {
"main": [[{ "node": "Check Success", "type": "main", "index": 0 }]]
},
"Check Success": {
"main": [
[{ "node": "Continue", "type": "main", "index": 0 }],
[{ "node": "Wait Between Calls", "type": "main", "index": 0 }]
]
},
"Wait Between Calls": {
"main": [[{ "node": "API Call", "type": "main", "index": 0 }]]
}
}
}
Pagination Loop
Use case: Fetch paginated API results until no more pages.
{
"nodes": [
{
"id": "fetch-1",
"name": "Fetch Page",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.4,
"position": [450, 300],
"parameters": {
"method": "GET",
"url": "https://api.example.com/items",
"sendQuery": true,
"queryParameters": {
"parameters": [
{ "name": "page", "value": "={{ $json.nextPage ?? 1 }}" },
{ "name": "limit", "value": "100" }
]
}
}
},
{
"id": "check-1",
"name": "Has More Pages",
"type": "n8n-nodes-base.if",
"typeVersion": 2.2,
"position": [650, 300],
"parameters": {
"conditions": {
"options": { "version": 2, "caseSensitive": true, "typeValidation": "strict" },
"conditions": [
{
"leftValue": "={{ $json.hasNextPage }}",
"rightValue": true,
"operator": { "type": "boolean", "operation": "equals" }
}
],
"combinator": "and"
}
}
}
],
"connections": {
"Fetch Page": {
"main": [[{ "node": "Process Items", "type": "main", "index": 0 }]]
},
"Process Items": {
"main": [[{ "node": "Has More Pages", "type": "main", "index": 0 }]]
},
"Has More Pages": {
"main": [
[{ "node": "Fetch Page", "type": "main", "index": 0 }],
[{ "node": "Done", "type": "main", "index": 0 }]
]
}
}
}
Quick Reference: Transform Node typeVersions
| Node | typeVersion |
|---|---|
| Set | 3.4 |
| If | 2.2 |
| Switch | 3.2 |
| Filter | 2.3 |
| Sort | 1 |
| Split Out | 1 |
| Merge | 3 |
| Code | 2 |
| HTTP Request | 4.4 |
| Wait | 1.1 |
| Split In Batches | 3 |
| Respond to Webhook | 1.1 |
Open this reference as its own page
Trigger Nodes
Starting points for workflow execution.
Contents
- Webhook
- Schedule Trigger
- Form Trigger
- Chat Trigger
- Airtable Trigger
- Gmail Trigger
- Slack Trigger
- Telegram Trigger
- WhatsApp Trigger
- HubSpot Trigger
- Stripe Trigger
- Shopify Trigger
- Postgres Trigger
- Google Sheets Trigger
Webhook
ALWAYS use responseMode: "onReceived" (Respond Immediately) by default.
{
"id": "webhook-1",
"name": "Webhook",
"type": "n8n-nodes-base.webhook",
"typeVersion": 2,
"position": [250, 300],
"parameters": {
"path": "my-webhook-path",
"httpMethod": "POST",
"responseMode": "onReceived",
"options": {}
},
"webhookId": "unique-webhook-id"
}
Response modes:
onReceived- PREFERRED - Respond immediately, workflow runs in backgroundlastNode- Wait for workflow to complete and return last node's outputresponseNode- Wait for Respond to Webhook node (custom response)streaming- Stream response in real-time (v2.1+)
Why onReceived is preferred:
- Caller doesn't wait for long-running workflows
- No timeout issues on complex workflows
- Workflow runs reliably in background
Authentication options:
none- No authenticationbasicAuth- Basic AuthheaderAuth- Header AuthjwtAuth- JWT Auth
Schedule Trigger
{
"id": "schedule-1",
"name": "Schedule Trigger",
"type": "n8n-nodes-base.scheduleTrigger",
"typeVersion": 1.2,
"position": [250, 300],
"parameters": {
"rule": {
"interval": [
{
"field": "hours",
"hoursInterval": 1
}
]
}
}
}
Common intervals:
Every hour:
{ "field": "hours", "hoursInterval": 1 }
Daily at 9 AM:
{ "field": "days", "triggerAtHour": 9 }
Every 30 minutes:
{ "field": "minutes", "minutesInterval": 30 }
Weekly on Monday at 9 AM:
{ "field": "weeks", "triggerAtDay": [1], "triggerAtHour": 9 }
Form Trigger
{
"id": "form-trigger-1",
"name": "n8n Form Trigger",
"type": "n8n-nodes-base.formTrigger",
"typeVersion": 2.2,
"position": [250, 300],
"parameters": {
"formTitle": "Contact Form",
"formDescription": "Please fill out this form",
"formFields": {
"values": [
{
"fieldLabel": "Name",
"fieldType": "text",
"requiredField": true
},
{
"fieldLabel": "Email",
"fieldType": "email",
"requiredField": true
},
{
"fieldLabel": "Message",
"fieldType": "textarea",
"requiredField": false
}
]
},
"options": {}
},
"webhookId": "unique-form-id"
}
Field types: text, email, number, textarea, dropdown, date, file
Chat Trigger
{
"id": "chat-trigger-1",
"name": "When chat message received",
"type": "@n8n/n8n-nodes-langchain.chatTrigger",
"typeVersion": 1.1,
"position": [250, 300],
"parameters": {
"options": {}
},
"webhookId": "unique-chat-id"
}
Use with AI Agent for conversational workflows.
Airtable Trigger
Note: Airtable Trigger (v1) uses baseId/tableId parameters. This is different from Airtable data node (v2.1) which uses base/table. Use the correct parameter names for each node type.
{
"id": "airtable-trigger-1",
"name": "Airtable Trigger",
"type": "n8n-nodes-base.airtableTrigger",
"typeVersion": 1,
"position": [250, 300],
"parameters": {
"pollTimes": {
"item": [{ "mode": "everyMinute" }]
},
"baseId": {
"__rl": true,
"mode": "id",
"value": "appXXXXXXXXXXXXXX"
},
"tableId": {
"__rl": true,
"mode": "id",
"value": "tblXXXXXXXXXXXXXX"
}
},
"credentials": {
"airtableTokenApi": {
"id": "cred-id",
"name": "Airtable Token"
}
}
}
Gmail Trigger
{
"id": "gmail-trigger-1",
"name": "Gmail Trigger",
"type": "n8n-nodes-base.gmailTrigger",
"typeVersion": 1.2,
"position": [250, 300],
"parameters": {
"pollTimes": {
"item": [{ "mode": "everyMinute" }]
},
"filters": {
"includeSpamTrash": false
}
},
"credentials": {
"gmailOAuth2": {
"id": "cred-id",
"name": "Gmail OAuth2"
}
}
}
Slack Trigger
{
"id": "slack-trigger-1",
"name": "Slack Trigger",
"type": "n8n-nodes-base.slackTrigger",
"typeVersion": 1,
"position": [250, 300],
"parameters": {
"trigger": "onMessage",
"channelId": {
"__rl": true,
"mode": "id",
"value": "C0XXXXXXXXX"
}
},
"credentials": {
"slackOAuth2Api": {
"id": "cred-id",
"name": "Slack OAuth2"
}
}
}
Trigger events: onMessage, onReactionAdded, onChannelCreated, onUserJoined
Telegram Trigger
{
"id": "telegram-trigger-1",
"name": "Telegram Trigger",
"type": "n8n-nodes-base.telegramTrigger",
"typeVersion": 1.1,
"position": [250, 300],
"parameters": {
"updates": ["message", "callback_query"]
},
"credentials": {
"telegramApi": {
"id": "cred-id",
"name": "Telegram API"
}
}
}
Update types: message, edited_message, callback_query, inline_query, channel_post
WhatsApp Trigger
{
"id": "whatsapp-trigger-1",
"name": "WhatsApp Trigger",
"type": "n8n-nodes-base.whatsAppTrigger",
"typeVersion": 1,
"position": [250, 300],
"parameters": {
"updates": ["messages"]
},
"credentials": {
"whatsAppBusinessCloudApi": {
"id": "cred-id",
"name": "WhatsApp Business Cloud"
}
}
}
HubSpot Trigger
{
"id": "hubspot-trigger-1",
"name": "HubSpot Trigger",
"type": "n8n-nodes-base.hubspotTrigger",
"typeVersion": 1,
"position": [250, 300],
"parameters": {
"eventsUi": {
"eventValues": [
{
"name": "contact.creation"
}
]
}
},
"credentials": {
"hubspotDeveloperApi": {
"id": "cred-id",
"name": "HubSpot Developer"
}
}
}
Events: contact.creation, contact.propertyChange, deal.creation, deal.propertyChange
Stripe Trigger
{
"id": "stripe-trigger-1",
"name": "Stripe Trigger",
"type": "n8n-nodes-base.stripeTrigger",
"typeVersion": 1,
"position": [250, 300],
"parameters": {
"events": ["payment_intent.succeeded", "customer.subscription.created"]
},
"credentials": {
"stripeApi": {
"id": "cred-id",
"name": "Stripe API"
}
}
}
Common events: payment_intent.succeeded, customer.subscription.created, invoice.paid, checkout.session.completed
Shopify Trigger
{
"id": "shopify-trigger-1",
"name": "Shopify Trigger",
"type": "n8n-nodes-base.shopifyTrigger",
"typeVersion": 1,
"position": [250, 300],
"parameters": {
"topic": "orders/create"
},
"credentials": {
"shopifyApi": {
"id": "cred-id",
"name": "Shopify API"
}
}
}
Topics: orders/create, orders/updated, products/create, customers/create
Postgres Trigger
{
"id": "postgres-trigger-1",
"name": "Postgres Trigger",
"type": "n8n-nodes-base.postgresTrigger",
"typeVersion": 1,
"position": [250, 300],
"parameters": {
"triggerMode": "createTrigger",
"schema": "public",
"tableName": "users",
"channelName": "n8n_changes",
"firesOn": "INSERT"
},
"credentials": {
"postgres": {
"id": "cred-id",
"name": "Postgres"
}
}
}
Fires on: INSERT, UPDATE, DELETE
Google Sheets Trigger
{
"id": "sheets-trigger-1",
"name": "Google Sheets Trigger",
"type": "n8n-nodes-base.googleSheetsTrigger",
"typeVersion": 1,
"position": [250, 300],
"parameters": {
"pollTimes": {
"item": [{ "mode": "everyMinute" }]
},
"documentId": {
"__rl": true,
"mode": "id",
"value": "SPREADSHEET_ID"
},
"sheetName": {
"__rl": true,
"mode": "name",
"value": "Sheet1"
},
"event": "rowAdded"
},
"credentials": {
"googleSheetsOAuth2Api": {
"id": "cred-id",
"name": "Google Sheets OAuth2"
}
}
}
Events: rowAdded, rowUpdated
Quick Reference: Trigger typeVersions
| Node | typeVersion |
|---|---|
| Webhook | 2 |
| Schedule Trigger | 1.2 |
| Form Trigger | 2.2 |
| Chat Trigger | 1.1 |
| Airtable Trigger | 1 |
| Gmail Trigger | 1.2 |
| Slack Trigger | 1 |
| Telegram Trigger | 1.1 |
| WhatsApp Trigger | 1 |
| HubSpot Trigger | 1 |
| Stripe Trigger | 1 |
| Shopify Trigger | 1 |
| Postgres Trigger | 1 |
| Google Sheets Trigger | 1 |
More in this playbook
Safe to turn on
Use this skill when an agent or person is about to create, change or enable an automation inside someone else's account or a shared environment: "create this workflow", "build it in the customer's account", "turn it on", "go live", "deploy this automation". Produces a proposal the human approves, an automation created in the off state, and a short list of what only the human can finish.
Workflow buildingMITn8n agents
Design n8n AI agents the right way. Use when building or editing any @n8n/n8n-nodes-langchain.* AI node — an AI Agent, LLM chain, Text Classifier, or Information Extractor — and whenever the user mentions AI agents, LLM with tools, tool calling, $fromAI, system prompts, agent memory, sessionId, structured/JSON output, output parser, RAG, vector store, a chat assistant/bot, or human-in-the-loop review. Covers Agent-vs-chain-vs-classifier choice, the model/memory/tools/outputParser slots, tool names/descriptions as prompt, structured output with autoFix, memory, RAG, human review, and chat topologies.
Workflow buildingMITn8n agents
Design n8n AI agents the right way. Use when building or editing any @n8n/n8n-nodes-langchain.* AI node — an AI Agent, LLM chain, Text Classifier, or Information Extractor — and whenever the user mentions AI agents, LLM with tools, tool calling, $fromAI, system prompts, agent memory, sessionId, structured/JSON output, output parser, RAG, vector store, a chat assistant/bot, or human-in-the-loop review. Covers Agent-vs-chain-vs-classifier choice, the model/memory/tools/outputParser slots, tool names/descriptions as prompt, structured output with autoFix, memory, RAG, human review, and chat topologies.


