Node-RED for AI Automation
What This Article Covers
- How to install and configure Node-RED for AI automation.
- How to connect Node-RED with Ollama and use local models in flows.
- How to implement function calling, RAG, and agent workflows in Node-RED.
- Practical examples for email sorting, document summarization, and notifications.
- Best practices for security, performance, and maintenance.
Introduction: Node-RED for AI Automation Explained
Node-RED is a visual programming tool for automation. Originally developed by IBM to connect IoT devices and APIs, it’s now used for everything from smart homes to enterprise integration. Combined with local AI, Node-RED becomes a powerful platform for building AI workflows visually without writing code.
This article is for people who want to run AI automation with local models and use Node-RED as their platform. You should understand what local AI is and how Ollama works. For programming fundamentals, see IRC-Coding.de.
Why Use Node-RED for AI Automation?
Imagine you want to sort emails automatically, summarize documents, and send notifications, all with local AI. You could write a Python script, but it quickly becomes messy. Node-RED lets you build these workflows visually: one node receives email, another classifies it with AI, and another takes action.
Node-RED is especially useful when you need multi-step workflows that connect different APIs and should be modifiable by non-programmers. The visual interface makes workflows understandable, and the flow editor enables rapid experimentation.
Node-RED for AI Automation: The Essentials
Node-RED is a browser-based flow editor where you connect nodes via drag-and-drop. Each node does one thing: receive email, send an HTTP request, execute JavaScript, or call AI. For AI automation, you connect input nodes (email, webhook, schedule) with AI nodes (Ollama, OpenAI) and output nodes (email, Slack, database).
The core idea: Node-RED is the visual bridge between input, AI, and output.
Who Should Read This?
- Automation enthusiasts wanting to integrate AI into existing workflows.
- Self-hosters using local AI for automation and looking for an interface.
- Developers evaluating visual workflow tools.
- Teams building workflows that non-programmers can understand.
Familiarity with local AI, Ollama, and basic JavaScript is helpful.
Key Terms
- Node-RED - Visual flow editor for automation. Useful when: building workflows visually.
- Ollama - Local model server. Useful when: serving as the AI backend for Node-RED.
- Node - A single element in a flow. Useful when: performing one task, like making an HTTP request.
- Flow - Connected nodes forming a workflow. Useful when: creating a complete automation script.
- Function Calling - AI function returning structured data. Useful when: making AI-driven decisions.
- RAG - Retrieval-Augmented Generation. Useful when: extending models with custom data.
- Docker - Container platform. Useful when: running Node-RED in isolation.
- Inject Node - Starts a flow manually or on a schedule. Useful when: testing and scheduling tasks.
Installing Node-RED
With Docker
docker run -d \
--name nodered \
-p 1880:1880 \
-v nodered-data:/data \
--restart unless-stopped \
nodered/node-red
Then open http://localhost:1880 in your browser.
With npm
npm install -g node-red
node-red
With Proxmox LXC
If you use Proxmox VE, you can install Node-RED in an LXC container:
# Inside the LXC container
npm install -g node-red
# Set up as a service
npm install -g pm2
pm2 start node-red
pm2 startup
pm2 save
Connecting Ollama to Node-RED
Preparing Ollama
Make sure Ollama is running and a model is loaded:
ollama pull llama3.1
ollama serve
HTTP Request Node in Node-RED
Node-RED has a built-in HTTP Request node you can use with Ollama:
- Drag an
injectnode into your flow. - Drag a
functionnode and set the payload:msg.payload = { model: "llama3.1", messages: [ { role: "user", content: msg.payload.prompt || "Hello" } ], stream: false }; msg.headers = { "Content-Type": "application/json" }; return msg; - Drag an
http requestnode and configure:- Method: POST
- URL:
http://localhost:11434/api/chat - Return: parsed JSON
- Connect the nodes:
inject→function→http request→debug.
Click the Inject button, and you’ll see Ollama’s response in the Debug panel.
Community Nodes for Ollama
Several community nodes provide direct Ollama support:
- node-red-contrib-ollama - Direct Ollama integration with chat and embedding nodes.
- node-red-contrib-openai - OpenAI-compatible, works with Ollama.
Install via the Palette Manager in Node-RED:
Manage Palette → Install → "node-red-contrib-ollama"
Practical Example 1: Email Sorting with AI
This example sorts incoming emails by category using Ollama to determine the right classification.
Flow Structure
- IMAP Node (Incoming emails)
- Function Node (Build prompt):
msg.payload = { model: "llama3.1", messages: [ { role: "system", content: "You are an email classifier. Reply with only one of these categories: support, sales, billing, spam, other." }, { role: "user", content: `Subject: ${msg.topic}\nContent: ${msg.payload}` } ], stream: false }; msg.headers = { "Content-Type": "application/json" }; return msg; - HTTP Request Node (Call Ollama)
- Switch Node (Branch by category)
- Output Nodes (Move email to folder, notify Slack, etc.)
Advantages
- Emails sort automatically without manual rules.
- Add new categories by adjusting the system prompt.
- Local AI means no cloud dependency and no privacy concerns.
Limitations
- Each email takes inference time (seconds to minutes).
- Misclassifications are possible, especially with ambiguous messages.
- The model should be evaluated regularly.
Practical Example 2: Document Summarization
This example summarizes PDF documents that land in a folder.
Flow Setup
- File Node (monitor directory for PDFs)
- Function Node (extract text using
pdf-parse):const pdf = require('pdf-parse'); const buffer = msg.payload; pdf(buffer).then(data => { msg.payload = { model: "llama3.1", messages: [ { role: "system", content: "Summarize this document in 5 sentences." }, { role: "user", content: data.text.substring(0, 4000) } ], stream: false }; msg.headers = { "Content-Type": "application/json" }; node.send(msg); }); - HTTP Request Node (call Ollama)
- File Node (save summary)
Important Notes
- Large documents need to be chunked, since models have a context window limit.
- For better summaries, use models with larger context, such as
qwen2.5:32k. - See context length for details.
Practical Example 3: AI-Filtered Notifications
This example filters system notifications and forwards only important ones.
Flow Setup
- Webhook Node (receive notification)
- Function Node (build prompt):
msg.payload = { model: "llama3.1", messages: [ { role: "system", content: "Determine whether this notification is important. Respond with 'important' or 'unimportant'." }, { role: "user", content: msg.payload.message } ], stream: false }; msg.headers = { "Content-Type": "application/json" }; return msg; - HTTP Request Node (call Ollama)
- Switch Node (forward only if marked ‘important’)
- Slack Node (send notification)
Function Calling in Node-RED
Function Calling lets you retrieve structured data from the AI that you can process further in Node-RED.
Example: Structured Email Response
// Function Node
msg.payload = {
model: "llama3.1",
messages: [
{
role: "system",
content: "You are an email assistant. Respond in JSON format: {\"category\": \"...\", \"priority\": \"...\", \"response\": \"...\"}"
},
{ role: "user", content: msg.payload.email }
],
format: "json",
stream: false
};
msg.headers = { "Content-Type": "application/json" };
return msg;
After the HTTP Request Node, you can process the JSON response directly, for example, branching with a Switch Node based on category.
See Function Calling for details.
RAG in Node-RED
RAG requires a vector database and embeddings. Node-RED can handle both:
-
Embeddings from Ollama:
msg.payload = { model: "nomic-embed-text", prompt: msg.payload.text }; msg.headers = { "Content-Type": "application/json" }; return msg;URL:
http://localhost:11434/api/embeddings -
Vector database: Use
node-red-contrib-chromafor ChromaDB or build HTTP requests to Pinecone, Qdrant, or Weaviate. -
RAG flow: Query, Embedding, Vector Search, build context, Ollama chat with context.
See Local RAG for details.
Security Considerations
- Secure Node-RED: Set a password by editing
settings.js. By default, Node-RED runs without authentication. - No secrets in flows: Use environment variables instead of hardcoded API keys.
- Keep Ollama local: Do not expose Ollama to the internet without authentication. See API Keys.
- Sandbox for Function Nodes: Function Nodes can execute arbitrary JavaScript. Restrict access to the flow editor.
- Audit Logging: Enable logging for Node-RED to track actions. See Audit Logging.
Performance Tips
- Small model for classification: Use a smaller model like
llama3.1:8bfor simple classification tasks, a larger one for complex work. - Caching: Cache recurring requests to save inference time.
- Batching: Collect multiple requests and send them together when possible.
- Streaming: Use streaming for long responses to reduce latency.
- Asynchronous processing: Use queues to handle traffic spikes.
Common Pitfalls
- No authentication: Node-RED has no password by default, a security risk.
- Models too large: A 70B model for simple classification is overkill and slow.
- Missing error handling: If Ollama is unreachable, the flow should catch errors instead of crashing.
- Ignoring context length: Large documents must be chunked or inference will fail.
- No testing: Workflows should be tested before going to production.
Further Resources on Node-RED
- Node-RED Documentation - Official Node-RED docs.
- Install Ollama - Backend for Node-RED.
- Function Calling - Structured AI responses.
- Local RAG - RAG with local AI.
- Automation Basics - AI automation fundamentals.
- Proxmox VE - Run Node-RED in LXC.
- API Keys - Secure Ollama.
Key Takeaways:
- Node-RED is a visual flow editor for automation.
- With Ollama as backend, you can use local AI in workflows.
- Practical examples: email sorting, document summarization, notification filtering.
- Function Calling and RAG are implementable in Node-RED.
- Security: secure Node-RED, keep secrets out of flows, run Ollama locally only.
FAQ: Node-RED for AI Automation - Common Questions
What is Node-RED?
How do I connect Node-RED to Ollama?
Can I use Function Calling in Node-RED?
Can I implement RAG in Node-RED?
How do I secure Node-RED?
Can I run Node-RED in Docker?
Which model should I use?
How can I improve performance?
Is Node-RED free?
Are there alternatives to Node-RED?
Sources and Further Reading
- Node-RED Documentation - Official documentation.
- Ollama API - API reference.
- Node-RED Ollama Node - Community nodes.
- Automation Basics - Fundamentals of AI automation.


