Actions10
- Agent Chat Actions
- Browser Automation Actions
- Code Execution Actions
- File Processing Actions
- Memory Operation Actions
- Tool Execution Actions
Overview
The node enables execution of custom code snippets in different runtime environments, specifically Python, Node.js, or shell commands. It is designed to run user-provided code dynamically within workflows, making it useful for scenarios such as data processing, automation tasks, or integrating custom logic that is not natively supported by other nodes.
A practical example includes running a Python script to analyze data and return results directly within an n8n workflow, or executing shell commands to interact with the underlying system environment. The optional session ID allows maintaining state across multiple executions, which is beneficial for workflows requiring persistent context (e.g., iterative computations or multi-step scripts).
Properties
| Name | Meaning |
|---|---|
| Code | The actual code snippet to execute. Supports Python, Node.js, or shell commands depending on the runtime. |
| Runtime | The environment where the code will be executed. Options: Python, Node.js, Shell. |
| Session ID | Optional identifier to maintain execution context between runs, allowing variables and imports to persist. |
| Timeout (Seconds) | Maximum allowed execution time in seconds (1-300). Execution terminates if this limit is exceeded. |
Output
The node outputs the result of the executed code in the json field of the output data. This typically contains the standard output or any returned data from the code execution. If the code produces binary data (e.g., files or images), the node would handle it accordingly, but based on the provided information, the primary focus is on textual or structured JSON output representing the execution result.
Dependencies
- Requires an API key credential to authenticate requests to the Nerve Agent AI system.
- Depends on the external Nerve Agent service for code execution.
- The node configuration must include the base URL and API key for the Nerve Agent endpoint.
- No local runtime dependencies are needed since execution happens remotely via the Nerve Agent platform.
Troubleshooting
- Timeout Errors: If the code takes longer than the specified timeout, execution will be terminated. Increase the timeout value if necessary, but keep it within the 1-300 seconds range.
- Invalid Code Syntax: Errors may occur if the provided code has syntax errors or unsupported commands for the selected runtime. Validate code before execution.
- Session Issues: Using a session ID incorrectly (e.g., reusing IDs unintentionally) might cause unexpected persistence of variables or imports. Use unique session IDs when isolation is required.
- Authentication Failures: Ensure the API key credential is correctly configured and valid; otherwise, the node will fail to connect to the Nerve Agent service.
Links and References
- Nerve Agent Documentation (hypothetical link for reference)
- Python official documentation: https://docs.python.org/3/
- Node.js official documentation: https://nodejs.org/en/docs/
- Shell scripting basics: https://tldp.org/LDP/Bash-Beginners-Guide/html/