Beyond web development, intelligent automation has become a major productivity multiplier. With n8n, LLMs, and AI agents, I can build workflows that understand unstructured data and then execute business actions.
The important distinction is between text generation and reliable automation. A production workflow should combine probabilistic AI + deterministic rules + persistence + supervision.
A simple architecture
Trigger
│
▼
n8n
│
├──► LLM / Agent
│ │
│ └──► Structured JSON
│
├──► Business validation
│
├──► PostgreSQL
│
└──► Slack / Email / CRM
n8n orchestrates. The LLM interprets. PostgreSQL stores state. Deterministic rules decide what is actually allowed.
1. Classifying emails or tickets
A workflow can receive:
{
"subject": "I cannot log in",
"body": "My account has rejected my password since this morning."
}
The model can return:
{
"category": "authentication",
"priority": "high",
"summary": "User cannot log in",
"needs_human": false
}
I always request a strict format instead of trying to parse a freely generated paragraph.
2. Validating the model output
An LLM result should never be treated as absolute truth.
Inside an n8n Code node, I can verify it:
const data = JSON.parse($json.output);
const allowedCategories = [
"authentication",
"billing",
"technical",
"other"
];
if (!allowedCategories.includes(data.category)) {
throw new Error("Invalid category");
}
return { json: data };
Deterministic logic protects the workflow from unexpected outputs.
3. Extracting data from documents
Another pipeline can look like:
PDF / Image
│
▼
Text / vision extraction
│
▼
LLM
│
▼
Structured JSON
│
▼
Validation
│
▼
PostgreSQL
For example:
{
"invoiceNumber": "INV-2026-042",
"supplier": "Example Corp",
"total": 125000,
"currency": "XAF"
}
The system can store those fields without requiring a human to manually retype them.
4. Keeping a human in the loop
Some decisions should not be fully automated.
I can define a rule:
confidence < 0.85
│
▼
Human approval
The workflow then sends a Slack or email notification containing the extracted information and waits for approval.
5. Using PostgreSQL as business memory
n8n should not become the only source of state.
I can store:
- document identifier;
- model result;
- validation status;
- execution identifier;
- timestamp;
- possible error.
This makes auditing and replaying workflows much easier.
6. AI agents and tools
Agents become useful when a task requires multiple actions:
User request
│
▼
Agent
/ | Search DB API
|
n8n tools
I still limit the tools exposed to the agent. Each tool should have a clear responsibility and minimum permissions.
Reducing hallucinations
I prefer to:
- give the model only the required context;
- enforce an output schema;
- validate fields;
- retrieve critical facts from trusted sources;
- require human confirmation for sensitive actions.
AI should interpret or propose. Deterministic systems should control.
Reliability and idempotency
A webhook can be received twice. A workflow can also be retried.
I therefore create event identifiers and prevent duplicate writes:
INSERT INTO automation_events (event_id, status)
VALUES ($1, 'processed')
ON CONFLICT (event_id) DO NOTHING;
This becomes essential as soon as automation touches business data.
My approach
I do not try to replace the entire backend with AI.
Instead, I build pipelines where:
n8n orchestrates → the LLM interprets → code validates → PostgreSQL persists → humans intervene when necessary.
That combination is what makes intelligent automation genuinely useful in production.
