Build an OpenClaude-Style AI Agent Step by Step with n8n [2026]

1. Understanding the Core Concept

Before writing any code, you need to understand how AI agents actually work.

A normal LLM works like this:

Input → Model → Output

Example:

You ask:

“Create a folder”

The LLM replies with text explaining how to create it.

But it cannot execute the command itself.


The Problem With LLMs

LLMs cannot:

  • access your computer
  • run commands
  • read emails
  • control browsers
  • interact with external tools

They only generate predicted text tokens.

So they act like a brain without a body.


2. The Agent Architecture

To make AI perform real actions, you need three components.

1. Brain (LLM)

This is the reasoning layer.

Examples:

  • OpenAI GPT
  • Claude
  • Gemini

Responsibilities:

  • understand user request
  • plan steps
  • choose tools

2. Tools (Body)

Tools perform real actions.

Examples of tools:

executeCommand

readFiles

writeFiles

browserAutomation

dockerControl

These are functions written by developers.

The AI calls them when needed.

Example:

AI decides:

Execute command → mkdir project

The tool runs the command on the system.


3. Gateway (Communication Layer)

This is how users communicate with the agent.

Examples:

HTTP API

Telegram bot

WhatsApp bot

Web interface

The gateway forwards user requests to the AI agent.


3. High Level Workflow

A complete AI agent system works like this.

  1. User sends request
  2. Gateway receives request
  3. Request goes to the AI model
  4. AI analyzes the task
  5. AI selects the correct tool
  6. Tool executes action
  7. Result returns to AI
  8. AI decides next step
  9. Process repeats until task completes

This loop is called the agent execution loop.


4. Tools Used in the Demo

The system in the transcript uses several tools.

1. OpenAI API

Used for the LLM reasoning layer.

Purpose:

  • understand instructions
  • decide which tool to call
  • generate commands

Example models:

GPT-4.1

GPT-5


2. Express.js

Used to create the API server.

Purpose:

  • receive requests
  • send requests to the agent
  • return results

3. Node.js

Used as the runtime environment.

Purpose:

  • run the server
  • execute commands
  • manage tools

4. Requestly

Used for API debugging.

Purpose:

  • inspect network calls
  • debug API requests
  • analyze LLM responses

5. Playwright

Used for browser automation.

Purpose:

  • open browsers
  • navigate websites
  • perform actions

Example:

AI opens Chrome

Searches a query

Clicks buttons


6. Docker

Used to run containers.

Example tasks:

  • start Nginx server
  • run Apache server
  • manage containers

5. Project Setup

Create a new project.

Example:

mkdir openclaude-agent

cd openclaude-agent

Initialize project.

npm init

Install dependencies.

openai

express

Optional development dependencies:

types for node

types for express


6. Building the Agent Layer

The agent layer is responsible for:

  • sending prompts to the LLM
  • receiving responses
  • calling tools

The system prompt instructs the AI how to behave.

Example instructions:

“You are an AI assistant capable of controlling the user’s machine.”

The prompt also describes available tools.

Example:

Tool: executeCommand

Description:

Executes a system command and returns output.


7. Creating the First Tool

Example tool:

executeCommand

Purpose:

Run system commands.

Implementation idea:

Use Node’s child_process module.

The tool receives:

command string

Example commands:

mkdir project

ls

docker run nginx

The tool executes the command and returns output.


8. Tool Calling Logic

The LLM response must follow a structured format.

Two possible responses:

  1. Text output
  2. Tool call

Example structure:

type: tool_call

tool_name: executeCommand

params: [“mkdir test”]

Or

type: text

content: “Folder created successfully”

This structure allows the system to decide what to do next.


9. Agent Execution Loop

Agents work using a loop.

Steps inside the loop:

  1. Send conversation history to LLM
  2. Receive structured response
  3. If tool call → execute tool
  4. Add tool result to conversation
  5. Repeat

Loop ends when the AI returns a final message.


10. Connecting the Agent to an API

Next step is exposing the agent through an API.

Using Express.

Example route:

POST /message

Input:

user message

Example request:

Create a folder named project

The server sends this message to the agent.

The agent processes the request and returns results.


11. Example Agent Tasks

Once connected, the agent can perform real tasks.

Example 1

Create folder

User request:

Create a folder called test

Agent steps:

AI decides command

Tool executes mkdir test

Result:

Folder created.


Example 2

Create project files.

User request:

Create a To-Do app with HTML, CSS and JS.

Agent steps:

Create folder

Generate files

Write code

Return result


Example 3

Run Docker container.

User request:

Run Nginx server on port 8080

Agent steps:

Pull Nginx image

Run container

Expose port


Example 4

Browser automation.

Using Playwright.

User request:

Open Google and search “AI agents”.

Agent steps:

Launch browser

Navigate to Google

Perform search


12. Error Handling

Agents must handle errors.

Example problems:

tool fails

command fails

missing dependency

Solution:

Wrap tool execution in try/catch.

If error occurs:

Return error to agent.

The AI can then:

fix command

retry action


13. Expanding Agent Capabilities

The system can be extended by adding more tools.

Examples:

Email automation

File management

Browser scraping

Database queries

API integrations

Each new tool expands the agent’s abilities.


14. Adding Messaging Channels

Instead of HTTP API, you can connect the agent to messaging apps.

Examples:

Telegram bot

WhatsApp bot

Slack bot

Users send commands through chat.

The gateway forwards messages to the agent.


15. Security Considerations

Giving AI system access is risky.

Important protections:

command restrictions

sandbox environments

limited permissions

approval systems

Never allow unrestricted command execution in production.


16. Final Architecture

The complete system contains three layers.

User Layer

User interacts through:

API

Telegram

WhatsApp

Gateway Layer

Handles communication and routing.

Agent Layer

Contains:

LLM

tools

execution loop

Tools Layer

Performs real world actions.


Final Takeaway

AI agents are not complicated.

They are built from three components.

LLM reasoning

tools for execution

loop for decision making

LLM thinks.

Tools act.

Agents combine both.

This is the same principle behind modern systems built with:

AI agents

automation workflows

platforms like n8n.

1. Understanding the Core Concept

Before writing any code, you need to understand how AI agents actually work.

A normal LLM works like this:

Input → Model → Output

Example:

You ask:

“Create a folder”

The LLM replies with text explaining how to create it.

But it cannot execute the command itself.


The Problem With LLMs

LLMs cannot:

  • access your computer
  • run commands
  • read emails
  • control browsers
  • interact with external tools

They only generate predicted text tokens.

So they act like a brain without a body.


2. The Agent Architecture

To make AI perform real actions, you need three components.

1. Brain (LLM)

This is the reasoning layer.

Examples:

  • OpenAI GPT
  • Claude
  • Gemini

Responsibilities:

  • understand user request
  • plan steps
  • choose tools

2. Tools (Body)

Tools perform real actions.

Examples of tools:

executeCommand

readFiles

writeFiles

browserAutomation

dockerControl

These are functions written by developers.

The AI calls them when needed.

Example:

AI decides:

Execute command → mkdir project

The tool runs the command on the system.


3. Gateway (Communication Layer)

This is how users communicate with the agent.

Examples:

HTTP API

Telegram bot

WhatsApp bot

Web interface

The gateway forwards user requests to the AI agent.


3. High Level Workflow

A complete AI agent system works like this.

  1. User sends request
  2. Gateway receives request
  3. Request goes to the AI model
  4. AI analyzes the task
  5. AI selects the correct tool
  6. Tool executes action
  7. Result returns to AI
  8. AI decides next step
  9. Process repeats until task completes

This loop is called the agent execution loop.


4. Tools Used in the Demo

The system in the transcript uses several tools.

1. OpenAI API

Used for the LLM reasoning layer.

Purpose:

  • understand instructions
  • decide which tool to call
  • generate commands

Example models:

GPT-4.1

GPT-5


2. Express.js

Used to create the API server.

Purpose:

  • receive requests
  • send requests to the agent
  • return results

3. Node.js

Used as the runtime environment.

Purpose:

  • run the server
  • execute commands
  • manage tools

4. Requestly

Used for API debugging.

Purpose:

  • inspect network calls
  • debug API requests
  • analyze LLM responses

5. Playwright

Used for browser automation.

Purpose:

  • open browsers
  • navigate websites
  • perform actions

Example:

AI opens Chrome

Searches a query

Clicks buttons


6. Docker

Used to run containers.

Example tasks:

  • start Nginx server
  • run Apache server
  • manage containers

5. Project Setup

Create a new project.

Example:

mkdir openclaude-agent

cd openclaude-agent

Initialize project.

npm init

Install dependencies.

openai

express

Optional development dependencies:

types for node

types for express


6. Building the Agent Layer

The agent layer is responsible for:

  • sending prompts to the LLM
  • receiving responses
  • calling tools

The system prompt instructs the AI how to behave.

Example instructions:

“You are an AI assistant capable of controlling the user’s machine.”

The prompt also describes available tools.

Example:

Tool: executeCommand

Description:

Executes a system command and returns output.


7. Creating the First Tool

Example tool:

executeCommand

Purpose:

Run system commands.

Implementation idea:

Use Node’s child_process module.

The tool receives:

command string

Example commands:

mkdir project

ls

docker run nginx

The tool executes the command and returns output.


8. Tool Calling Logic

The LLM response must follow a structured format.

Two possible responses:

  1. Text output
  2. Tool call

Example structure:

type: tool_call

tool_name: executeCommand

params: [“mkdir test”]

Or

type: text

content: “Folder created successfully”

This structure allows the system to decide what to do next.


9. Agent Execution Loop

Agents work using a loop.

Steps inside the loop:

  1. Send conversation history to LLM
  2. Receive structured response
  3. If tool call → execute tool
  4. Add tool result to conversation
  5. Repeat

Loop ends when the AI returns a final message.


10. Connecting the Agent to an API

Next step is exposing the agent through an API.

Using Express.

Example route:

POST /message

Input:

user message

Example request:

Create a folder named project

The server sends this message to the agent.

The agent processes the request and returns results.


11. Example Agent Tasks

Once connected, the agent can perform real tasks.

Example 1

Create folder

User request:

Create a folder called test

Agent steps:

AI decides command

Tool executes mkdir test

Result:

Folder created.


Example 2

Create project files.

User request:

Create a To-Do app with HTML, CSS and JS.

Agent steps:

Create folder

Generate files

Write code

Return result


Example 3

Run Docker container.

User request:

Run Nginx server on port 8080

Agent steps:

Pull Nginx image

Run container

Expose port


Example 4

Browser automation.

Using Playwright.

User request:

Open Google and search “AI agents”.

Agent steps:

Launch browser

Navigate to Google

Perform search


12. Error Handling

Agents must handle errors.

Example problems:

tool fails

command fails

missing dependency

Solution:

Wrap tool execution in try/catch.

If error occurs:

Return error to agent.

The AI can then:

fix command

retry action


13. Expanding Agent Capabilities

The system can be extended by adding more tools.

Examples:

Email automation

File management

Browser scraping

Database queries

API integrations

Each new tool expands the agent’s abilities.


14. Adding Messaging Channels

Instead of HTTP API, you can connect the agent to messaging apps.

Examples:

Telegram bot

WhatsApp bot

Slack bot

Users send commands through chat.

The gateway forwards messages to the agent.


15. Security Considerations

Giving AI system access is risky.

Important protections:

command restrictions

sandbox environments

limited permissions

approval systems

Never allow unrestricted command execution in production.


16. Final Architecture

The complete system contains three layers.

User Layer

User interacts through:

API

Telegram

WhatsApp

Gateway Layer

Handles communication and routing.

Agent Layer

Contains:

LLM

tools

execution loop

Tools Layer

Performs real world actions.


Final Takeaway

AI agents are not complicated.

They are built from three components.

LLM reasoning

tools for execution

loop for decision making

LLM thinks.

Tools act.

Agents combine both.

This is the same principle behind modern systems built with:

AI agents

automation workflows

platforms like n8n.

Author

Written By

Vikash Kumar

Building AI agents, n8n workflows and end-to-end automation for 30+ Brands across India, the US, Europe, Dubai & Australia. 7+ years of Experience saving founders real hours every week - no code required.

Ask more Questions about this Blog with AI:

Our AI Articles

Learn from our AI Articles to excel in your profession ;)

Complete Guide To Claude Code Agent Teams

Agent Teams are one of the most advanced features inside Claude Code. Instead of using one AI agent to complete...

How To Build Realistic AI Voice Agents With 11Labs + Make.com

How Agent Teams turn Claude Code into a collaborative AI workforce for building complex systems....

100 SECRET CLAUDE PROMPT CODES

Practical Claude prompt systems that improve writing, research, strategy, automation, and workflows....

The Real Claude AI Business Guide for 2026

5 Claude AI business models solving expensive problems businesses already pay for in 2026....

Complete Guide: How To Build A Claude Skill For SEO Content Writing

Reusable Claude workflows that turn generic AI writing into personalized, scalable SEO systems....

Complete Breakdown: How To Build AI Backlink Systems Using Claude Skills + Automation

Complete Breakdown: How To Build AI Backlink Systems Using Claude Skills + Automation...

Claude AI SEO Automation Guide

This AI SEO workflow automates content creation, optimization, publishing, and indexing at scale....

Complete AI Lead Generation Workflow Using Claude AI + ChatGPT

AI workflow to automate lead generation, outreach emails, and scalable client acquisition....

Use Amazon Bedrock To Try Claude, OpenAI, DeepSeek, And More

Beginner guide to using Amazon Bedrock with Claude, OpenAI, DeepSeek, APIs, and AI workflows....

Build n8n Automations With Claude Code

This guide shows how to build AI automation systems using Cursor, Claude Code, n8n, MCP, and agents....
1:1 Free Strategy Session
Your competitors are already automating. Are you still paying for it manually?

Do you want to adopt AI Automation?

Every hour your team does repetitive work, you're burning real money.
While you wait, faster businesses are cutting costs and moving quicker.
AI and automations aren't the future anymore — they're the present.

Book a live 1-on-1 session where we show you exactly which of your daily tasks can be automated — and what it’s costing you not to.