n8n
- Day 28|讓 AI 用流程思考:n8n 讓 Agent 以工作流驅動協作
- [AI Workflow] [n8n] n8n Tutorial – Zero to Hero Course - HackMD
- n8n SSH 節點教學:3 種操作完整設定指南
deployment
services:
postgres:
image: postgres:16-alpine
restart: unless-stopped
environment:
- POSTGRES_USER=n8n
- POSTGRES_PASSWORD=foo@123
- POSTGRES_DB=n8n
volumes:
- postgres_data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U n8n"]
interval: 10s
timeout: 5s
retries: 5
redis: # Keep Redis if you want it for future use, but not required now
image: redis:7-alpine
restart: unless-stopped
command: redis-server --appendonly yes
volumes:
- redis_data:/data
n8n:
image: docker.n8n.io/n8nio/n8n:latest
restart: unless-stopped
ports:
- "5678:5678"
environment:
- DB_TYPE=postgresdb
- DB_POSTGRESDB_HOST=postgres
- DB_POSTGRESDB_PORT=5432
- DB_POSTGRESDB_DATABASE=n8n
- DB_POSTGRESDB_USER=n8n
- DB_POSTGRESDB_PASSWORD=foo@123
- N8N_HOST=0.0.0.0
- N8N_PORT=5678
- N8N_PROTOCOL=http
# Required for HTTP / non-localhost URLs; use HTTPS in production and omit or set true
- N8N_SECURE_COOKIE=false
# WEBHOOK_URL=http://your-domain-or-ip:5678/
- WEBHOOK_URL=http://x.x.x.x:5678/
- GENERIC_TIMEZONE=America/Chicago
- TZ=America/Chicago
# Disable runners/queue mode for stability with AI Agents + Chat Trigger
- N8N_RUNNERS_ENABLED=false
- EXECUTIONS_MODE=regular
# Increase timeout for AI + Redfish calls
- EXECUTIONS_TIMEOUT=600
- EXECUTIONS_TIMEOUT_MAX=7200
volumes:
- n8n_data:/home/node/.n8n
depends_on:
postgres:
condition: service_healthy
volumes:
postgres_data:
redis_data:
n8n_data:
with local vllm which can reference the LLM to Agent
RTX 5070 can use the nvidia/NVIDIA-Nemotron-3-Nano-4B-FP8
services:
vllm:
image: vllm/vllm-openai:latest
container_name: vllm
restart: unless-stopped
runtime: nvidia
ipc: host
ports:
- "8000:8000"
volumes:
- ~/.cache/huggingface:/root/.cache/huggingface
deploy:
resources:
reservations:
devices:
- driver: nvidia
count: all
capabilities: [gpu]
command: >
--model nvidia/NVIDIA-Nemotron-3-Nano-4B-FP8
--enable-auto-tool-choice
--tool-call-parser qwen3_coder
--reasoning-parser nemotron_v3
--max-model-len 32768
--max-num-seqs 1
--trust-remote-code
--gpu-memory-utilization 0.85
--kv-cache-dtype fp8
--host 0.0.0.0
template
AI Agent for Localhost
{
"name": "AI Agent for Localhost",
"nodes": [
{
"parameters": {
"options": {}
},
"type": "@n8n/n8n-nodes-langchain.chatTrigger",
"typeVersion": 1.4,
"position": [
0,
0
],
"id": "f1a5dcfc-2838-44a3-8c4d-ae37c64312c6",
"name": "When chat message received",
"webhookId": "4b172f66-ad5c-4ccf-944b-b44e9a07217b"
},
{
"parameters": {
"options": {
"systemMessage": "You are an AI Linux System Administrator Agent expert designed to help manage Linux systems.\nThe user will communicate with you as a fellow colleague. You must understand their final intention and act accordingly.\nYou can execute single-line bash commands inside a Linux System using the SSH tool.\nTo pass a command to execute, you should only pass the command itself.\nReplacing null with a command you want to execute.\n\n\nYour objectives are:\n\n### 1. Understand User Intent\n- Parse user requests related to Linux operations.\n- Accurately interpret the intent to generate valid Linux commands.\n- Accurately interpret the response you receive from a Linux System.\n- Provide the user with an interpreted response.\n\n### 2. Refer to tools\n- Execute SSH\n\n### 3. Restrictions\n- Do not do destructive actions without confirmation from the user.\n- Under no circumstance execute \"rm -rf\" command.\n\n### 4. Behavior Guidelines\n- Be concise, precise, and consistent.\n- Ensure all generated commands are compatible with Linux SSH.\n- Rely on system defaults when user input is incomplete.\n- For unknown or unrelated queries, clearly indicate invalid input.\n- when stderr contain \"command not found\", try to install the missing package after user's confirmation",
"maxIterations": 30
}
},
"type": "@n8n/n8n-nodes-langchain.agent",
"typeVersion": 3.1,
"position": [
208,
0
],
"id": "b24d122f-ec61-44bb-b018-b77661dfe90b",
"name": "AI Agent"
},
{
"parameters": {
"model": {
"__rl": true,
"value": "nvidia/NVIDIA-Nemotron-3-Nano-4B-FP8",
"mode": "list",
"cachedResultName": "nvidia/NVIDIA-Nemotron-3-Nano-4B-FP8"
},
"builtInTools": {},
"options": {}
},
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"typeVersion": 1.3,
"position": [
80,
208
],
"id": "b914f89e-392c-49e0-8d49-143b3755ef4e",
"name": "OpenAI Chat Model",
"credentials": {
"openAiApi": {
"id": "ahoGALlM1ZkXbVWu",
"name": "OpenAI account"
}
}
},
{
"parameters": {
"description": "Execute shell commands on the remote Linux host via SSH",
"source": "parameter",
"workflowJson": "{\n \"nodes\": [\n {\n \"parameters\": {\n \"workflowInputs\": {\n \"values\": [\n {\n \"name\": \"query\"\n }\n ]\n }\n },\n \"type\": \"n8n-nodes-base.executeWorkflowTrigger\",\n \"typeVersion\": 1.1,\n \"position\": [\n 0,\n 0\n ],\n \"id\": \"29e380c2-2ecd-465e-a784-f31b1c204b38\",\n \"name\": \"When Executed by Another Workflow\"\n },\n {\n \"parameters\": {\n \"command\": \"=export PATH=$PATH:/usr/bin:/usr/lib/wsl/lib; {{ $json.query }}\"\n },\n \"type\": \"n8n-nodes-base.ssh\",\n \"typeVersion\": 1,\n \"position\": [\n 220,\n 0\n ],\n \"id\": \"81a147e8-e8c8-4c98-8a9b-24de4e0152a0\",\n \"name\": \"SSH\",\n \"alwaysOutputData\": true,\n \"credentials\": {\n \"sshPassword\": {\n \"id\": \"JkHcZoevDfZRWlUK\",\n \"name\": \"SSH Password account\"\n }\n },\n \"onError\": \"continueErrorOutput\"\n }\n ],\n \"pinData\": {},\n \"connections\": {\n \"When Executed by Another Workflow\": {\n \"main\": [\n [\n {\n \"node\": \"SSH\",\n \"type\": \"main\",\n \"index\": 0\n }\n ]\n ]\n }\n }\n}\n\n\n\n\n\n\n\n\n"
},
"type": "@n8n/n8n-nodes-langchain.toolWorkflow",
"typeVersion": 2.2,
"position": [
512,
208
],
"id": "f78edeea-2c50-4312-9232-83565bcff328",
"name": "Execute SSH"
}
],
"pinData": {},
"connections": {
"When chat message received": {
"main": [
[
{
"node": "AI Agent",
"type": "main",
"index": 0
}
]
]
},
"OpenAI Chat Model": {
"ai_languageModel": [
[
{
"node": "AI Agent",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Execute SSH": {
"ai_tool": [
[
{
"node": "AI Agent",
"type": "ai_tool",
"index": 0
}
]
]
}
},
"active": false,
"settings": {
"executionOrder": "v1",
"binaryMode": "separate"
},
"versionId": "1af5079a-b054-4118-af60-52796bdc77fd",
"meta": {
"templateCredsSetupCompleted": true,
"instanceId": "e1acf573e6487637a947a14a16d366d3933d7118d3a97a8d73d0ffc0cc3e79b6"
},
"id": "v4y8vBMqBTfvmQ69",
"tags": []
}
AI agent with Built-in SSH Node
{
"name": "AI agent with Built-in SSH Node",
"nodes": [
{
"parameters": {
"options": {}
},
"type": "@n8n/n8n-nodes-langchain.chatTrigger",
"typeVersion": 1.4,
"position": [
0,
0
],
"id": "01f3a6df-ada9-489b-8901-5a7cc1d13c17",
"name": "When chat message received",
"webhookId": "e54d9053-6e43-48cc-9cf7-3fa6f82f155f"
},
{
"parameters": {
"options": {
"systemMessage": "You are an expert Linux administrator. Your ONLY goal is to run the commands on the remote host via SSH.\n\nYou have access to the 'Build-in SSH node' tool. Use it for every action on the remote host.\n\nThe tool returns stdout, stderr, and exit code.\n\nSTRICT RULES:\n- Work in clear, sequential steps. After each major step, summarize what you did and what the output was.\n- Never run more than one long command per tool call unless necessary.\n- If a command takes >30 seconds, use `timeout` or run it with `nohup` + background if appropriate, but prefer simple blocking commands first.\n- If anything fails, report the exact error and ask for clarification.\n\nAlways be concise in your reasoning."
}
},
"type": "@n8n/n8n-nodes-langchain.agent",
"typeVersion": 3.1,
"position": [
208,
0
],
"id": "a8677c2e-57ba-4b6b-87b6-f8d57ba25c2c",
"name": "AI Agent"
},
{
"parameters": {
"model": "grok-4-1-fast-reasoning",
"options": {}
},
"type": "@n8n/n8n-nodes-langchain.lmChatXAiGrok",
"typeVersion": 1,
"position": [
80,
208
],
"id": "e76bc58e-d631-4b12-a952-45d8da60e81b",
"name": "xAI Grok Chat Model",
"credentials": {
"xAiApi": {
"id": "dVr2LJqB2QduwKrH",
"name": "xAi account"
}
}
},
{
"parameters": {
"source": "parameter",
"workflowJson": "\n{\n \"nodes\": [\n {\n \"parameters\": {\n \"workflowInputs\": {\n \"values\": [\n {\n \"name\": \"query\"\n }\n ]\n }\n },\n \"type\": \"n8n-nodes-base.executeWorkflowTrigger\",\n \"typeVersion\": 1.1,\n \"position\": [\n 0,\n 0\n ],\n \"id\": \"29e380c2-2ecd-465e-a784-f31b1c204b38\",\n \"name\": \"When Executed by Another Workflow\"\n },\n {\n \"parameters\": {\n \"command\": \"={{ $json.query }}\"\n },\n \"type\": \"n8n-nodes-base.ssh\",\n \"typeVersion\": 1,\n \"position\": [\n 220,\n 0\n ],\n \"id\": \"81a147e8-e8c8-4c98-8a9b-24de4e0152a0\",\n \"name\": \"SSH\",\n \"alwaysOutputData\": true,\n \"credentials\": {\n \"sshPassword\": {\n \"id\": \"xjZ8fdwnMvlGYUTI\",\n \"name\": \"SSH Password account\"\n }\n },\n \"onError\": \"continueErrorOutput\"\n }\n ],\n \"pinData\": {},\n \"connections\": {\n \"When Executed by Another Workflow\": {\n \"main\": [\n [\n {\n \"node\": \"SSH\",\n \"type\": \"main\",\n \"index\": 0\n }\n ]\n ]\n }\n }\n}\n\n\n\n\n\n\n\n"
},
"type": "@n8n/n8n-nodes-langchain.toolWorkflow",
"typeVersion": 2.2,
"position": [
496,
176
],
"id": "d33bb4e1-2ac7-4fdc-9ade-a054bd449323",
"name": "Call 'Build-in SSH node'"
}
],
"pinData": {},
"connections": {
"When chat message received": {
"main": [
[
{
"node": "AI Agent",
"type": "main",
"index": 0
}
]
]
},
"xAI Grok Chat Model": {
"ai_languageModel": [
[
{
"node": "AI Agent",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Call 'Build-in SSH node'": {
"ai_tool": [
[
{
"node": "AI Agent",
"type": "ai_tool",
"index": 0
}
]
]
}
},
"active": false,
"settings": {
"executionOrder": "v1",
"binaryMode": "separate"
},
"versionId": "f8f9e4f3-443f-4392-ae95-01ae6396e3d0",
"meta": {
"instanceId": "99e5fc265fd8b35bcde7b27ef921b9989b8800054116f489a219d4ecb60c07ec"
},
"id": "923yW4EpCTW3s248",
"tags": []
}
AI agent with Community SSH Node
prerequisite
Install the Comminuty Node: n8n-nodes-sshv2
{
"name": "AI agent with Community SSH Node",
"nodes": [
{
"parameters": {
"options": {}
},
"type": "@n8n/n8n-nodes-langchain.chatTrigger",
"typeVersion": 1.4,
"position": [
0,
0
],
"id": "70766e77-48e0-4b8c-a9a0-06e13f4d2bd6",
"name": "When chat message received",
"webhookId": "074248bf-10cb-44b3-946f-a53eba55cf84"
},
{
"parameters": {
"options": {
"systemMessage": "You are an expert Linux administrator. Your ONLY goal is to run the commands on the remote host via SSH.\n\nYou have access to the 'build-in ssh node' tool. Use it for every action on the remote host.\n\nIf basic commands fail to show output, use: bash -l -c 'your command here'\nThe tool returns stdout, stderr, and exit code.\n\nSTRICT RULES:\n- Work in clear, sequential steps. After each major step, summarize what you did and what the output was.\n- Never run more than one long command per tool call unless necessary.\n- If a command takes >30 seconds, use `timeout` or run it with `nohup` + background if appropriate, but prefer simple blocking commands first.\n- If anything fails, report the exact error and ask for clarification.\n\nAlways be concise in your reasoning."
}
},
"type": "@n8n/n8n-nodes-langchain.agent",
"typeVersion": 3.1,
"position": [
208,
0
],
"id": "5513a9fb-23af-4736-ac6f-1ee51be14663",
"name": "AI Agent"
},
{
"parameters": {
"model": "grok-4-1-fast-reasoning",
"options": {}
},
"type": "@n8n/n8n-nodes-langchain.lmChatXAiGrok",
"typeVersion": 1,
"position": [
80,
208
],
"id": "283accd0-f233-40e6-9af2-2803e27390d4",
"name": "xAI Grok Chat Model",
"credentials": {
"xAiApi": {
"id": "dVr2LJqB2QduwKrH",
"name": "xAi account"
}
}
},
{
"parameters": {
"connectionType": "credentials",
"command": "={{ $fromAI('Command', ``, 'string') }}",
"workingDirectory": "/"
},
"type": "n8n-nodes-sshv2.hadidizAiTool",
"typeVersion": 1,
"position": [
528,
208
],
"id": "ad18e3ef-da10-4e3b-8318-a6c600681f54",
"name": "Hadidiz-AI",
"credentials": {
"sshPasswordApi": {
"id": "Pf8Dy7wI5qIv2ITR",
"name": "SSH Password account 2"
}
}
}
],
"pinData": {},
"connections": {
"When chat message received": {
"main": [
[
{
"node": "AI Agent",
"type": "main",
"index": 0
}
]
]
},
"xAI Grok Chat Model": {
"ai_languageModel": [
[
{
"node": "AI Agent",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Hadidiz-AI": {
"ai_tool": [
[
{
"node": "AI Agent",
"type": "ai_tool",
"index": 0
}
]
]
}
},
"active": false,
"settings": {
"executionOrder": "v1",
"binaryMode": "separate",
"availableInMCP": false
},
"versionId": "04982771-db19-48a6-8ce5-529ae9eab8f2",
"meta": {
"templateCredsSetupCompleted": true,
"instanceId": "99e5fc265fd8b35bcde7b27ef921b9989b8800054116f489a219d4ecb60c07ec"
},
"id": "ipOa1KLsLSFQAdT2",
"tags": []
}