[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill-59da939e-4801-487e-9e57-161f4eb2b31f":3,"$fWyRMvKBRGRqdAXdDdao9nrH4BpS_NGw6ED7qFe68_-g":42},{"id":4,"title":5,"description":6,"categoryId":7,"moduleId":8,"tags":9,"prompt":10,"icon":11,"source":12,"sourceUrl":13,"authorId":14,"authorName":15,"isPublic":16,"stars":17,"runs":18,"createdAt":19,"updatedAt":19,"module":20,"category":27,"packages":33},"59da939e-4801-487e-9e57-161f4eb2b31f","n8n-expression-syntax","验证n8n表达式语法并修复常见错误。在编写n8n表达式、使用{{}}语法、访问$json\u002F$node变量、排查表达式错误或在工作流程中处理webhook数据时使用。","cat_coding_backend","mod_coding","sickn33,coding","---\nname: n8n-expression-syntax\ndescription: Validate n8n expression syntax and fix common errors. Use when writing n8n expressions, using {{}} syntax, accessing $json\u002F$node variables, troubleshooting expression errors, or working with webhook data in workflows.\nrisk: unknown\nsource: community\n---\n\n# n8n Expression Syntax\n\nExpert guide for writing correct n8n expressions in workflows.\n\n## When to Use\n- You need to write or debug n8n expressions using `{{ ... }}` syntax.\n- The task involves `$json`, `$node`, webhook payloads, or expression-related workflow errors.\n- You want syntax-correct dynamic values inside n8n nodes and parameters.\n\n---\n\n## Expression Format\n\nAll dynamic content in n8n uses **double curly braces**:\n\n```\n{{expression}}\n```\n\n**Examples**:\n```\n✅ {{$json.email}}\n✅ {{$json.body.name}}\n✅ {{$node[\"HTTP Request\"].json.data}}\n❌ $json.email  (no braces - treated as literal text)\n❌ {$json.email}  (single braces - invalid)\n```\n\n---\n\n## Core Variables\n\n### $json - Current Node Output\n\nAccess data from the current node:\n\n```javascript\n{{$json.fieldName}}\n{{$json['field with spaces']}}\n{{$json.nested.property}}\n{{$json.items[0].name}}\n```\n\n### $node - Reference Other Nodes\n\nAccess data from any previous node:\n\n```javascript\n{{$node[\"Node Name\"].json.fieldName}}\n{{$node[\"HTTP Request\"].json.data}}\n{{$node[\"Webhook\"].json.body.email}}\n```\n\n**Important**:\n- Node names **must** be in quotes\n- Node names are **case-sensitive**\n- Must match exact node name from workflow\n\n### $now - Current Timestamp\n\nAccess current date\u002Ftime:\n\n```javascript\n{{$now}}\n{{$now.toFormat('yyyy-MM-dd')}}\n{{$now.toFormat('HH:mm:ss')}}\n{{$now.plus({days: 7})}}\n```\n\n### $env - Environment Variables\n\nAccess environment variables:\n\n```javascript\n{{$env.API_KEY}}\n{{$env.DATABASE_URL}}\n```\n\n---\n\n## 🚨 CRITICAL: Webhook Data Structure\n\n**Most Common Mistake**: Webhook data is **NOT** at the root!\n\n### Webhook Node Output Structure\n\n```javascript\n{\n  \"headers\": {...},\n  \"params\": {...},\n  \"query\": {...},\n  \"body\": {           \u002F\u002F ⚠️ USER DATA IS HERE!\n    \"name\": \"John\",\n    \"email\": \"john@example.com\",\n    \"message\": \"Hello\"\n  }\n}\n```\n\n### Correct Webhook Data Access\n\n```javascript\n❌ WRONG: {{$json.name}}\n❌ WRONG: {{$json.email}}\n\n✅ CORRECT: {{$json.body.name}}\n✅ CORRECT: {{$json.body.email}}\n✅ CORRECT: {{$json.body.message}}\n```\n\n**Why**: Webhook node wraps incoming data under `.body` property to preserve headers, params, and query parameters.\n\n---\n\n## Common Patterns\n\n### Access Nested Fields\n\n```javascript\n\u002F\u002F Simple nesting\n{{$json.user.email}}\n\n\u002F\u002F Array access\n{{$json.data[0].name}}\n{{$json.items[0].id}}\n\n\u002F\u002F Bracket notation for spaces\n{{$json['field name']}}\n{{$json['user data']['first name']}}\n```\n\n### Reference Other Nodes\n\n```javascript\n\u002F\u002F Node without spaces\n{{$node[\"Set\"].json.value}}\n\n\u002F\u002F Node with spaces (common!)\n{{$node[\"HTTP Request\"].json.data}}\n{{$node[\"Respond to Webhook\"].json.message}}\n\n\u002F\u002F Webhook node\n{{$node[\"Webhook\"].json.body.email}}\n```\n\n### Combine Variables\n\n```javascript\n\u002F\u002F Concatenation (automatic)\nHello {{$json.body.name}}!\n\n\u002F\u002F In URLs\nhttps:\u002F\u002Fapi.example.com\u002Fusers\u002F{{$json.body.user_id}}\n\n\u002F\u002F In object properties\n{\n  \"name\": \"={{$json.body.name}}\",\n  \"email\": \"={{$json.body.email}}\"\n}\n```\n\n---\n\n## When NOT to Use Expressions\n\n### ❌ Code Nodes\n\nCode nodes use **direct JavaScript access**, NOT expressions!\n\n```javascript\n\u002F\u002F ❌ WRONG in Code node\nconst email = '={{$json.email}}';\nconst name = '{{$json.body.name}}';\n\n\u002F\u002F ✅ CORRECT in Code node\nconst email = $json.email;\nconst name = $json.body.name;\n\n\u002F\u002F Or using Code node API\nconst email = $input.item.json.email;\nconst allItems = $input.all();\n```\n\n### ❌ Webhook Paths\n\n```javascript\n\u002F\u002F ❌ WRONG\npath: \"{{$json.user_id}}\u002Fwebhook\"\n\n\u002F\u002F ✅ CORRECT\npath: \"user-webhook\"  \u002F\u002F Static paths only\n```\n\n### ❌ Credential Fields\n\n```javascript\n\u002F\u002F ❌ WRONG\napiKey: \"={{$env.API_KEY}}\"\n\n\u002F\u002F ✅ CORRECT\nUse n8n credential system, not expressions\n```\n\n---\n\n## Validation Rules\n\n### 1. Always Use {{}}\n\nExpressions **must** be wrapped in double curly braces.\n\n```javascript\n❌ $json.field\n✅ {{$json.field}}\n```\n\n### 2. Use Quotes for Spaces\n\nField or node names with spaces require **bracket notation**:\n\n```javascript\n❌ {{$json.field name}}\n✅ {{$json['field name']}}\n\n❌ {{$node.HTTP Request.json}}\n✅ {{$node[\"HTTP Request\"].json}}\n```\n\n### 3. Match Exact Node Names\n\nNode references are **case-sensitive**:\n\n```javascript\n❌ {{$node[\"http request\"].json}}  \u002F\u002F lowercase\n❌ {{$node[\"Http Request\"].json}}  \u002F\u002F wrong case\n✅ {{$node[\"HTTP Request\"].json}}  \u002F\u002F exact match\n```\n\n### 4. No Nested {{}}\n\nDon't double-wrap expressions:\n\n```javascript\n❌ {{{$json.field}}}\n✅ {{$json.field}}\n```\n\n---\n\n## Common Mistakes\n\nFor complete error catalog with fixes, see COMMON_MISTAKES.md\n\n### Quick Fixes\n\n| Mistake | Fix |\n|---------|-----|\n| `$json.field` | `{{$json.field}}` |\n| `{{$json.field name}}` | `{{$json['field name']}}` |\n| `{{$node.HTTP Request}}` | `{{$node[\"HTTP Request\"]}}` |\n| `{{{$json.field}}}` | `{{$json.field}}` |\n| `{{$json.name}}` (webhook) | `{{$json.body.name}}` |\n| `'={{$json.email}}'` (Code node) | `$json.email` |\n\n---\n\n## Working Examples\n\nFor real workflow examples, see EXAMPLES.md\n\n### Example 1: Webhook to Slack\n\n**Webhook receives**:\n```json\n{\n  \"body\": {\n    \"name\": \"John Doe\",\n    \"email\": \"john@example.com\",\n    \"message\": \"Hello!\"\n  }\n}\n```\n\n**In Slack node text field**:\n```\nNew form submission!\n\nName: {{$json.body.name}}\nEmail: {{$json.body.email}}\nMessage: {{$json.body.message}}\n```\n\n### Example 2: HTTP Request to Email\n\n**HTTP Request returns**:\n```json\n{\n  \"data\": {\n    \"items\": [\n      {\"name\": \"Product 1\", \"price\": 29.99}\n    ]\n  }\n}\n```\n\n**In Email node** (reference HTTP Request):\n```\nProduct: {{$node[\"HTTP Request\"].json.data.items[0].name}}\nPrice: ${{$node[\"HTTP Request\"].json.data.items[0].price}}\n```\n\n### Example 3: Format Timestamp\n\n```javascript\n\u002F\u002F Current date\n{{$now.toFormat('yyyy-MM-dd')}}\n\u002F\u002F Result: 2025-10-20\n\n\u002F\u002F Time\n{{$now.toFormat('HH:mm:ss')}}\n\u002F\u002F Result: 14:30:45\n\n\u002F\u002F Full datetime\n{{$now.toFormat('yyyy-MM-dd HH:mm')}}\n\u002F\u002F Result: 2025-10-20 14:30\n```\n\n---\n\n## Data Type Handling\n\n### Arrays\n\n```javascript\n\u002F\u002F First item\n{{$json.users[0].email}}\n\n\u002F\u002F Array length\n{{$json.users.length}}\n\n\u002F\u002F Last item\n{{$json.users[$json.users.length - 1].name}}\n```\n\n### Objects\n\n```javascript\n\u002F\u002F Dot notation (no spaces)\n{{$json.user.email}}\n\n\u002F\u002F Bracket notation (with spaces or dynamic)\n{{$json['user data'].email}}\n```\n\n### Strings\n\n```javascript\n\u002F\u002F Concatenation (automatic)\nHello {{$json.name}}!\n\n\u002F\u002F String methods\n{{$json.email.toLowerCase()}}\n{{$json.name.toUpperCase()}}\n```\n\n### Numbers\n\n```javascript\n\u002F\u002F Direct use\n{{$json.price}}\n\n\u002F\u002F Math operations\n{{$json.price * 1.1}}  \u002F\u002F Add 10%\n{{$json.quantity + 5}}\n```\n\n---\n\n## Advanced Patterns\n\n### Conditional Content\n\n```javascript\n\u002F\u002F Ternary operator\n{{$json.status === 'active' ? 'Active User' : 'Inactive User'}}\n\n\u002F\u002F Default values\n{{$json.email || 'no-email@example.com'}}\n```\n\n### Date Manipulation\n\n```javascript\n\u002F\u002F Add days\n{{$now.plus({days: 7}).toFormat('yyyy-MM-dd')}}\n\n\u002F\u002F Subtract hours\n{{$now.minus({hours: 24}).toISO()}}\n\n\u002F\u002F Set specific date\n{{DateTime.fromISO('2025-12-25').toFormat('MMMM dd, yyyy')}}\n```\n\n### String Manipulation\n\n```javascript\n\u002F\u002F Substring\n{{$json.email.substring(0, 5)}}\n\n\u002F\u002F Replace\n{{$json.message.replace('old', 'new')}}\n\n\u002F\u002F Split and join\n{{$json.tags.split(',').join(', ')}}\n```\n\n---\n\n## Debugging Expressions\n\n### Test in Expression Editor\n\n1. Click field with expression\n2. Open expression editor (click \"fx\" icon)\n3. See live preview of result\n4. Check for errors highlighted in red\n\n### Common Error Messages\n\n**\"Cannot read property 'X' of undefined\"**\n→ Parent object doesn't exist\n→ Check your data path\n\n**\"X is not a function\"**\n→ Trying to call method on non-function\n→ Check variable type\n\n**Expression shows as literal text**\n→ Missing {{ }}\n→ Add curly braces\n\n---\n\n## Expression Helpers\n\n### Available Methods\n\n**String**:\n- `.toLowerCase()`, `.toUpperCase()`\n- `.trim()`, `.replace()`, `.substring()`\n- `.split()`, `.includes()`\n\n**Array**:\n- `.length`, `.map()`, `.filter()`\n- `.find()`, `.join()`, `.slice()`\n\n**DateTime** (Luxon):\n- `.toFormat()`, `.toISO()`, `.toLocal()`\n- `.plus()`, `.minus()`, `.set()`\n\n**Number**:\n- `.toFixed()`, `.toString()`\n- Math operations: `+`, `-`, `*`, `\u002F`, `%`\n\n---\n\n## Best Practices\n\n### ✅ Do\n\n- Always use {{ }} for dynamic content\n- Use bracket notation for field names with spaces\n- Reference webhook data from `.body`\n- Use $node for data from other nodes\n- Test expressions in expression editor\n\n### ❌ Don't\n\n- Don't use expressions in Code nodes\n- Don't forget quotes around node names with spaces\n- Don't double-wrap with extra {{ }}\n- Don't assume webhook data is at root (it's under .body!)\n- Don't use expressions in webhook paths or credentials\n\n---\n\n## Related Skills\n\n- **n8n MCP Tools Expert**: Learn how to validate expressions using MCP tools\n- **n8n Workflow Patterns**: See expressions in real workflow examples\n- **n8n Node Configuration**: Understand when expressions are needed\n\n---\n\n## Summary\n\n**Essential Rules**:\n1. Wrap expressions in {{ }}\n2. Webhook data is under `.body`\n3. No {{ }} in Code nodes\n4. Quote node names with spaces\n5. Node names are case-sensitive\n\n**Most Common Mistakes**:\n- Missing {{ }} → Add braces\n- `{{$json.name}}` in webhooks → Use `{{$json.body.name}}`\n- `{{$json.email}}` in Code → Use `$json.email`\n- `{{$node.HTTP Request}}` → Use `{{$node[\"HTTP Request\"]}}`\n\nFor more details, see:\n- COMMON_MISTAKES.md - Complete error catalog\n- EXAMPLES.md - Real workflow examples\n\n---\n\n**Need Help?** Reference the n8n expression documentation or use n8n-mcp validation tools to check your expressions.\n\n## Limitations\n- Use this skill only when the task clearly matches the scope described above.\n- Do not treat the output as a substitute for environment-specific validation, testing, or expert review.\n- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.\n","","imported","https:\u002F\u002Fgithub.com\u002Fsickn33\u002Fantigravity-awesome-skills","user_system_seed","SkillOPIC",true,104,922,"2026-05-16 13:30:13",{"id":8,"name":21,"slug":22,"icon":23,"description":24,"sort":25,"createdAt":26},"编程开发","coding","mdi-code-braces","代码生成、调试、审查，提升开发效率",2,"2026-05-16 12:53:40",{"id":7,"name":28,"slug":29,"icon":30,"description":31,"moduleId":8,"sort":25,"skillCount":32,"createdAt":26},"后端开发","backend","mdi-server","API、数据库、服务端架构",296,[34],{"id":35,"skillId":4,"version":36,"fileName":37,"fileSize":38,"filePath":39,"fileHash":40,"manifest":41,"createdAt":19},"bede1445-4ef3-491b-be97-f60107f5292a","1.0.0","n8n-expression-syntax.zip",3821,"uploads\u002Fskills\u002F59da939e-4801-487e-9e57-161f4eb2b31f\u002Fn8n-expression-syntax.zip","c5550949385926c296f1041215afe46f18e6385ca5050a54516f2bad5af3c8f0","[{\"path\":\"SKILL.md\",\"isDirectory\":false,\"size\":10133}]",{"code":43,"message":44,"data":45},200,"success",{"items":46,"stats":47,"page":50},[],{"averageRating":48,"totalRatings":48,"ratingCounts":49},0,[48,48,48,48,48],{"limit":51,"offset":48,"hasMore":52,"nextOffset":51,"ratedOnly":16},15,false]