Offset: 0.0s
Space Play/Pause

I'll never use n8n the same......

The way you use the powerful workflow automation tool, n8n, is about to be completely transformed. What if you could combine the structured, event-driven power of n8n with a dynamic, code-execu…

7 min read

Supercharge n8n with AI Agents: A Game-Changing Workflow

The way you use the powerful workflow automation tool, n8n, is about to be completely transformed. What if you could combine the structured, event-driven power of n8n with a dynamic, code-executing AI like Claude Code? This isn’t just a minor upgrade; it’s a revolutionary approach that turns n8n into a master orchestrator for complex AI agents, skills, and workflows. This combination was a personal game-changer, and it represents a massive leap in what’s possible with automation.

When I realized I could combine the two… Oh my gosh, I unlocked a superpower.

Get your coffee ready, because we’re diving into a method that will redefine your automation architecture.

Requirements to Get Started

[0:00:26.551]

[n8n workflow showing a Claude Code node triggering multiple other automations.]

So, how is it possible to create an n8n workflow that seamlessly integrates with Claude Code? The magic lies in a clever setup that allows n8n to execute commands, trigger AI agents, and even maintain conversational sessions. This approach makes n8n the perfect orchestrator for your AI tasks.

[0:00:35.485]

[A handwritten list of requirements: n8n instance, Claude Code, and Coffee.]

To make this happen, you’ll need three essential things:

  1. An n8n instance.
  2. An AI terminal tool.
  3. And, of course, coffee.

For the AI terminal tool, Claude Code is highly recommended, especially since it allows for complex agentic workflows. However, other tools like Gemini-CLI or even OpenAI’s Codex can also work, though they might have different capabilities. It’s important to note that Claude Code requires a Pro subscription, while Gemini-CLI offers a free tier with limitations. The power of running AI directly in the terminal is that it can interact with your local files and system, giving it immense context and capability.

Setting Up Your n8n Instance in 5 Minutes

[0:01:04.288]

[A hand points to the recommendation of using a Hostinger VPS.]

If you don’t already have an n8n instance, the quickest and most efficient way to get started is by self-hosting it on a Hostinger VPS. There are two major advantages to this method. First, it’s incredibly affordable, often on sale, allowing you to run a full-fledged homelab in the cloud for just a few dollars a month. The server specs are more than enough to run n8n alongside other applications.

[0:01:09.122]

[Hostinger VPS pricing page showing different plans.]

Second, Hostinger makes the setup process unbelievably simple. With their pre-configured templates, you can have a fully operational n8n instance ready to go in about five minutes. You just need to select the plan with the n8n template, create your credentials, and the system handles the rest. Once the setup is complete, you’ll have direct access to your private n8n dashboard, ready for automation.

The Secret Connection: How n8n Talks to Claude Code

[0:02:10.021]

[A diagram showing an n8n node connecting to a Claude Code node, which is then revealed to be an SSH node.]

The secret to connecting n8n and Claude Code is surprisingly simple: SSH (Secure Shell). You don’t need a complex custom integration or API wrapper. By using the built-in SSH node in n8n, you can securely connect to the server where your AI terminal tool is installed (whether it’s on your Hostinger VPS, a local server, or even a Raspberry Pi) and execute any command you want.

This simple yet elegant solution is the most effective way to bridge the gap between n8n’s workflow automation and the powerful, context-aware capabilities of an AI terminal agent.

Basic Execution: Running Your First AI Command

[0:02:52.887]

[The n8n workflow overview screen.]

Let’s build a simple workflow to demonstrate this connection. Inside n8n, start with a manual trigger and add an “Execute a command” action from the SSH node.

[0:03:12.784]

[The parameters screen for the n8n SSH ‘Execute a command’ node.]

First, you’ll need to configure your credentials to connect to the server where Claude Code is running. This involves providing the server’s host IP address, your username, and your password (or using a private key). Once the connection is tested and successful, you can start sending commands.

[0:03:51.527]

[The command field in the SSH node with ‘hostname’ typed in.]

To verify the connection, you can start with a basic Linux command like hostname. After executing the step, the output should show your server’s name. Now for the real test: change the command to claude --version. This will confirm that n8n can successfully execute Claude Code commands.

[0:04:07.130]

[The SSH command field updated to run ‘claude –version’.]

Once executed, the output will display the installed version of Claude Code. You have now successfully integrated n8n with a powerful AI agent.

Unlocking Context, Skills, and Agents

[0:04:36.565]

[The SSH command field in n8n with a prompt for Claude Code.]

Now that the connection is established, you can unlock the true power of this setup. AI terminal tools like Claude Code can be run in headless mode using the -p (print) flag. This allows you to pass a prompt, get a direct response, and have the process terminate, which is perfect for automation. For instance, you can ask a simple question and get an immediate answer.

[0:05:31.439]

[The n8n output panel showing Claude’s text-based analysis of the video project.]

The real magic happens when you provide context. By using a command to first change the directory (cd) to a specific project folder before running the Claude prompt, the AI gains awareness of all the files in that directory. You can ask it to analyze your project, summarize scripts, or check for issues, and it will use the surrounding files as context to provide an intelligent, relevant answer. This architecture allows you to leverage three incredible benefits:

  1. Context: The AI has access to your local file system.
  2. Subscription: You use your existing AI subscription, avoiding per-call API costs.
  3. Skills & Agents: You can trigger pre-defined skills or even deploy multiple AI agents to perform complex, parallel tasks.

[0:06:41.836]

[A custom dashboard monitoring Claude Code activity, showing three agents being deployed and running tasks.]

For example, you could give Claude a prompt to use a custom “unifi” skill to analyze your network, rate its performance, and deploy three separate agents to handle different aspects of the analysis. N8n simply sends the command, and Claude Code orchestrates the entire complex task, demonstrating how n8n acts as the high-level orchestrator while the AI handles the intricate details.

Maintaining Conversations with Sessions

[0:07:58.203]

[An n8n workflow with a manual trigger and a single SSH node.]

One of the most powerful features of this setup is the ability to maintain a continuous conversation with the AI across multiple workflow executions. This is achieved by using session IDs. First, you generate a unique ID (UUID), perhaps using a Code node in n8n.

[0:08:44.201]

[An expression in the n8n command field showing the use of a session-id variable.]

You then pass this ID with your initial prompt using the --session-id flag. For any follow-up prompts, you use the -r (resume) flag along with the same session ID. This tells Claude Code to treat the new prompt as part of the existing conversation, allowing it to remember previous interactions and maintain context.

[0:10:04.975]

[A complete n8n workflow showing a Slack trigger and a looping mechanism for conversational AI.]

This enables incredible use cases, such as building a conversational chatbot in Slack. A message in Slack can trigger the workflow, which starts a new Claude Code session. The AI’s response is sent back to Slack with an option to continue the conversation. If you choose to continue, your next message is sent back to the same Claude session, creating a seamless, interactive experience, all orchestrated by n8n.

A New Architecture for Automation

[0:12:57.199]

[A graphic showing n8n plus Claude Code leading to an explosion, symbolizing immense power.]

This integration represents a fundamental architecture shift. Instead of building massively complex workflows within n8n, you can now use n8n as the orchestrator for a much more powerful and flexible AI agent. N8n handles the triggers and high-level logic, while Claude Code executes the intricate, context-aware tasks. This simplifies your n8n workflows while exponentially increasing their capabilities, giving you the best of both worlds. You get the robust automation of n8n supercharged with the intelligence and skills of a local AI agent.