n8n-code-javascript

Write JavaScript code for n8n Code nodes with data access patterns and built-in functions.

45|20|Updated Aug 31, 2024
One-click install
npx skills add https://github.com/richardadonnell/Upwork-Job-Scraper --skill n8n-code-javascript-richardadonnell
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: n8n-code-javascript
Source: https://github.com/richardadonnell/Upwork-Job-Scraper/tree/main/.agents/skills/n8n-code-javascript
Command: npx skills add https://github.com/richardadonnell/Upwork-Job-Scraper --skill n8n-code-javascript-richardadonnell

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) and assets (resource) components.

What problem does it solve?

This Skill empowers you to write effective JavaScript code within n8n Code nodes, enabling complex data transformations, custom logic, and seamless integration with APIs.

Core Features & Use Cases

  • Write JavaScript: Learn the syntax, data access patterns ($input, $json, $node), and return formats required for n8n Code nodes.
  • Avoid Errors: Understand and prevent the top 5 common Code node errors, including webhook data handling and null checks.
  • Use Built-ins: Leverage powerful functions like $helpers.httpRequest(), DateTime (Luxon), and $jmespath() for API calls, date manipulation, and JSON querying.
  • Use Case: Transform raw webhook data into a structured format suitable for a CRM API, including custom calculations and error handling.

Quick Start

Use the n8n-code-javascript skill to write a JavaScript function that takes an array of user objects and returns only the active users, formatted as [{json: {id, name}}].

Frequently Asked Questions about n8n-code-javascript

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write JavaScript in an n8n Code node to transform webhook data?

Writing JavaScript in an n8n Code node requires accessing webhook data via $input or $json patterns, applying custom transformations, and returning arrays like [{json: {id, name}}] to ensure correct downstream workflow execution.

What is the correct return format for n8n Code nodes?

The correct return format for n8n Code nodes is an array of objects structured as [{json: {id, name}}]. Using this specific format ensures your custom JavaScript logic passes data seamlessly to subsequent workflow nodes without structural errors.

Why does my n8n Code node fail when handling nested webhook data?

n8n Code node failures with nested webhook data often stem from incorrect data access syntax or missing null checks. Properly referencing $json and validating webhook payloads before processing prevents these common structural and null reference errors.

Can I use built-in functions like $helpers.httpRequest() and $jmespath() in n8n Code nodes?

Yes, you can use built-in functions in n8n Code nodes. Leverage $helpers.httpRequest() for API integration, $jmespath() for JSON querying, and DateTime (Luxon) for date manipulation to execute complex operations without external dependencies.

What is the best way to avoid common errors in n8n JavaScript Code nodes?

The best way to avoid common errors in n8n JavaScript Code nodes is to understand the top 5 pitfalls, including webhook data nesting and expression syntax confusion, by applying correct data access patterns and enforcing strict null checks.