n8n is currently one of the most popular open-source AI workflow platforms, boasting over 94,000 stars on GitHub. It allows users to easily build complex AI workflows by dragging and dropping nodes, with each node offering access to thousands of tool plugins. These plugins enable seamless integration of external systems, facilitating the free flow of data across different systems. Known for its high flexibility and reliability, n8n is often referred to as the "Lego of workflows," crafted with German engineering precision.
This article serves as a comprehensive, hands-on tutorial for n8n. We'll cover how to deploy n8n locally, explore its capabilities through five practical examples, and dive into its core features.
Getting Started: Deploying n8n Locally
To begin, visit the n8n GitHub homepage, where you'll find important information about its open-source license. The license permits using n8n for internal business or personal AI workflows but prohibits offering it as a commercial service. For commercial purposes, consider alternative open-source AI workflow tools like Airflow.
n8n offers two deployment methods: Node.js and Docker. This tutorial focuses on Node.js deployment, with Docker covered later.
Deploying with Node.js
- Visit nodejs.org and download the installer. Follow the straightforward installation process by clicking "Next" through the prompts.
- After installation, open a command-line window and verify the setup by typing:
node -v
to check the Node.js version.npx -v
to check the NPX version.
If both commands return version numbers, your Node.js environment is ready.
- Run the command provided on the n8n GitHub page to install n8n. The first execution may be slow as it downloads dependencies. If it fails, try again or use a VPN for a stable connection.
- Once installed, n8n provides a local address. Open it in your browser, enter an email, name, and password, then click "Next." Skip optional steps and click "Get Started" to access the main n8n interface.
Creating Your First Workflow
Instead of explaining every feature, let’s dive into creating a practical workflow. Our first example will periodically fetch news from Hacker News, filter content based on interest, summarize it, and email the results.
Step 1: Setting Up the Workflow
- Click "Create Workflow" in the top-right corner.
- Add a trigger node to start the workflow. Options include manual, event-based (e.g., receiving an email), scheduled, or API-triggered. For this example, select "Manual" for testing, but we’ll switch to "On a Schedule" later for periodic execution.
Step 2: Fetching Data with RSS
- Add a node to fetch data. Choose the "RSS" node, which subscribes to updates from websites.
- Search for "Hacker News RSS" online to find subscription feeds. For this example, use a feed that filters news by points (e.g., set to 5 for articles with 5+ points). Copy the RSS URL.
- Paste the URL into the RSS node and test it. The node should return 20 items, indicating successful data retrieval.
Step 3: Web Scraping with Firecrawl
- To scrape content from the links in the RSS feed, add a web scraping node. n8n doesn’t natively support Firecrawl, but you can install a community plugin.
- Go to "Settings" > "Community Nodes" > "Install," search for "Firecrawl," and install the plugin. Restart n8n by stopping it (Ctrl+C in the terminal) and rerunning
npx n8n
. - Add a Firecrawl node, configure it to scrape URLs, and create an API credential:
- Visit the Firecrawl website, log in, and copy your API key.
- In n8n, paste the API key into the Firecrawl node’s credential settings and save.
- Drag the "link" field from the RSS node to the Firecrawl node’s URL field. n8n automatically loops through all links (e.g., 20 articles).
- To limit output for testing, add a "Limit" node before Firecrawl, setting it to 3 items. Test the Firecrawl node to confirm it scrapes content from the three URLs.
Step 4: Summarizing with AI
- Add an "AI Agent" node to summarize the scraped data. Switch to "Custom" prompt mode.
- Drag the "data" field from the Firecrawl node into the AI node’s prompt. Add a system prompt: "You are a news assistant. Summarize the scraped website data into a concise news brief."
- Configure the AI model (e.g., DeepSeek):
- Visit DeepSeek’s API platform, create an API key, and paste it into the AI node’s credentials.
- Test the node. The AI will translate and summarize the scraped data into a news brief.
- Pin the results by clicking the "Pin" button to use them as test data for subsequent nodes.
Step 5: Aggregating and Converting Data
- Add an "Aggregation" node to combine the three summarized outputs into a single list. Drag the "output" field from the AI node and test it.
- Add a "Markdown" node to convert the Markdown-formatted output to HTML for email compatibility. Drag the aggregated "output" field, set the join method to "Join with two newlines," and test. This merges the summaries into a single HTML string.
Step 6: Sending the Email
- Add a "Send Email" node and configure an email service (e.g., QQ Mail):
- Log into your QQ Mail account, enable SMTP in settings, and generate an authorization code.
- In n8n, enter the SMTP host, your QQ email, and the authorization code as the password.
- Set the sender and recipient (e.g., your Outlook email), choose HTML format, and drag the HTML output from the Markdown node into the email content. Test the node to send the email.
- Check your Outlook inbox to confirm the news brief was delivered in a well-formatted layout.
Step 7: Automating the Workflow
- Replace the manual trigger with an "On a Schedule" node. Set it to run every 4 hours (or use a cron expression for more complex scheduling).
- Connect the nodes, activate the workflow by toggling the start switch, and confirm. Your workflow will now automatically fetch, summarize, and email news every 4 hours.
Saving and Sharing Workflows
n8n stores workflows in a local SQLite database, located in the folder displayed when you start n8n. You can also use MySQL or PostgreSQL for persistent storage. To share a workflow:
- In the workflow editor, click the three dots and select "Download" to save it as a JSON file.
- Others can import the JSON file via "Create Workflow" > "Import from File."
Exploring Community Workflows
Visit n8n’s official workflows page to explore community-shared workflows, such as:
- Marketing: Scrapes LinkedIn data, uses AI to score potential clients, and adds them to a table.
- Video Generation: Automates video creation and multi-platform publishing.
- Invoice Parsing: Uses AI to parse invoices from emails and store data.
To use a community workflow, click "Use for Free" to copy its JSON file and import it into your n8n instance.
n8n as an MCP Client and Server
n8n supports bidirectional Message Control Protocol (MCP) functionality, acting as both a client and server:
- As an MCP Client: Supports SSE and STDIO protocols. For example, configure an MCP Client node to call Baidu Maps’ MCP 서버 for route planning.
- As an MCP Server: Expose a workflow as an MCP server via an "MCP Server Trigger" node, allowing external tools to trigger it.
Example: MCP Integration
- Create a workflow with an "On Chat Message" trigger and an AI Agent node using DeepSeek.
- Add an MCP Client node to call Baidu Maps’ MCP server. Configure it with an SSE URL and API key from Baidu Maps’ API platform.
- Test the workflow by asking, “Plan a public transit route from Qingdao Taipingjiao Park to Xiaoyushan.” The AI will use the MCP server to return route options.
- To expose the workflow as an MCP server, add an "MCP Server Trigger" node, configure it to call the workflow, and share the generated SSE URL. Test it using a client like Cherry Studio.
Deploying n8n with Docker
For production use, deploy n8n on a Linux server using Docker:
- Install Docker on your server (refer to detailed guides online).
- Run the Docker volume creation command from n8n’s GitHub page.
- Execute the Docker run command, modified with
-d
for background execution and a parameter for HTTP access. - Access n8n via your server’s public IP and port 5678.
- For persistent storage, configure environment variables to connect n8n to a relational database like MySQL.
Alternatively, platforms like Zoho Cloud offer free n8n deployment for testing.
Conclusion
n8n’s flexibility and extensive plugin ecosystem make it a powerful tool for automating AI workflows. This tutorial covered local deployment, creating a news aggregation workflow, and leveraging MCP capabilities. For more advanced workflows and community resources, explore n8n’s official documentation and workflow library.