跳转至

Load n8n into a docker and let hermes to build and operate it all using local ollama llm

To get Hermes Agent (HA) to actually build and create a new workflow in n8n from scratch (rather than just triggering one that already exists), you need to bridge them using n8n's Public REST API.

n8n workflows are essentially just large JSON files under the hood. Since Hermes Agent is powered by an LLM, it can write that JSON code and inject it directly into n8n.

Here is how to set up this advanced "AI building AI workflows" pipeline:

Phase 1: Enable the n8n API

First, you need to give Hermes Agent a master key to your n8n factory.

  1. Open your n8n web interface (http://localhost:5678).
  2. Go to Settings (the gear icon) > n8n API.
  3. Click Create an API Key.
  4. Copy this key and save it somewhere safe.

Phase 2: Give Hermes Agent the "n8n Builder" Tool

Hermes Agent needs to know how to talk to the n8n API. Depending on your exact HA setup, you need to define a custom API tool or HTTP request capability in Hermes' configuration.

You need to instruct Hermes Agent with the following parameters:

You can do this by adding a "System Prompt" or "Custom Tool" in your ~/.hermes configuration. You basically tell Hermes: "You are an n8n expert. When I ask you to create a workflow, you must write the n8n JSON structure, and then send a POST request to http://host.docker.internal:5678/api/v1/workflows with that JSON."

Phase 3: Prompting Hermes via WhatsApp

Once configured, you can text Hermes on WhatsApp with a prompt like this:

"Hermes, I need an n8n workflow that triggers every day at 8 AM, fetches data from a generic REST API, and sends a Telegram message. Please generate the n8n JSON for this and push it to my n8n server."

What happens behind the scenes:

  1. Your local Ollama model thinks about how n8n nodes are structured (Schedule Trigger Node -> HTTP Request Node -> Telegram Node).
  2. It generates the raw JSON code for those nodes and how they connect to each other.
  3. It uses its HTTP tool to silently send that JSON to your n8n Docker container.
  4. Hermes replies on WhatsApp: "I've created the workflow! Check your n8n dashboard."

⚠️ Important Caveat for Local LLMs

Because you are using a local Ollama model (like Hermes 3 or Llama 3), the success of this depends heavily on the size and intelligence of your model.

Writing perfect n8n JSON schemas from scratch is complex. Smaller models (like 8B parameter models) might hallucinate node names or mess up the JSON syntax, causing the n8n API to reject it.

  • Pro Tip: If the local model struggles to build complex flows from scratch, ask it to create the basic framework (just the trigger and a dummy node). Then, open n8n in your browser and finish connecting the exact API credentials visually.

Detail for Phase 2

To make Hermes Agent (HA) actually understand how to use the n8n API, you need to define a "Custom Tool" using standard LLM function-calling schemas.

Inside your ~/.hermes folder, HA typically looks for a file where custom tools are defined (often named tools.json, custom_tools.yaml, or within config.json under a tools array, depending on the exact build).

You need to provide the agent with two things: the Schema (so the LLM knows what the tool does) and the Execution Details (so the Docker container knows where to send the data).

Here is exactly what that configuration looks like:

The Configuration Block

Add this JSON block to your Hermes tools configuration:

{ "name": "create_n8n_workflow", "description": "Creates a new automation workflow in n8n. Use this when the user asks to build an automation. You must generate valid n8n workflow JSON.", "parameters": { "type": "object", "properties": { "name": { "type": "string", "description": "The name of the workflow." }, "nodes": { "type": "array", "description": "The array of n8n nodes in JSON format." }, "connections": { "type": "object", "description": "The routing connections between the nodes." } }, "required": ["name", "nodes", "connections"] }, "execution": { "type": "http_request", "method": "POST", "url": "http://host.docker.internal:5678/api/v1/workflows", "headers": { "Content-Type": "application/json", "X-N8N-API-KEY": "YOUR_N8N_API_KEY_HERE" }, "body": { "name": "{{name}}", "nodes": "{{nodes}}", "connections": "{{connections}}" } } }

How this works under the hood:

  1. The LLM Brain (Qwen 122B): When you text WhatsApp, Qwen reads the "description" of this tool. It realizes, "Ah, I need to use create_n8n_workflow!" It then writes the code for the nodes and connections arrays.
  2. The Docker Engine: Once Qwen generates the JSON, Hermes Agent looks at the "execution" block. It takes the code Qwen just wrote, places it into the "body", attaches your secret X-N8N-API-KEY, and fires it over the Docker network (host.docker.internal:5678) straight into your n8n factory.

Note: If your specific version of Hermes Agent uses an OpenAPI specification (openapi.yaml) instead of standard JSON tools, you would define this exact same POST request under the /workflows path in the OpenAPI format.