### Start n8n After Installation Source: https://github.com/nithichotec/n8ndocs/blob/main/other_e_174.md Run n8n after it has been installed globally. You can use either the simple 'n8n' command or 'n8n start'. ```bash n8n # or n8n start ``` -------------------------------- ### Installing Dependencies (Shell) Source: https://github.com/nithichotec/n8ndocs/blob/main/other_n_674.md Installs all required project dependencies listed in the package.json file. This command should be run in the project's root directory after cloning or setting up the project. ```Shell npm i ``` -------------------------------- ### Install Project Dependencies (Shell) Source: https://github.com/nithichotec/n8ndocs/blob/main/other_n_684.md Installs the necessary project dependencies defined in the package.json file using the npm package manager. ```Shell npm i ``` -------------------------------- ### Starting n8n Webhook Processor (CLI) Source: https://github.com/nithichotec/n8ndocs/blob/main/other_s_369.md Command to start a dedicated n8n process for handling incoming webhooks from the root directory of the n8n installation. ```bash ./packages/cli/bin/n8n webhook ``` -------------------------------- ### Start n8n with Tunnel Enabled Source: https://github.com/nithichotec/n8ndocs/blob/main/other_e_174.md Start n8n and enable the tunnel feature, which allows you to expose your local n8n instance to the internet. ```bash n8n start --tunnel ``` -------------------------------- ### Try n8n without Installation (npx) Source: https://github.com/nithichotec/n8ndocs/blob/main/other_e_174.md Use npx to run n8n directly without a global installation. This command downloads necessary components and starts n8n, making it accessible via http://localhost:5678. ```bash npx n8n ``` -------------------------------- ### Define Assistant Instructions (Text) Source: https://github.com/nithichotec/n8ndocs/blob/main/other_s_1176.md This snippet provides an example of the system instructions used to define the assistant's persona and behavior. This field has a maximum length of 32,768 characters and guides how the model should respond. ```Text Always respond in a friendly and engaging manner. When a user asks a question, provide a concise answer first, followed by a brief explanation or additional context if necessary. If the question is open-ended, offer a suggestion or ask a clarifying question to guide the conversation. Keep the tone positive and supportive, and avoid technical jargon unless specifically requested by the user. ``` -------------------------------- ### Dockerfile for n8n Image Build Source: https://github.com/nithichotec/n8ndocs/blob/main/other_e_455.md Defines the steps to build an n8n Docker image. It starts from a Node.js Alpine base, installs system dependencies, sets up a non-root user, installs n8n globally, and adds necessary fonts. ```Dockerfile FROM node:16-alpine ARG N8N_VERSION RUN if [ -z "$N8N_VERSION" ] ; then echo "The N8N_VERSION argument is missing!" ; exit 1; fi # Update everything and install needed dependencies RUN apk add --update graphicsmagick tzdata git tini su-exec # Set a custom user to not have n8n run as root USER root # Install n8n and the packages it needs to build it correctly. RUN apk --update add --virtual build-dependencies python3 build-base ca-certificates && \ npm config set python "$(which python3)" && \ npm_config_user=root npm install -g full-icu n8n@${N8N_VERSION} && \ apk del build-dependencies \ && rm -rf /root /tmp/* /var/cache/apk/* && mkdir /root; # Install fonts RUN apk --no-cache add --virtual fonts msttcorefonts-installer fontconfig && \ update-ms-fonts && \ fc-cache -f && \ apk del fonts && \ find /usr/share/fonts/truetype/msttcorefonts/ -type l -exec unlink {} \; \ && rm -rf /root /tmp/* /var/cache/apk/* && mkdir /root ``` -------------------------------- ### Starting n8n Docker Compose Services (Bash) Source: https://github.com/nithichotec/n8ndocs/blob/main/other_y_24.md This command starts the n8n and Traefik services defined in the docker-compose.yml file in detached mode (-d), allowing them to run in the background. It assumes Docker Compose is installed and the configuration files are set up. ```bash sudo docker compose up -d ``` -------------------------------- ### Setting Node API Documentation URL - JavaScript Source: https://github.com/nithichotec/n8ndocs/blob/main/other_I_18.md Assigns an empty string as the documentation URL for the Node API example. ```JavaScript documentationUrl = ''; ``` -------------------------------- ### Install 'next' n8n Version Globally (npm) Source: https://github.com/nithichotec/n8ndocs/blob/main/other_e_174.md Install the 'next' development version of n8n globally using npm. ```bash npm install -g n8n@next ``` -------------------------------- ### Example LangChain Prompt Template Structure Source: https://github.com/nithichotec/n8ndocs/blob/main/other_n_425.md This snippet provides an example of a prompt template designed for an AI assistant using LangChain. It includes sections for defining available tools, incorporating format instructions from an output parser, and clearly marking the user's input using specific variables. ```Prompt Template TOOLS ------ Assistant can ask the user to use tools to look up information that may be helpful in answering the user's original question. The tools the human can use are: {tools} {format_instructions} USER'S INPUT -------------------- Here is the user's input (remember to respond with a markdown code snippet of a JSON blob with a single action, and NOTHING else): {{input}} ``` -------------------------------- ### n8n Workflow Definition (JSON) Source: https://github.com/nithichotec/n8ndocs/blob/main/other_e_135.md This JSON snippet defines a basic n8n workflow. It includes a Start node and a Merge node, detailing their parameters, types, IDs, and how they are connected. It serves as an example of how n8n workflows are structured programmatically. ```json { "nodes": [ { "parameters": {}, "name": "Start", "type": "n8n-nodes-base.start", "typeVersion": 1, "id": "a713338a-2148-429a-932d-290607520437", "credentials": {} }, { "parameters": { "options": {} }, "name": "Merge", "type": "n8n-nodes-base.merge", "typeVersion": 1, "id": "3884069a-444f-4272-801d-419204142957", "credentials": {} } ], "connections": { "Start": [ [ { "node": "Merge", "type": "main", "index": 0 } ] ], "Merge": [ [ { "node": "Merge", "type": "main", "index": 1 } ] ] }, "pinData": {} } ``` -------------------------------- ### Installing Dependencies with npm Source: https://github.com/nithichotec/n8ndocs/blob/main/other_u_4.md Installs project dependencies using npm. This command is typically run in the root directory of a Node.js project, such as the n8n node starter, to set up the development environment and make tools like the linter available. ```Shell npm install ``` -------------------------------- ### Example n8n Configuration File (JSON) Source: https://github.com/nithichotec/n8ndocs/blob/main/other_e_169.md An example of a JSON configuration file that can be used with n8n, showing how to set execution saving behavior and timezone. ```json { "executions": { "saveDataOnSuccess": "none" }, "generic": { "timezone": "Europe/Berlin" } } ``` -------------------------------- ### Example OpenAI Assistant Description (Plaintext) Source: https://github.com/nithichotec/n8ndocs/blob/main/app_langchain_134.md This text provides an example of the content that can be used for the 'Description' field when creating an OpenAI Assistant. It briefly outlines the assistant's general capabilities. ```plaintext A virtual assistant that helps users with daily tasks, including setting reminders, answering general questions, and providing quick information. ``` -------------------------------- ### Example Customer Data - JSON Source: https://github.com/nithichotec/n8ndocs/blob/main/other_a_10.md This JSON array represents example customer data records. Each object in the array is a single customer with properties like id, name, email, notes, country, and creation date. This data is typically generated by a 'Customer Datastore' node. ```json [ { "id": "23423532", "name": "Jay Gatsby", "email": "gatsby@west-egg.com", "notes": "Keeps asking about a green light??", "country": "US", "created": "1925-04-10" }, { "id": "23423533", "name": "José Arcadio Buendía", "email": "jab@macondo.co", "notes": "Lots of people named after him. Very confusing", "country": "CO", "created": "1967-05-05" }, ... ] ``` -------------------------------- ### Example OpenAI Assistant Instructions (Plaintext) Source: https://github.com/nithichotec/n8ndocs/blob/main/app_langchain_134.md This text provides an example of the system instructions used for the 'Instructions' field when creating an OpenAI Assistant. It defines the assistant's persona, response style, and interaction guidelines. ```plaintext Always respond in a friendly and engaging manner. When a user asks a question, provide a concise answer first, followed by a brief explanation or additional context if necessary. If the question is open-ended, offer a suggestion or ask a clarifying question to guide the conversation. Keep the tone positive and supportive, and avoid technical jargon unless specifically requested by the user. ``` -------------------------------- ### Start Docker Compose Services (Shell) Source: https://github.com/nithichotec/n8ndocs/blob/main/other_e_176.md Starts the services defined in the "docker-compose.yml" file in detached mode (-d). This command builds images if necessary, creates containers, and starts n8n and Caddy running in the background. ```shell docker compose up -d ``` -------------------------------- ### List MySQL Databases (SQL) Source: https://github.com/nithichotec/n8ndocs/blob/main/other_s_1948.md This SQL query lists all available databases on the MySQL server, useful for confirming the database name during credential setup. ```SQL SHOW DATABASES; ``` -------------------------------- ### Start n8n and Caddy with Docker Compose (Shell) Source: https://github.com/nithichotec/n8ndocs/blob/main/other_e_175.md Command to start the services defined in the `docker-compose.yml` file in detached mode (`-d`), running n8n and Caddy in the background. ```shell sudo docker compose up -d ``` -------------------------------- ### Specifying n8n User Folder Path with N8N_USER_FOLDER (bash) Source: https://github.com/nithichotec/n8ndocs/blob/main/other_y_22.md Overrides the default location where n8n stores user-specific data such as the encryption key, SQLite database, and tunnel ID. By default, this data is stored in a '.n8n' subfolder of the user who started n8n. The example sets the folder to '/home/jim/n8n'. ```bash export N8N_USER_FOLDER=/home/jim/n8n ``` -------------------------------- ### Calling n8n API with API Key (Shell) Source: https://github.com/nithichotec/n8ndocs/blob/main/other_s_175.md Demonstrates how to make a GET request to the n8n API using `curl`. It shows examples for both self-hosted and cloud instances, including how to pass the API key in the `X-N8N-API-KEY` header to retrieve active workflows. ```shell # For a self-hosted n8n instance curl -X 'GET' \ '://api/v/workflows?active=true' \ -H 'accept: application/json' \ -H 'X-N8N-API-KEY: ' # For n8n Cloud curl -X 'GET' \ '/api/v/workflows?active=true' \ -H 'accept: application/json' \ -H 'X-N8N-API-KEY: ' ``` -------------------------------- ### Verify Docker and Docker Compose Installation (Bash) Source: https://github.com/nithichotec/n8ndocs/blob/main/other_e_175.md Commands to check the installed versions of Docker and Docker Compose to confirm successful installation. ```bash docker --version docker compose version ``` -------------------------------- ### Defining Request Defaults and Operations in n8n Node (JavaScript) Source: https://github.com/nithichotec/n8ndocs/blob/main/other_e_431.md This snippet illustrates how to define default settings for API requests within an n8n node's configuration. It sets a base URL, default headers (Accept and Content-Type), and defines a 'Get' operation that maps to a specific GET request to the '/planetary/apod' endpoint. ```JavaScript // Other node info here requestDefaults: { baseURL: 'https://api.nasa.gov', url: '', httpHeaders: { Accept: 'application/json', 'Content-Type': 'application/json' }, }, properties: [ // Resources here { displayName: 'Operation', // Other operation details options: [ { name: 'Get', value: 'get', description: '', routing: { request: { method: 'GET', url: '/planetary/apod' } } } ] } ] } ``` -------------------------------- ### Installing n8n Globally via npm Source: https://github.com/nithichotec/n8ndocs/blob/main/other_e_398.md This command uses the npm package manager to install the n8n command-line interface globally on your system. A global installation allows you to run n8n from any directory in your terminal, which is necessary for testing custom nodes locally. ```Shell npm install n8n -g ``` -------------------------------- ### Setting Node API Display Name - JavaScript Source: https://github.com/nithichotec/n8ndocs/blob/main/other_I_18.md Assigns a human-readable name to the Node API example using a string literal. ```JavaScript displayName = 'Example Node API'; ``` -------------------------------- ### Install Docker and Docker Compose on Ubuntu (Bash) Source: https://github.com/nithichotec/n8ndocs/blob/main/other_e_175.md A sequence of bash commands to install Docker Engine, Docker CLI, containerd, Docker Buildx, and Docker Compose Plugin on an Ubuntu system, including removing old versions and setting up repositories. ```bash # Remove incompatible or out of date Docker implementations if they exist for pkg in docker.io docker-doc docker-compose docker-compose-v2 podman-docker containerd runc; do sudo apt-get remove $pkg; done # Install prereq packages sudo apt-get update sudo apt-get install ca-certificates curl # Download the repo signing key sudo install -m 0755 -d /etc/apt/keyrings sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc sudo chmod a+r /etc/apt/keyrings/docker.asc # Configure the repository echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu $(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}") stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null # Update and install Docker and Docker Compose sudo apt-get update sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin ``` -------------------------------- ### Example Input for AI Transform Node Source: https://github.com/nithichotec/n8ndocs/blob/main/core_aitransform_5.md This snippet shows an example of a natural language instruction provided as input to the n8n AI Transform node. It describes the desired transformation of data. ```Natural Language Convert 'languages' array to JSON (key, value) pairs. ``` -------------------------------- ### Update n8n to 'next' Version (npm) Source: https://github.com/nithichotec/n8ndocs/blob/main/other_e_174.md Update your globally installed n8n instance to the 'next' development version using npm. ```bash npm install -g n8n@next ``` -------------------------------- ### Defining Example Node Class (TypeScript) Source: https://github.com/nithichotec/n8ndocs/blob/main/other_e_449.md This snippet shows the initial declaration of a TypeScript class named `ExampleNode` which implements the `INodeType` interface, typically the starting point for defining a custom node in n8n. ```TypeScript export class ExampleNode implements INodeType { ``` -------------------------------- ### Configure Caddy Reverse Proxy for n8n with Custom Subdomain (Caddyfile) Source: https://github.com/nithichotec/n8ndocs/blob/main/other_e_175.md Another example Caddyfile configuration block demonstrating how to use a different subdomain (`automate.example.com`) to proxy requests to the n8n service. ```text automate.example.com { reverse_proxy n8n:5678 { flush_interval -1 } } ``` -------------------------------- ### Example Input Data Structure (JSON) Source: https://github.com/nithichotec/n8ndocs/blob/main/other_a_27.md This JSON snippet shows an example of an array of objects that might be received as input data in an n8n node. Each object contains 'id' and 'name' properties, which can then be mapped or accessed. ```json [ { "id": "23423532", "name": "Jay Gatsby" }, { "id": "23423533", "name": "José Arcadio Buendía" }, { "id": "23423534", "name": "Max Sendak" }, { "id": "23423535", "name": "Zaphod Beeblebrox" }, { "id": "23423536", "name": "Edmund Pevensie" } ] ``` -------------------------------- ### Install Specific n8n Version Globally (npm) Source: https://github.com/nithichotec/n8ndocs/blob/main/other_e_174.md Install or update to a specific version of n8n globally using npm by specifying the version number with the '@' syntax. ```bash npm install -g n8n@0.126.1 ``` -------------------------------- ### Install Docker Compose Plugin on Hetzner Cloud Source: https://github.com/nithichotec/n8ndocs/blob/main/other_e_176.md These commands update the package lists on the server and then install the Docker Compose plugin using apt. This is necessary because the default Hetzner Docker image does not include Docker Compose. ```shell apt update && apt -y upgrade apt install docker-compose-plugin ``` -------------------------------- ### Example Output Format (Non-ISO) Source: https://github.com/nithichotec/n8ndocs/blob/main/other_s_1550.md This snippet shows the structure of the output when the 'Output as ISO String' option is disabled. The time difference is broken down into separate fields for each selected unit. ```Text timeDifference years : 1 months : 3 days : 13 ``` -------------------------------- ### Update n8n to Latest Version (npm) Source: https://github.com/nithichotec/n8ndocs/blob/main/other_e_174.md Update your globally installed n8n instance to the latest stable version using npm. ```bash npm update -g n8n ``` -------------------------------- ### Install n8n Globally (npm) Source: https://github.com/nithichotec/n8ndocs/blob/main/other_e_174.md Install the latest stable version of n8n globally using npm. This makes the 'n8n' command available in your terminal. ```bash npm install n8n -g ``` -------------------------------- ### Example Data Structure JSON Source: https://github.com/nithichotec/n8ndocs/blob/main/other_a_28.md This JSON snippet shows a simple array containing an object with 'fruit' and 'color' keys, used as an example data structure for demonstrating data mapping concepts. ```JSON [ { "fruit": "apples", "color": "green" } ] ``` -------------------------------- ### Example Input Data for MySQL Query Source: https://github.com/nithichotec/n8ndocs/blob/main/other_d_349.md Example input data in JSON format, representing records with email, name, and age, used to demonstrate how to use query parameters in a MySQL query. ```js [ { "email": "alex@example.com", "name": "Alex", "age": 21 }, { "email": "jamie@example.com", "name": "Jamie", "age": 33 } ] ``` -------------------------------- ### Ignore a Directory (Anymatch/Shell) Source: https://github.com/nithichotec/n8ndocs/blob/main/other_s_1630.md Example demonstrating the Anymatch syntax to ignore an entire directory and all its contents within the watched structure. The pattern matches any directory with the given name anywhere in the path. ```Shell **//** # For example, **/myDirectory/** ``` -------------------------------- ### Providing Google OAuth Scopes in n8n Source: https://github.com/nithichotec/n8ndocs/blob/main/core_youtube_3.md This snippet shows an example of how to enter multiple Google OAuth scopes when configuring the credential in n8n. Scopes should be provided as a space-separated list. ```Text https://www.googleapis.com/auth/gmail.labels https://www.googleapis.com/auth/gmail.addons.current.action.compose ``` -------------------------------- ### Calling $fromAI with only key parameter (simplified) Source: https://github.com/nithichotec/n8ndocs/blob/main/app_langchain_73.md A simplified example demonstrating the $fromAI() function call using only the required 'key' parameter, similar to the first snippet but presented as an alternative to the full parameter example. ```JavaScript $fromAI("name") ``` -------------------------------- ### Example Workflow Output Data (JSON) Source: https://github.com/nithichotec/n8ndocs/blob/main/other_a_26.md This JSON array represents example output data from a preceding node in a workflow. Each object in the array contains an 'id' and a 'name' property, demonstrating a common structure for list-based data in workflow automation platforms. ```json [ { "id": "23423532", "name": "Jay Gatsby" }, { "id": "23423533", "name": "José Arcadio Buendía" }, { "id": "23423534", "name": "Max Sendak" }, { "id": "23423535", "name": "Zaphod Beeblebrox" }, { "id": "23423536", "name": "Edmund Pevensie" } ] ``` -------------------------------- ### Specific Email Address Format Example Source: https://github.com/nithichotec/n8ndocs/blob/main/other_s_1677.md A specific example demonstrating the format for including a name with an email address, using 'Nathan Doe '. ```text Nathan Doe ``` -------------------------------- ### Accessing Binary Data Buffer - Example - JavaScript Source: https://github.com/nithichotec/n8ndocs/blob/main/other_a_13.md Provides a concrete example of using `getBinaryDataBuffer` to retrieve the binary data from the 'data' property of the first input item (index 0). ```JavaScript let binaryDataBufferItem = await this.helpers.getBinaryDataBuffer(0, 'data'); // Returns the data in the binary buffer for the first input item ``` -------------------------------- ### Email Address Format Example Source: https://github.com/nithichotec/n8ndocs/blob/main/other_s_1677.md Example format for including a name when specifying an email address in the 'From Email' or 'To Email' parameters. ```text Name Name ``` -------------------------------- ### Ignore a Single File (Anymatch/Shell) Source: https://github.com/nithichotec/n8ndocs/blob/main/other_s_1630.md Example demonstrating the Anymatch syntax to ignore a specific file within the watched directories. The pattern matches any file with the given name and suffix anywhere in the directory structure. ```Shell **/. # For example, **/myfile.txt ``` -------------------------------- ### Installing n8n Community Node - Shell Source: https://github.com/nithichotec/n8ndocs/blob/main/other_e_383.md Installs a community node package for n8n using npm. Replace `n8n-nodes-nodeName` with the actual package name of the node. ```Shell npm i n8n-nodes-nodeName ``` -------------------------------- ### Get MySQL Port (SQL) Source: https://github.com/nithichotec/n8ndocs/blob/main/other_s_1948.md This SQL query retrieves the port variable from the MySQL server, useful for confirming the port number during credential setup. ```SQL SHOW VARIABLES WHERE Variable_name = 'port'; ``` -------------------------------- ### Request Body for Creating Credentials (JSON) Source: https://github.com/nithichotec/n8ndocs/blob/main/other_s_332.md Provides an example of the JSON payload required in the request body when creating credentials via the n8n REST API. It includes the `name` for the credential and the `type` of credential being created (e.g., `airtableApi`). Note that the example is truncated. ```JSON { "name":"MyAirtable", "type":"airtableApi", } ``` -------------------------------- ### Get MySQL Hostname (SQL) Source: https://github.com/nithichotec/n8ndocs/blob/main/other_s_1948.md This SQL query retrieves the hostname variable from the MySQL server, useful for confirming the server address during credential setup. ```SQL SHOW VARIABLES WHERE Variable_name = 'hostname'; ``` -------------------------------- ### Configuring n8n Webhook URL with WEBHOOK_URL (bash) Source: https://github.com/nithichotec/n8ndocs/blob/main/other_y_22.md Manually sets the public webhook URL for n8n, which is necessary when running n8n behind a reverse proxy. This ensures n8n displays the correct URL in the UI and registers it properly with external services, overriding the default URL constructed from N8N_PROTOCOL, N8N_HOST, and N8N_PORT. The example sets the URL to 'https://n8n.example.com/'. ```bash export WEBHOOK_URL=https://n8n.example.com/ ``` -------------------------------- ### Starting n8n Container with Tunnel (Docker) Source: https://github.com/nithichotec/n8ndocs/blob/main/other_n_92.md Creates a Docker volume for data persistence and then starts a new n8n container, mapping port 5678, mounting the volume, and enabling the tunnel feature for external access. ```Shell docker volume create n8n_data docker run -it --rm \ --name n8n \ -p 5678:5678 \ -v n8n_data:/home/node/.n8n \ docker.n8n.io/n8nio/n8n --tunnel ``` -------------------------------- ### Configuring n8n Node Package.json Source: https://github.com/nithichotec/n8ndocs/blob/main/other_e_406.md This snippet shows a basic package.json structure for an n8n community node, including metadata, repository information, and the start of the n8n configuration block. ```JSON "n8n-community-node-package" ], "license": "MIT", "homepage": "https://n8n.io", "author": { "name": "Test", "email": "test@example.com" }, "repository": { "type": "git", // Change the git remote to your own repository // Add the new URL here "url": "git+" }, "main": "index.js", "scripts": { // don't change }, "files": [ "dist" ], // Link the credentials and node "n8n": { ``` -------------------------------- ### Example Input Data (Customer Records) Source: https://github.com/nithichotec/n8ndocs/blob/main/other_s_1683.md Sample input data structure, an array of customer objects, used to demonstrate creating dynamic JSON output using expressions. ```JSON [ { "id": "23423532", "name": "Jay Gatsby", "email": "gatsby@west-egg.com", "notes": "Keeps asking about a green light??", "country": "US", "created": "1925-04-10" }, { "id": "23423533", "name": "José Arcadio Buendía", "email": "jab@macondo.co", "notes": "Lots of people named after him. Very confusing", "country": "CO", "created": "1967-05-05" }, { "id": "23423534", "name": "Max Sendak", "email": "info@in-and-out-of-weeks.org", "notes": "Keeps rolling his terrible eyes", "country": "US", "created": "1963-04-09" }, { "id": "23423535", "name": "Zaphod Beeblebrox", "email": "captain@heartofgold.com", "notes": "Felt like I was talking to more than one person", "country": null, "created": "1979-10-12" }, { "id": "23423536", "name": "Edmund Pevensie", "email": "edmund@narnia.gov", "notes": "Passionate sailor", "country": "UK", "created": "1950-10-16" } ] ``` -------------------------------- ### Accessing n8n Docker Shell (sh) Source: https://github.com/nithichotec/n8ndocs/blob/main/other_s_2249.md This command accesses the shell of the n8n Docker container, allowing manual operations like installing community nodes. ```sh docker exec -it n8n sh ``` -------------------------------- ### Starting n8n Container with Volume Mount (Docker) Source: https://github.com/nithichotec/n8ndocs/blob/main/other_n_92.md Starts a new n8n Docker container, mapping port 5678 and mounting a named volume `n8n_data` to persist data. Uses the official n8n Docker image. ```Shell docker run -it --rm \ --name n8n \ -p 5678:5678 \ -v n8n_data:/home/node/.n8n \ docker.n8n.io/n8nio/n8n ``` -------------------------------- ### n8n Start Node Configuration (JSON) Source: https://github.com/nithichotec/n8ndocs/blob/main/core_start_1.md This JSON snippet configures a standard 'start' node in an n8n workflow. It defines the node type, version, and its position on the workflow canvas. ```JSON "type": "n8n-nodes-base.start", "typeVersion": 1, "position": [ 130, 640 ] ``` -------------------------------- ### Training Simple Neural Network (JavaScript) Source: https://github.com/nithichotec/n8ndocs/blob/main/other_d_546.md Shows how to create and train a basic neural network using the brain.js library in JavaScript. It demonstrates defining training data and running the trained network for prediction. Requires the brain.js library. ```JavaScript const brain = require('brain.js'); // Create a simple neural network const net = new brain.NeuralNetwork(); // Train the network with some data net.train([ { input: [0, 0], output: [0] }, { input: [0, 1], output: [1] }, { input: [1, 0], output: [1] }, { input: [1, 1], output: [0] } ]); // Test the network const output = net.run([1, 0]); console.log(`Output for [1, 0]: ${output[0]}`); ``` -------------------------------- ### Valid Single-line JavaScript Expression in n8n (JS) Source: https://github.com/nithichotec/n8ndocs/blob/main/other_n_19.md Provides a valid n8n expression that calculates the difference between two dates in months using the Luxon library. This example demonstrates how to condense logic into a single line suitable for n8n expressions, contrasting with multi-line examples. ```js {{DateTime.fromISO('2017-03-13').diff(DateTime.fromISO('2017-02-13'), 'months').toObject()}} ``` -------------------------------- ### Training Linear Regression Model (Python) Source: https://github.com/nithichotec/n8ndocs/blob/main/other_d_546.md Demonstrates how to create, train, and use a simple linear regression model using the scikit-learn library in Python. It shows data preparation, model fitting, and making a prediction. Requires scikit-learn and numpy. ```Python import sklearn from sklearn.linear_model import LinearRegression import numpy as np # Sample data X = np.array([[1], [2], [3], [4]]) y = np.array([2, 4, 5, 4]) # Create and train the model model = LinearRegression() model.fit(X, y) # Predict prediction = model.predict([[5]]) print(f"Prediction for 5: {prediction[0]}") ``` -------------------------------- ### Querying n8n API for Workflows with Pagination (First Page) Source: https://github.com/nithichotec/n8ndocs/blob/main/core_n8n_1.md Demonstrates how to fetch the first page of active workflows from the n8n API using curl, specifying a custom limit (150). Includes examples for both self-hosted and n8n Cloud instances, requiring an API key. ```shell # For a self-hosted n8n instance curl -X 'GET' \ '://api/v/workflows?active=true&limit=150' \ -H 'accept: application/json' \ -H 'X-N8N-API-KEY: ' ``` ```shell # For n8n Cloud curl -X 'GET' \ '/api/v/workflows?active=true&limit=150' \ -H 'accept: application/json' \ -H 'X-N8N-API-KEY: ' ``` -------------------------------- ### Example n8n Workflow Structure (JSON) Source: https://github.com/nithichotec/n8ndocs/blob/main/other_s_304.md This JSON snippet defines the basic structure of an n8n workflow, including a 'Start' node and a 'Loop Over Items' node with their connections. It serves as a template for building more complex workflows. ```json { "nodes": [ { "parameters": {}, "name": "Start", "type": "n8n-nodes-base.start", "typeVersion": 1, "id": "a360578f-8727-404d-9f9c-7a93000a1234", "credentials": {}, "data": {}, "executeOnStartup": false, "meta": {}, "webhookId": null, "settings": {} }, { "parameters": {}, "name": "Loop Over Items", "type": "main", "index": 0 } ], "connections": [ [ { "node": "Loop Over Items", "type": "main", "index": 0 } ] ] } ``` -------------------------------- ### List All Cluster Nodes Python Source: https://github.com/nithichotec/n8ndocs/blob/main/other_d_454.md This Python function simulates fetching a list of all cluster nodes via an API call using the `requests` library. It makes a GET request and returns the response parsed as JSON. This requires the `requests` library to be installed. ```python # Another Python example import requests def list_all_nodes(): # Assume API call to list nodes response = requests.get('/api/nodes') return response.json() ``` -------------------------------- ### Get SQL Server Default Domain Name (SQL) Source: https://github.com/nithichotec/n8ndocs/blob/main/core_microsoftsql_4.md This SQL query retrieves the default domain name associated with the current SQL Server instance. It is used during the n8n credential setup to find the domain name if required for authentication. ```SQL SELECT DEFAULT_DOMAIN()[DomainName]; ``` -------------------------------- ### Initiating npm Package Uninstallation - Shell Source: https://github.com/nithichotec/n8ndocs/blob/main/other_e_383.md Starts the process of uninstalling an npm package. This command is typically followed by the name of the package to be removed. ```Shell npm uninstall ``` -------------------------------- ### Invalid Multi-line JavaScript Expression in n8n (JS) Source: https://github.com/nithichotec/n8ndocs/blob/main/other_n_19.md Shows an example of a multi-line JavaScript function intended to calculate the difference between two dates using the Luxon library. This code is presented as an invalid n8n expression because expressions are limited to a single line of JavaScript. ```js // This example is split over multiple lines for readability // It's still invalid when formatted as a single line {{ function example() { let end = DateTime.fromISO('2017-03-13'); let start = DateTime.fromISO('2017-02-13'); let diffInMonths = end.diff(start, 'months'); return diffInMonths.toObject(); } example(); }} ``` -------------------------------- ### Start n8n Worker Process via CLI (Bash) Source: https://github.com/nithichotec/n8ndocs/blob/main/other_e_180.md Starts an n8n worker process using the command-line interface. This command should be run from the n8n root directory and is used to launch worker nodes that connect to the main n8n instance and Redis for executing workflows. ```bash ./packages/cli/bin/n8n worker ``` -------------------------------- ### Examples of Webhook URL Paths with Parameters Source: https://github.com/nithichotec/n8ndocs/blob/main/other_s_1793.md Illustrates various formats for specifying custom webhook URL paths in n8n, including how to incorporate single or multiple route parameters. ```URL Path /:variable ``` ```URL Path /path/:variable ``` ```URL Path /:variable/path ``` ```URL Path /:variable1/path/:variable2 ``` ```URL Path /:variable1/:variable2 ``` -------------------------------- ### Specify npm Package Version for Installation Source: https://github.com/nithichotec/n8ndocs/blob/main/other_e_378.md This snippet shows the exact package name and version string to enter when prompted during an npm installation process to install version 2.3 of the 'n8n-node-storms' package. ```shell n8n-node-storms@2.3 ``` -------------------------------- ### Configuring Generic Basic Authentication in n8n Source: https://github.com/nithichotec/n8ndocs/blob/main/other_n_557.md Provides an example of the format used for Basic Authentication, typically sent in the Authorization header of an HTTP request, requiring a username and password. ```Generic API Example Header: Authorization Value: Basic base64(username:password) ``` -------------------------------- ### Adding curl to n8n Docker Image (Dockerfile) Source: https://github.com/nithichotec/n8ndocs/blob/main/other_e_302.md This Dockerfile snippet defines the steps to extend the default n8n Docker image by installing the `curl` package. It starts from the base n8n image, switches to the root user to run the `apk` command to add `curl`, and then switches back to the `node` user. ```Dockerfile FROM docker.n8n.io/n8nio/n8n USER root RUN apk --update add curl USER node ``` -------------------------------- ### Example Input Data for Multiple Matches - JSON Source: https://github.com/nithichotec/n8ndocs/blob/main/other_r_58.md Sample JSON data representing two identical input datasets used to demonstrate how the 'Multiple Matches' option affects the comparison result when duplicate items exist. ```json [ { "fruit": { "type": "apple", "color": "red" } }, { "fruit": { "type": "apple", "color": "red" } }, { "fruit": { "type": "banana", "color": "yellow" } } ] // Input 2 [ { "fruit": { "type": "apple", "color": "red" } }, { "fruit": { "type": "apple", "color": "red" } }, { "fruit": { "type": "banana", "color": "yellow" } } ] ``` -------------------------------- ### Specify n8n Node Package Name for Installation Source: https://github.com/nithichotec/n8ndocs/blob/main/other_e_377.md Instructs the user to enter the exact npm package name for the desired n8n node into the specified input field during installation. This name identifies the package to be downloaded and installed. ```Text n8n-nodes-storms ``` -------------------------------- ### Creating Docker Volume for n8n Data Source: https://github.com/nithichotec/n8ndocs/blob/main/other_n_89.md Creates a Docker volume named 'n8n_data'. This volume is used to persist n8n's data, ensuring it is not lost when the Docker container is stopped or removed. ```Shell docker volume create n8n_data ``` -------------------------------- ### Querying n8n API for Workflows with Pagination (Next Page) Source: https://github.com/nithichotec/n8ndocs/blob/main/core_n8n_1.md Shows how to fetch the next page of results from the n8n API using curl by including the 'cursor' parameter obtained from the previous response. Examples are provided for both self-hosted and n8n Cloud. ```bash # For a self-hosted n8n instance curl -X 'GET' \ '://api/v/workflows?active=true&limit=150&cursor=MTIzZTQ1NjctZTg5Yi0xMmQzLWE0NTYtNDI2NjE0MTc0MDA' \ -H 'accept: application/json' ``` ```bash # For n8n Cloud curl -X 'GET' \ '/api/v/workflows?active=true&limit=150&cursor=MTIzZTQ1NjctZTg5Yi0xMmQzLWE0NTYtNDI2NjE0MTc0MDA' \ -H 'accept: application/json' ``` -------------------------------- ### Example Object in JSON Source: https://github.com/nithichotec/n8ndocs/blob/main/other_s_259.md Illustrates a simple object with 'name' and 'color' properties, demonstrating the key-value pair structure that forms the elements within the array of objects. ```json { name: 'Michelangelo', color: 'blue', } ``` -------------------------------- ### JavaScript Requirement Comment Source: https://github.com/nithichotec/n8ndocs/blob/main/other_s_2269.md A single-line comment in JavaScript explaining that a specific keyword is mandatory for community nodes. ```JavaScript // This keyword is required for community nodes ``` -------------------------------- ### Providing Sample Data in n8n Code Node (JavaScript) Source: https://github.com/nithichotec/n8ndocs/blob/main/other_t_133.md This JavaScript snippet generates a static list of sample data records, formatted as an array of objects, suitable for processing in subsequent nodes in an n8n workflow. It includes example data with potential duplicates and commented-out entries. It is intended to be used in an n8n Code node configured to 'Run Once for Each Item'. ```javascript let data =[]; return { data: [ { id: 1, name: 'Taylor Swift', job: 'Pop star', last_updated: '2024-09-20T10:12:43.493Z' }, { id: 2, name: 'Ed Sheeran', job: 'Singer-songwriter', last_updated: '2024-10-05T08:30:59.493Z' }, { id: 3, name: 'Adele', job: 'Singer-songwriter', last_updated: '2024-10-07T14:15:59.493Z' }, { id: 4, name: 'Bruno Mars', job: 'Singer-songwriter', last_updated: '2024-08-25T17:45:12.493Z' }, { id: 1, name: 'Taylor Swift', job: 'Pop star', last_updated: '2024-09-20T10:12:43.493Z' }, // duplicate { id: 5, name: 'Billie Eilish', job: 'Singer-songwriter', last_updated: '2024-09-10T09:30:12.493Z' }, { id: 6, name: 'Katy Perry', job: 'Pop star', last_updated: '2024-10-08T12:30:45.493Z' }, { id: 2, name: 'Ed Sheeran', job: 'Singer-songwriter', last_updated: '2024-10-05T08:30:59.493Z' }, // duplicate { id: 7, name: 'Lady Gaga', job: 'Pop star', last_updated: '2024-09-15T14:45:30.493Z' }, { id: 8, name: 'Rihanna', job: 'Pop star', last_updated: '2024-10-01T11:50:22.493Z' }, { id: 3, name: 'Adele', job: 'Singer-songwriter', last_updated: '2024-10-07T14:15:59.493Z' }, // duplicate //{ id: 9, name: 'Tom Hanks', job: 'Actor', last_updated: '2024-10-17T13:58:31.493Z' }, //{ id: 0, name: 'Madonna', job: 'Pop star', last_updated: '2024-10-17T17:11:38.493Z' }, //{ id: 15, name: 'Bob Dylan', job: 'Folk singer', last_updated: '2024-09-24T08:03:16.493Z'}, //{ id: 10, name: 'Harry Nilsson', job: 'Singer-songwriter', last_updated: '2020-10-17T17:11:38.493Z' }, //{ id: 11, name: 'Kylie Minogue', job: 'Pop star', last_updated: '2024-10-24T08:03:16.493Z'}, ] } ``` -------------------------------- ### Install Specific n8n Node Package Version - Shell Source: https://github.com/nithichotec/n8ndocs/blob/main/other_0_8.md Installs the specified version (2.1.0) of the 'n8n-nodes-nodeName' package using the npm package manager. This command is typically run in a terminal within your n8n installation directory or a project using n8n. ```Shell npm install n8n-nodes-nodeName@2.1.0 ``` -------------------------------- ### Example URL with Pre-populated Fields (URL) Source: https://github.com/nithichotec/n8ndocs/blob/main/core_form_8.md This URL demonstrates how to set initial values for the 'email' and 'name' fields in an n8n form using query parameters. It shows percent-encoding for the '@' symbol (%40) in the email and the space character (%20) in the name. ```URL https://my-account.n8n.cloud/form/my-form?email=jane.doe%40example.com&name=Jane%20Doe ``` -------------------------------- ### Specify n8n Node Type (JavaScript) Source: https://github.com/nithichotec/n8ndocs/blob/main/core_FriendGrid_1.md This line of code specifies the type of n8n node being referenced or configured. It indicates that the node is 'FriendGrid' and belongs to the 'n8n-nodes-base' package. ```JavaScript "node": "n8n-nodes-base.FriendGrid", ``` -------------------------------- ### Retrieve Notion Block Content via HTTP Request (URL) Source: https://github.com/nithichotec/n8ndocs/blob/main/core_httprequest_23.md This snippet shows the URL structure for making a GET request to the Notion API to retrieve a specific block's content. It demonstrates using a placeholder for the block ID and an example using an n8n expression to dynamically insert the ID from previous node results. ```URL https://api.notion.com/v1/blocks/ ``` ```URL https://api.notion.com/v1/blocks/{{ $json.results[0].id }} ``` -------------------------------- ### Configure PostgreSQL Database Connection - n8n Environment Variables Source: https://github.com/nithichotec/n8ndocs/blob/main/other_y_22.md Define the connection parameters for a PostgreSQL database used by n8n. These variables cover essential settings like host, port, database name, user, and password, as well as advanced options like SSL configuration and connection pool size. Proper configuration is crucial for reliable database access. ```Environment Variables DB_POSTGRESDB_DATABASE / _FILE: The name of the PostgreSQL database. (Type: String, Default: n8n) DB_POSTGRESDB_HOST / _FILE: The PostgreSQL host. (Type: String, Default: localhost) DB_POSTGRESDB_PORT / _FILE: The PostgreSQL port. (Type: Number, Default: 5432) DB_POSTGRESDB_USER / _FILE: The PostgreSQL user. (Type: String, Default: postgres) DB_POSTGRESDB_PASSWORD / _FILE: The PostgreSQL password. (Type: String, Default: -) DB_POSTGRESDB_POOL_SIZE / _FILE: Control how many parallel open Postgres connections n8n should have. (Type: Number, Default: 2) DB_POSTGRESDB_CONNECTION_TIMEOUT / _FILE: Postgres connection timeout (ms). (Type: Number, Default: 20000) DB_POSTGRESDB_SCHEMA / _FILE: The PostgreSQL schema. (Type: String, Default: public) DB_POSTGRESDB_SSL_ENABLED / _FILE: Whether to enable SSL. (Type: Boolean, Default: false) DB_POSTGRESDB_SSL_CA / _FILE: The PostgreSQL SSL certificate authority. (Type: String, Default: -) DB_POSTGRESDB_SSL_CERT / _FILE: The PostgreSQL SSL certificate. (Type: String, Default: -) DB_POSTGRESDB_SSL_KEY / _FILE: The PostgreSQL SSL key. (Type: String, Default: -) DB_POSTGRESDB_SSL_REJECT_UNAUTHORIZED / _FILE: If n8n should reject unauthorized SSL connections. (Type: Boolean, Default: true) ``` -------------------------------- ### Define Assistant Description (Text) Source: https://github.com/nithichotec/n8ndocs/blob/main/other_s_1176.md This snippet shows an example of the text used for the assistant's description. This field has a maximum length of 512 characters and provides a brief overview of the assistant's purpose. ```Text A virtual assistant that helps users with daily tasks, including setting reminders, answering general questions, and providing quick information. ``` -------------------------------- ### MongoDB Sort Example for KoboToolbox Submissions (JSON) Source: https://github.com/nithichotec/n8ndocs/blob/main/other_s_728.md Example demonstrating how to use MongoDB's JSON sort format to order KoboToolbox submissions. This example sorts first by 'status' in ascending order (1) and then by '_submission_time' in descending order (-1). ```JSON {"status": 1, "_submission_time": -1} ```