Building Enterprise AI Autonomous Agents in Self-Hosted n8n with Qdrant Vector Memory
Overview
n8n is an open-source workflow automation platform that supports AI agent orchestration. By pairing self-hosted n8n with a local Qdrant vector database and an Ollama inference container, engineering teams can build fully sovereign AI agents that process sensitive documents without sending data to third-party APIs.
This guide provides the complete Docker Compose architecture for launching n8n with Qdrant vector memory.
Architecture Blueprint
┌────────────────────────────────────────────────────────┐
│ SELF-HOSTED DOCKER STACK │
│ │
│ ┌────────────────────────┐ Trigger / Webhook │
│ │ n8n Automation Engine │ ◄───────────────────────── │
│ └───────────┬────────────┘ │
│ │ Vector Memory Queries (Port 6333) │
│ ▼ │
│ ┌────────────────────────┐ │
│ │ Qdrant Vector DB │ │
│ └───────────┬────────────┘ │
│ │ Embedding & Chat Completions │
│ ▼ │
│ ┌────────────────────────┐ │
│ │ Local Ollama Service │ │
│ └────────────────────────┘ │
└────────────────────────────────────────────────────────┘
Docker Compose Manifest
Create /opt/n8n-agent-stack/docker-compose.yml:
version: "3.8"
services:
qdrant:
image: qdrant/qdrant:v1.9.2
container_name: qdrant_db
restart: unless-stopped
volumes:
- qdrant_storage:/qdrant/storage
ports:
- "6333:6333"
n8n:
image: docker.n8n.io/n8nio/n8n:latest
container_name: n8n_engine
restart: unless-stopped
ports:
- "5678:5678"
environment:
- N8N_BASIC_AUTH_ACTIVE=true
- N8N_BASIC_AUTH_USER=admin
- N8N_BASIC_AUTH_PASSWORD=${N8N_PASSWORD}
volumes:
- n8n_data:/home/node/.n8n
depends_on:
- qdrant
volumes:
qdrant_storage:
n8n_data:
Summary Checklist
- Deployed n8n and Qdrant in shared Docker environment.
- Configured Qdrant vector store nodes in n8n AI workflow canvas.
- Connected local Ollama embeddings model (
nomic-embed-text).
Self-Hosted Autonomous Agent Architecture
Building sovereign AI agent workflows requires decoupling workflow orchestration (n8n), vector similarity indexing (Qdrant), and LLM text generation (vLLM / Ollama) into isolated container networks.
In this architecture, n8n executes autonomous agent chains by fetching relevant context from Qdrant via gRPC hybrid search, injecting vector payload context into system prompts, and calling local LLM endpoints—ensuring zero data leakage to external cloud APIs.
+-------------------------------------------------------------------------+
| Sovereign Autonomous Agent Topology |
| +-------------------------------------------------------------------+ |
| | n8n Workflow Engine (Agent Core) | |
| +-------------------------------------------------------------------+ |
| || Vector Query (gRPC Port 6334) || Inference API |
| \/ \/ |
| +-----------------------------------+ +---------------------------+ |
| | Qdrant Vector Engine | | Ollama / vLLM LLM Engine | |
| | (HNSW Index + Sparse Vectors) | | (Llama 3.3 / Qwen 2.5) | |
| +-----------------------------------+ +---------------------------+ |
+-------------------------------------------------------------------------+
Step 1: Production Docker Compose Stack (docker-compose.yml)
version: '3.8'
services:
n8n:
image: docker.n8n.io/n8nio/n8n:latest
container_name: n8n-agent-core
restart: always
ports:
- "5678:5678"
environment:
- N8N_HOST=n8n.local
- N8N_PORT=5678
- N8N_PROTOCOL=http
- NODE_ENV=production
- WEBHOOK_URL=http://localhost:5678/
- EXECUTIONS_DATA_PRUNE=true
- EXECUTIONS_DATA_MAX_AGE=168
volumes:
- n8n_data:/home/node/.n8n
qdrant:
image: qdrant/qdrant:latest
container_name: qdrant-vector-db
restart: always
ports:
- "6333:6333" # HTTP REST
- "6334:6334" # gRPC
volumes:
- qdrant_storage:/qdrant/storage
volumes:
n8n_data:
qdrant_storage:
Step 2: Python Script for Vector Collection Initialization
Execute vector schema initialization before connecting n8n workflows:
from qdrant_client import QdrantClient
from qdrant_client.models import VectorParams, Distance, OptimizersConfigDiff
client = QdrantClient(host="localhost", port=6333)
collection_name = "enterprise_knowledge_base"
if not client.collection_exists(collection_name):
client.create_collection(
collection_name=collection_name,
vectors_config=VectorParams(
size=1536, # Compatible with bge-large or OpenAI embeddings
distance=Distance.COSINE
),
optimizers_config=OptimizersConfigDiff(
default_segment_number=4
)
)
print(f"[+] Qdrant collection '{collection_name}' successfully created.") OpsNexusAI Engineering
Verified Lab PublicationOpsNexusAI is a technical laboratory dedicated to sovereign AI infrastructure. Every implementation guide and architectural blueprint published here is tested on physical hardware and isolated networks. Our team specializes in the deployment of private LLMs, network hardening with OPNsense, and enterprise-grade automation patterns.
Join the OpsNexus Brief
Get technical teardowns on sovereign AI architectures delivered to your inbox.