======================== CODE SNIPPETS ======================== TITLE: Configure n8n PostgresDB Connection via Environment Variables DESCRIPTION: Example bash commands to export environment variables for configuring n8n to connect to a PostgresDB instance. This snippet includes essential connection parameters and demonstrates how to set optional SSL/TLS related variables. The `n8n start` command is included to initiate n8n with the new database configuration. SOURCE: https://github.com/n8n-io/n8n-docs/blob/main/docs/hosting/configuration/supported-databases-settings.md#_snippet_1 LANGUAGE: bash CODE: ``` export DB_TYPE=postgresdb export DB_POSTGRESDB_DATABASE=n8n export DB_POSTGRESDB_HOST=postgresdb export DB_POSTGRESDB_PORT=5432 export DB_POSTGRESDB_USER=n8n export DB_POSTGRESDB_PASSWORD=n8n export DB_POSTGRESDB_SCHEMA=n8n # optional: export DB_POSTGRESDB_SSL_CA=$(pwd)/ca.crt export DB_POSTGRESDB_SSL_REJECT_UNAUTHORIZED=false n8n start ``` ---------------------------------------- TITLE: Install Docker and Docker Compose on Ubuntu DESCRIPTION: This snippet provides a comprehensive set of `bash` commands to install Docker and Docker Compose on an Ubuntu system. It includes steps for removing incompatible packages, installing necessary prerequisites, adding Docker's official GPG key, configuring the APT repository, and finally installing `docker-ce`, `docker-ce-cli`, `containerd.io`, `docker-buildx-plugin`, and `docker-compose-plugin`. SOURCE: https://github.com/n8n-io/n8n-docs/blob/main/docs/hosting/installation/server-setups/docker-compose.md#_snippet_0 LANGUAGE: bash CODE: ``` # 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 ``` ---------------------------------------- TITLE: n8n Placeholder Content Examples DESCRIPTION: Examples of common placeholder content for various input parameters within n8n nodes, demonstrating the recommended 'e.g.' prefix and camel case for demo content. SOURCE: https://github.com/n8n-io/n8n-docs/blob/main/docs/integrations/creating-nodes/build/reference/ux-guidelines.md#_snippet_4 LANGUAGE: APIDOC CODE: ``` image: e.g. https://example.com/image.png video: e.g. https://example.com/video.mp4 search term: e.g. automation email: e.g. nathan@example.com Twitter user (or similar): e.g. n8n Name and last name: e.g. Nathan Smith First name: e.g. Nathan Last name: e.g. Smith ``` ---------------------------------------- TITLE: Install n8n globally using npm DESCRIPTION: Installs the n8n command-line interface globally on your system, allowing you to run n8n from any directory. This is a prerequisite for testing custom n8n nodes locally. SOURCE: https://github.com/n8n-io/n8n-docs/blob/main/docs/integrations/creating-nodes/build/node-development-environment.md#_snippet_0 LANGUAGE: Shell CODE: ``` npm install n8n -g ``` ---------------------------------------- TITLE: Verify Docker and Docker Compose Installation DESCRIPTION: These commands allow users to confirm that Docker and Docker Compose have been successfully installed and are accessible from the command line. It checks the version of both `docker` and `docker compose`. SOURCE: https://github.com/n8n-io/n8n-docs/blob/main/docs/hosting/installation/server-setups/docker-compose.md#_snippet_1 LANGUAGE: bash CODE: ``` docker --version docker compose version ``` ---------------------------------------- TITLE: Start Local n8n Instance DESCRIPTION: This command starts your local n8n server. Once running, you can access the n8n web interface in your browser and verify that your custom nodes are loaded and available in the nodes panel. SOURCE: https://github.com/n8n-io/n8n-docs/blob/main/_snippets/integrations/creating-nodes/testing.md#_snippet_3 LANGUAGE: shell CODE: ``` n8n start ``` ---------------------------------------- TITLE: Start Docker Compose Services DESCRIPTION: This command starts the Docker Compose services defined in the `compose.yaml` file in detached mode, allowing them to run in the background. It initializes both the n8n and Traefik containers. SOURCE: https://github.com/n8n-io/n8n-docs/blob/main/docs/hosting/installation/server-setups/docker-compose.md#_snippet_9 LANGUAGE: bash CODE: ``` sudo docker compose up -d ``` ---------------------------------------- TITLE: Enhance QuickBooks Node Operations DESCRIPTION: Introduces the 'Purchase' resource to the QuickBooks node, along with 'Get' and 'Get All' operations, enabling comprehensive management and retrieval of purchase data. SOURCE: https://github.com/n8n-io/n8n-docs/blob/main/docs/release-notes/0-x.md#_snippet_42 LANGUAGE: APIDOC CODE: ``` QuickBooks Node: - Added Purchase resource with Get and Get All operations. ``` ---------------------------------------- TITLE: Link Custom Node to Local n8n Installation DESCRIPTION: Run this command in the `nodes` directory of your n8n installation (e.g., `~/.n8n/custom/`). It creates a symbolic link from your locally published node to the n8n instance, allowing n8n to discover and load your custom node. SOURCE: https://github.com/n8n-io/n8n-docs/blob/main/_snippets/integrations/creating-nodes/testing.md#_snippet_2 LANGUAGE: shell CODE: ``` npm link ``` ---------------------------------------- TITLE: Configure n8n Multi-Main Setup Environment Variables DESCRIPTION: This section outlines environment variables specifically for configuring n8n's multi-main setup, which requires a license. It includes settings for enabling the feature, leader key TTL, and check intervals. SOURCE: https://github.com/n8n-io/n8n-docs/blob/main/docs/hosting/configuration/environment-variables/queue-mode.md#_snippet_1 LANGUAGE: APIDOC CODE: ``` N8N_MULTI_MAIN_SETUP_ENABLED: Type: Boolean Default: false Description: Whether to enable multi-main setup for queue mode (license required). N8N_MULTI_MAIN_SETUP_KEY_TTL: Type: Number Default: 10 Description: Time to live (in seconds) for leader key in multi-main setup. N8N_MULTI_MAIN_SETUP_CHECK_INTERVAL: Type: Number Default: 3 Description: Interval (in seconds) for leader check in multi-main setup. ``` ---------------------------------------- TITLE: n8n Existing Node Enhancements DESCRIPTION: Outlines specific enhancements applied to various existing n8n nodes. These improvements include adding a 'Certificate Install' operation to the Citrix ADC node, introducing a 'Use key' option for messages in the Kafka node, and upgrading the MySQL node to use a resource locator component for easier browsing and selection of database fields. SOURCE: https://github.com/n8n-io/n8n-docs/blob/main/docs/release-notes/0-x.md#_snippet_13 LANGUAGE: APIDOC CODE: ``` Citrix ADC node: add Certificate Install operation. Kafka node: add a Use key option for messages. MySQL node: use the resource locator component for table parameters, making it easier for users to browse and select their database fields from within n8n. Crypto node: add SHA3 support. ``` ---------------------------------------- TITLE: Get n8n license information DESCRIPTION: This command allows self-hosted n8n users to retrieve information about their licenses directly from the command line. SOURCE: https://github.com/n8n-io/n8n-docs/blob/main/docs/release-notes/0-x.md#_snippet_0 LANGUAGE: sh CODE: ``` n8n license:info ``` ---------------------------------------- TITLE: Agile CRM Node: Contact & Company Resources Get All Operation Enhancements DESCRIPTION: Describes enhancements to the Agile CRM node, adding filtering capabilities to the 'Get All' operation for both 'Contact' and 'Company' resources, allowing for more refined data retrieval. SOURCE: https://github.com/n8n-io/n8n-docs/blob/main/docs/release-notes/0-x.md#_snippet_26 LANGUAGE: APIDOC CODE: ``` Agile CRM Node: Resource: Contact, Company Operation: Get All - Added: Filters for data retrieval. ``` ---------------------------------------- TITLE: DHL API Key Authentication Setup Guide DESCRIPTION: This guide outlines the process to obtain an API Key from the DHL Developer portal, which is required for authenticating DHL services in n8n. It covers creating a new application and retrieving the generated API key. SOURCE: https://github.com/n8n-io/n8n-docs/blob/main/docs/integrations/builtin/credentials/dhl.md#_snippet_0 LANGUAGE: APIDOC CODE: ``` DHL API Key Acquisition Steps: 1. In the DHL Developer portal, select the user icon to open your User Apps (https://developer.dhl.com/user/apps). 2. Select "+ Create App". 3. Enter an App name, e.g., `n8n integration`. 4. Enter a Machine name, e.g., `n8n_integration`. 5. In SELECT APIs, select "Shipment Tracking - Unified". The API is added to the Add API to app section. 6. In the Add API to app section, select the "+" next to the "Shipment Tracking - Unified" API. 7. Select "Create App". The Apps page opens, displaying the app you just created. 8. Select the app you just created to view its details. 9. Select "Show key" next to API Key. 10. Copy the API Key and enter it in your n8n credential. ``` ---------------------------------------- TITLE: Serve Local Preview of n8n Documentation DESCRIPTION: Executes the MkDocs serve command to launch a local development server, allowing users to preview the n8n documentation in a web browser. SOURCE: https://github.com/n8n-io/n8n-docs/blob/main/README.md#_snippet_2 LANGUAGE: bash CODE: ``` mkdocs serve ``` ---------------------------------------- TITLE: Call n8n API to get active workflows using cURL DESCRIPTION: Demonstrates how to authenticate and make a GET request to the n8n API to retrieve active workflows using cURL. The API key is sent via the 'X-N8N-API-KEY' header. Examples are provided for both self-hosted n8n instances and n8n Cloud. SOURCE: https://github.com/n8n-io/n8n-docs/blob/main/docs/api/authentication.md#_snippet_0 LANGUAGE: shell CODE: ``` # 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: ' ``` ---------------------------------------- TITLE: Example Human Message Prompt Structure for Conversational Agent DESCRIPTION: This example demonstrates the recommended structure for the 'Human Message' parameter in the Conversational AI Agent node. It includes placeholders for dynamically injecting available tools, output format instructions, and the user's input, guiding the AI on how to process queries and utilize tools effectively. SOURCE: https://github.com/n8n-io/n8n-docs/blob/main/docs/integrations/builtin/cluster-nodes/root-nodes/n8n-nodes-langchain.agent/conversational-agent.md#_snippet_0 LANGUAGE: text CODE: ``` 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}} ``` ---------------------------------------- TITLE: Shopify OAuth2 Credential Setup for n8n DESCRIPTION: Detailed steps to configure OAuth2 credentials for Shopify apps, including creating a custom app in the Shopify Partner dashboard, obtaining Client ID and Secret, setting up redirect URLs, and installing the app for use with n8n. SOURCE: https://github.com/n8n-io/n8n-docs/blob/main/docs/integrations/builtin/credentials/shopify.md#_snippet_1 LANGUAGE: APIDOC CODE: ``` Prerequisites: - Shopify partner account Required Credentials for n8n: - Client ID - Client Secret - Shop Subdomain (e.g., 'n8n' from 'https://n8n.myshopify.com') Steps to set up custom app in Shopify Partner dashboard: 1. Open your Shopify Partner dashboard. 2. Select 'Apps' from the left navigation. 3. Select 'Create app'. 4. In the 'Use Shopify Partners' section, enter an 'App name'. 5. Select 'Create app'. 6. When the app details open, copy the 'Client ID'. Enter this in your n8n credential. 7. Copy the 'Client Secret'. Enter this in your n8n credential. 8. In the left menu, select 'Configuration'. 9. In n8n, copy the 'OAuth Redirect URL' and paste it into the 'Allowed redirection URL(s)' in the 'URLs' section. 10. In the 'URLs' section, enter an 'App URL' for your app. The host entered here needs to match the host for the 'Allowed redirection URL(s)', like the base URL for your n8n instance. 11. Select 'Save and release'. 12. Select 'Overview' from the left menu. At this point, you can choose to 'Test your app' by installing it to one of your stores, or 'Choose distribution' to distribute it publicly. 13. In n8n, enter the 'Shop Subdomain' of the store you installed the app to, either as a test or as a distribution. ``` ---------------------------------------- TITLE: Example Assistant System Instructions DESCRIPTION: This snippet demonstrates detailed system instructions for an AI assistant. It guides the assistant's persona, response style, and interaction strategy, emphasizing a friendly and engaging manner, concise answers with context, and proactive guidance for open-ended questions, while avoiding technical jargon. SOURCE: https://github.com/n8n-io/n8n-docs/blob/main/docs/integrations/builtin/app-nodes/n8n-nodes-langchain.openai/assistant-operations.md#_snippet_4 LANGUAGE: Text CODE: ``` 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. ``` ---------------------------------------- TITLE: Clone and Set Up n8n Docs for External Contributors DESCRIPTION: Outlines the steps for external contributors to fork and clone the n8n documentation repository via HTTPS, then install the necessary public Python dependencies for local development. SOURCE: https://github.com/n8n-io/n8n-docs/blob/main/README.md#_snippet_1 LANGUAGE: bash CODE: ``` git clone https://github.com//n8n-docs.git cd n8n-docs pip install -r requirements.txt pip install mkdocs-material ```