Key Concepts
- Code Node: A powerful node within NA10 that allows users to write custom instructions using JavaScript or Python, enabling more complex automations and agent capabilities.
- Input/Output: Understanding how data enters (
$input.all,$input.json) and exits (return) the code node is crucial for its effective use. - Built-in Helpers: NA10 provides pre-defined functions and variables (e.g.,
$helpers.http_request,$now,$environment_variables) to simplify common tasks within the code node. - AI Assistance: Tools like ChatGPT can be leveraged to generate code for the code node, making it accessible even to non-programmers.
- When to Use Code Node: For processing large datasets, handling specific API functionalities not covered by built-in nodes, and extracting complex nested JSON.
- When NOT to Use Code Node: For simple conditional logic (if/else), field manipulation (edit fields), basic filtering, merging, aggregation, sorting, splitting, HTTP requests (using the dedicated node), date/time operations, waiting, and simple loops.
- Hostinger: A recommended platform for hosting NA10 agents, offering VPS solutions for scalability and reliability.
The Power and Accessibility of the NA10 Code Node
The NA10 code node is identified as the single most powerful node within the platform, capable of significantly accelerating workflows, simplifying automations, building more robust agents, and unlocking the full potential of custom code. Despite its power, a significant barrier exists: 99% of users avoid it due to fear, even though professional development skills are not a prerequisite. This video aims to demystify the code node for beginners.
Understanding the Code Node
The code node is a specific node that can be inserted into any NA10 workflow. It supports two primary programming languages: JavaScript and Python. Upon insertion, NA10 provides pre-written code that serves as a starting point.
The primary use case for the code node arises when a specific, unique task is required that is not covered by NA10's existing pre-made nodes, which already offer extensive logic, mathematical operations, and conditional branching.
Input and Output Processing
Every code node in NA10 follows a fundamental pattern for data processing:
- Input: Data entering the node is accessed via
$input.all(for all items from the previous node) or$input.json(for the current item's data). This data is typically saved into a variable for manipulation. - Processing: The code within the node performs custom instructions on the input data.
- Output: Processed data is sent to the next node using a
returnstatement. This is analogous to a function in programming, where data is received, processed, and then returned. The syntax for returning data isreturn { json: { your_variable_name: your_data } };. - Comments: Double slashes (
//) in JavaScript and hashtags (#) in Python are used for comments, which are essential for making code understandable to humans.
Built-in Helpers and Variables
NA10 enhances the code node's functionality with a suite of predefined helpers and variables, accessible by typing $:
$helpers.http_request: Enables making API calls to external services.$helpers.http_request_with_authentication: Facilitates API calls using saved credentials within NA10 (e.g., for Google Drive, Telegram).$node_name.all(or$node_name.json): Allows access to data from a specific previous node, not just the immediately preceding one. For example,$HTTPRequest.allwould retrieve data from a node named "HTTPRequest".$json: A shortcut to access the current item's data.$now: Retrieves the current date and time, usable in prompts and within the code node.$today: Similar to$now, but without the time component.$workflow: Provides information about the current workflow, such as its name or ID.$execution: Contains information about the current execution of the workflow.$environment_variables: Accesses environment-specific variables.
Practical Examples of Code Node Usage
The video presents four specific scenarios where the code node proves invaluable:
-
Grouping Orders: For processing large volumes of unstructured or chaotically structured data (e.g., 1,000 orders), the code node can efficiently group orders by customer and calculate total spending. This is a task that standard NA10 nodes struggle with, especially when combining grouping and calculation. A simple code snippet can transform chaotic data into clear summaries like "John spent $45." This is particularly useful for feeding into AI agent prompts.
-
Extending Built-in Node Functionality (WordPress Example): When a pre-built node, like the WordPress node, lacks a specific capability (e.g., media upload, only handling text content), the code node can bridge this gap. A short JavaScript snippet can enable media uploads, overcoming limitations that would otherwise halt an automation.
-
Advanced API Utilization (Stripe Example): Built-in nodes often have simplified filtering. The code node allows for more granular control, such as searching Stripe subscriptions by multiple specific conditions (e.g., active and on a premium plan) and setting hard limits on results, which the standard Stripe node cannot do. This is crucial for detailed data analysis.
-
Extracting and Parsing Nested JSON: Standard nodes like "Edit Fields" cannot deeply navigate complex, nested JSON structures from API responses. The code node excels at traversing multiple layers of arrays and objects to extract precise values, often with surprisingly concise code (e.g., 9-15 lines).
AI-Assisted Code Generation (Shopify Example)
The process of using AI for code generation is demonstrated with a Shopify order scenario. By describing the desired outcome to ChatGPT (e.g., "find orders where someone bought a large blue t-shirt"), and specifying the input data structure, AI can generate the necessary NA10 code node. This is particularly relevant with the rise of "Vite-coded" apps, where technical debt can be addressed by developers proficient in NA10 and its code node. The generated code, often under 50 lines, includes comments explaining its functionality, making it understandable and adaptable.
When NOT to Use the Code Node
While powerful, the code node should not be used when simpler, pre-built NA10 nodes suffice. Overusing the code node can lead to unnecessary complexity. Situations where dedicated nodes are preferable include:
- Simple If/Else Logic: The
If/Elsenode handles splitting workflows based on true/false conditions. - Field Manipulation: The
Edit Fieldsnode is designed for renaming, adding, or removing data fields (properties). - Simple Filtering: The
Filternode efficiently keeps items that meet specific criteria. - Merging Data: The
Mergenode combines data from parallel branches of a workflow. - Aggregation: The
Aggregatenode calculates or groups multiple items into a single summary item. - Sorting: The
Sortnode orders lists or arrays alphabetically, numerically, or randomly. - Splitting Items: The
Split Outnode separates a single item containing a list into multiple individual items. - HTTP Requests: The dedicated
HTTP Requestnode is highly capable of making API calls (GET, POST, PUT, DELETE) with custom headers, abstracting away the need for custom code. - Date and Time Operations: The
Date and Timenode handles formatting, adding/subtracting time, and calculating time differences. - Waiting/Delays: The
Waitnode is used for pausing workflows for specific durations or waiting for webhooks. - Simple Loops: The
Loop Over Itemsnode is designed to iterate through lists and perform actions on each item, negating the need for custom loop code.
Hosting NA10 Agents with Hostinger
For reliable execution of NA10 agents, especially those utilizing the code node, hosting is essential. Hostinger is recommended for its affordability and ease of use, offering Virtual Private Servers (VPS) that can host numerous agents. The KVN2 plan is suggested for most users. The setup process involves selecting a plan, server location, and operating system (NA10), followed by checkout and account creation. Hostinger provides a management panel for the VPS, including access to the NA10 server for managing agents. A discount code "David" is available for an additional 10% off.
Conclusion
The NA10 code node is a potent tool that democratizes advanced automation capabilities. By understanding its input/output mechanisms, leveraging built-in helpers, and utilizing AI for code generation, users can overcome the fear associated with coding and build significantly more powerful agents. However, it's crucial to recognize when simpler, dedicated nodes are more appropriate to maintain workflow clarity and efficiency. For robust agent deployment, Hostinger offers a scalable and user-friendly hosting solution.
AI summaries can miss context or contain errors. Check important details against the original video.





