Torna al blog
Intelligenza Artificiale

n8n with LLM: how I built an automated HR system with AI without writing (almost) any code

n8n is the most powerful automation tool I've ever used. Combining it with Ollama and local LLM models, I built complete HR workflows: email classification, dynamic forms, RAG system for company documents. All without sending sensitive data to the cloud.

The first time I saw n8n running with an LLM

I remember the exact moment. I was watching an n8n node receive an email, pass it to a local Ollama model for classification, and then automatically route the response to the correct department — all without a single line of custom code being written. In under twenty minutes. I'd spent years building custom automation systems in Node.js and Python. n8n does all that complexity for you, with a visual interface that makes the flow readable to anyone. When I added local LLM models, I realized I could build things that previously required an entire team.

Setup: n8n and Ollama in the same Docker Compose

The key is running n8n and Ollama on the same Docker network so they can communicate directly. n8n reaches Ollama at http://ollama:11434 — no ports exposed externally, everything isolated in the Docker network.

The LLM Chain node: the heart of the integration

n8n has a native Ollama node, but the real power comes from the LLM Chain node, which lets you build conversations with context, pass workflow variables to prompts, and receive structured responses. For classification, constraining the model to respond with a single word lets the downstream Switch node do exact matching without complex parsing.

Email handling: the HR Manager case

The HR Manager simulation receives emails from employees, classifies them, and automatically responds for simple categories while escalating complex ones to a human operator. IMAP reads incoming emails, LLM Chain classifies and drafts responses, IF Node escalates edge cases, SMTP sends the response. The entire pipeline handles dozens of emails per hour without human intervention for standard cases.

DataTables, CSV and Excel: automated reporting

Every Monday morning: Schedule Trigger fires, Database Query extracts weekly data, Spreadsheet File generates an Excel file, LLM Chain writes an executive summary, Email sends report and summary to the manager. Zero manual intervention. The manager receives a complete Excel file plus three paragraphs of AI-generated analysis.

RAG System: answering questions from company documents

The most advanced component is the RAG (Retrieval Augmented Generation) system: a chatbot that answers questions using company documents as its source, without hallucinating answers. Documents are chunked, embedded into vectors, and stored in a vector database. At query time, the user's question is embedded, similar chunks are retrieved, and the LLM answers using only those chunks as context. If the answer isn't in the documents, it says so.

AI Agent with tools: the next level

An AI Agent lets an LLM autonomously decide which tool to use: query the absence database, create a ticket, check the company calendar, search documents. When an employee asks how many vacation days remain and when they can take them next week, the agent autonomously queries the database and calendar without me explicitly programming this sequence.

Why this approach changes everything

I've built similar systems with custom code. It took weeks, required experienced developers, and every change was risky. With n8n + Ollama, someone with basic technical knowledge can build sophisticated workflows in days. Data stays local. The LLM runs on your infrastructure. No per-query costs, no vendor lock-in, no sensitive employee data on third-party servers.

Condividi