AI Platforms & Automation
AI platforms and automation tools help you rapidly build AI applications and automation workflows, integrating large language model capabilities into real business processes. This article covers deploying and using Dify, n8n, and LangChain/LangGraph on Ubuntu 26.04.
Dify
Dify is an open-source LLM application development platform that provides visual prompt orchestration, RAG (Retrieval-Augmented Generation), agent workflows, and more, with support for multiple model providers.
System Requirements
- Docker and Docker Compose
- At least 4GB RAM
- At least 20GB disk space
Docker Compose Deployment
# Install Docker (if not already installed)
sudo apt update
sudo apt install -y docker.io docker-compose-v2
sudo usermod -aG docker $USER
newgrp docker
# Clone the Dify repository
git clone https://github.com/langgenius/dify.git
cd dify/docker
# Copy the environment variable configuration file
cp .env.example .env
# Edit the configuration file (modify as needed)
nano .envKey configuration items:
# Important settings in .env file
# Secret key (must change to a random value)
SECRET_KEY=your-random-secret-key-here
# Database configuration
DB_USERNAME=postgres
DB_PASSWORD=your-secure-password
DB_HOST=db
DB_PORT=5432
DB_DATABASE=dify
# Redis configuration
REDIS_HOST=redis
REDIS_PORT=6379
REDIS_PASSWORD=your-redis-password
# Storage configuration
STORAGE_TYPE=local
STORAGE_LOCAL_PATH=storage
# Web configuration
WEB_API_URL=http://localhost/api# Start Dify
docker compose up -d
# Check startup status
docker compose ps
# View logs
docker compose logs -f
# Wait for all services to start (about 1-2 minutes)Access Dify
# Dify web interface defaults to port 80
# Open your browser and visit
# http://localhost
# First visit requires setting up an admin account
# Set email and password, then log inBasic Usage
Dify’s main feature modules:
-
Apps — Create and manage AI applications
- Chat Assistant — Build chatbots
- Text Generation — Create text generation apps
- Agent — Create autonomous AI agents
- Workflow — Visually orchestrate complex AI processes
-
Knowledge — RAG functionality
- Upload documents (PDF, Word, Markdown, etc.)
- Automatic segmentation and vectorization
- Reference knowledge base content in conversations
-
Model Providers — Configure AI models
Configure Model Providers
Add models in Dify settings:
# Connect OpenAI
# Settings > Model Providers > OpenAI > Enter API Key
# Connect Anthropic (Claude)
# Settings > Model Providers > Anthropic > Enter API Key
# Connect local Ollama
# Settings > Model Providers > Ollama
# Model name: qwen2.5:14b
# Base URL: http://host.docker.internal:11434
# (Use host.docker.internal to access host machine from Docker)If Ollama is running on the host machine, configure it to allow Docker container access:
# Modify Ollama listen address
sudo systemctl edit ollama
# Add:
# [Service]
# Environment="OLLAMA_HOST=0.0.0.0:11434"
sudo systemctl restart ollamaUpdate Dify
cd ~/dify/docker
# Pull latest code
git pull origin main
# Update images and restart
docker compose pull
docker compose down
docker compose up -dBackup Data
# Backup Dify data (database and storage)
cd ~/dify/docker
# Stop services
docker compose down
# Backup data volumes
sudo tar -czf ~/dify-backup-$(date +%Y%m%d).tar.gz \
./volumes/
# Restart services
docker compose up -dDify supports calling your created applications via API. You can get API keys and call examples in the app settings. This means you can visually build AI applications in Dify, then integrate them into your own products through the API.
n8n
n8n is a powerful visual workflow automation tool with hundreds of integration nodes, including AI-related nodes (OpenAI, Ollama, vector databases, etc.), making it easy to build AI automation workflows.
Install n8n
Method 1: Docker Installation (Recommended)
# Create data directory
mkdir -p ~/.n8n
# Run n8n with Docker
docker run -d \
--name n8n \
-p 5678:5678 \
-v ~/.n8n:/home/node/.n8n \
-e N8N_SECURE_COOKIE=false \
--restart always \
n8nio/n8nMethod 2: Docker Compose Installation
mkdir -p ~/n8n && cd ~/n8n
cat > docker-compose.yml << 'EOF'
services:
n8n:
image: n8nio/n8n
container_name: n8n
ports:
- "5678:5678"
environment:
- N8N_SECURE_COOKIE=false
- GENERIC_TIMEZONE=Asia/Shanghai
volumes:
- n8n_data:/home/node/.n8n
extra_hosts:
- "host.docker.internal:host-gateway"
restart: always
volumes:
n8n_data:
EOF
docker compose up -dMethod 3: npm Global Installation
# Install Node.js
curl -fsSL https://deb.nodesource.com/setup_24.x | sudo -E bash -
sudo apt install -y nodejs
# Install n8n globally
npm install -g n8n
# Start n8n
n8n start
# Or run in background
n8n start &Access n8n
# Open your browser
# http://localhost:5678
# First visit requires creating an accountAI Workflow Examples
n8n has built-in AI nodes for building powerful AI automation workflows.
Example 1: AI Customer Service Auto-Reply
Workflow node connections:
Webhook Trigger -> AI Agent (Claude/GPT) -> Knowledge Base Retrieval -> Generate Reply -> Send ResponseExample 2: Document Auto-Summary
File Monitor -> Read File -> AI Summary Generation -> Save Result -> Email NotificationExample 3: Connect Local Ollama
Configure Ollama connection in n8n:
- Add an “Ollama Chat Model” node to your workflow
- Create Ollama credentials:
- Base URL:
http://host.docker.internal:11434(Docker environment) - Or
http://localhost:11434(local installation)
- Base URL:
- Select a model (e.g.,
qwen2.5:14b)
AI Nodes in n8n
| Node Type | Purpose |
|---|---|
| AI Agent | Create autonomous AI agents |
| OpenAI Chat Model | Connect to OpenAI/compatible APIs |
| Ollama Chat Model | Connect to local Ollama |
| Anthropic Chat Model | Connect to Claude |
| Vector Store | Vector database operations |
| Text Splitter | Text segmentation |
| Embeddings | Text vectorization |
| Memory | Conversation memory management |
| Tool | Custom AI tools |
Create an AI Agent Workflow
1. Add a "When chat message received" trigger
2. Add an "AI Agent" node
3. Connect a model: Add an "Ollama Chat Model" sub-node
4. Add tools:
- "Calculator" -- Math calculations
- "Code" -- Execute code
- "HTTP Request" -- Call APIs
- "Wikipedia" -- Search Wikipedia
5. Add memory: Connect a "Window Buffer Memory" node
6. Save and activate the workflowThe n8n community edition (self-hosted) is completely free and includes all AI nodes. n8n Cloud offers a hosted service with additional features. For individuals and small teams, the self-hosted version is already quite powerful.
LangChain / LangGraph
LangChain is the leading development framework for building LLM applications. LangGraph is its sub-project focused on building stateful, multi-step AI agent workflows.
Install LangChain
# Create a project virtual environment
mkdir -p ~/langchain-project && cd ~/langchain-project
python3 -m venv venv
source venv/bin/activate
# Install LangChain core packages
pip install langchain langchain-core
# Install model provider packages
pip install langchain-anthropic # Claude
pip install langchain-openai # OpenAI
pip install langchain-ollama # Ollama (local models)
# Install LangGraph
pip install langgraph
# Install common tools
pip install langchain-community # Community integrations
pip install langchain-chroma # Chroma vector database
pip install langchain-text-splitters # Text splittingLangChain Basic Example
# basic_chain.py
from langchain_ollama import ChatOllama
from langchain_core.prompts import ChatPromptTemplate
from langchain_core.output_parsers import StrOutputParser
# Use local Ollama model
llm = ChatOllama(model="qwen2.5:14b", base_url="http://localhost:11434")
# Create a prompt template
prompt = ChatPromptTemplate.from_messages([
("system", "You are an Ubuntu Linux expert skilled at answering system administration questions."),
("human", "{question}")
])
# Build the chain
chain = prompt | llm | StrOutputParser()
# Invoke the chain
response = chain.invoke({"question": "How do I check disk usage on Ubuntu?"})
print(response)# Run the example
python basic_chain.pyRAG Example (Retrieval-Augmented Generation)
# rag_example.py
from langchain_ollama import ChatOllama, OllamaEmbeddings
from langchain_chroma import Chroma
from langchain_text_splitters import RecursiveCharacterTextSplitter
from langchain_core.prompts import ChatPromptTemplate
from langchain_core.runnables import RunnablePassthrough
from langchain_core.output_parsers import StrOutputParser
# 1. Prepare documents
documents = [
"Ubuntu 26.04 LTS, codenamed Resolute Raccoon, is scheduled for release on April 23, 2026.",
"Ubuntu uses APT as its package manager. You can install software with apt install.",
"Ubuntu's default desktop environment is GNOME, but it also supports KDE, XFCE, etc.",
"Ubuntu Server edition does not include a graphical interface, making it suitable for server deployments.",
]
# 2. Split text
text_splitter = RecursiveCharacterTextSplitter(
chunk_size=200, chunk_overlap=50
)
splits = text_splitter.create_documents(documents)
# 3. Create vector database
embeddings = OllamaEmbeddings(model="nomic-embed-text")
vectorstore = Chroma.from_documents(splits, embeddings)
retriever = vectorstore.as_retriever()
# 4. Build RAG chain
llm = ChatOllama(model="qwen2.5:14b")
prompt = ChatPromptTemplate.from_template("""
Answer the question based on the following context. If the answer is not in the context, say you don't know.
Context: {context}
Question: {question}
""")
rag_chain = (
{"context": retriever, "question": RunnablePassthrough()}
| prompt
| llm
| StrOutputParser()
)
# 5. Query
result = rag_chain.invoke("What is the codename for Ubuntu 26.04?")
print(result)# Install additional dependencies and run
pip install chromadb
python rag_example.pyLangGraph Agent Example
# agent_example.py
from langchain_ollama import ChatOllama
from langgraph.prebuilt import create_react_agent
from langchain_core.tools import tool
# Define tools
@tool
def search_docs(query: str) -> str:
"""Search Ubuntu documentation for information"""
docs = {
"apt": "APT is Ubuntu's package management tool. Use apt install to install software",
"systemd": "systemd is Ubuntu's service management system. Use systemctl to manage services",
}
for key, value in docs.items():
if key in query.lower():
return value
return "No relevant documentation found"
@tool
def run_command(command: str) -> str:
"""Simulate running a Linux command and return the result"""
return f"Command '{command}' executed (simulated)"
# Create Agent
llm = ChatOllama(model="qwen2.5:14b")
agent = create_react_agent(llm, [search_docs, run_command])
# Run Agent
result = agent.invoke({
"messages": [{"role": "user", "content": "How do I install nginx on Ubuntu?"}]
})
for message in result["messages"]:
print(f"[{message.type}]: {message.content}")LangSmith Debugging (Optional)
# LangSmith provides visual debugging and monitoring for LangChain applications
# Register at https://smith.langchain.com to get an API key
export LANGCHAIN_TRACING_V2=true
export LANGCHAIN_API_KEY="your-langsmith-api-key"
export LANGCHAIN_PROJECT="my-ubuntu-project"
# LangChain code run afterward will automatically report chain data to LangSmithLangChain’s ecosystem is vast. Beginners should start with simple Chains, then gradually progress to RAG and Agents. LangGraph is best for building complex multi-step agents. For simple conversational applications, basic LangChain Chains are sufficient.
Platform Comparison
| Feature | Dify | n8n | LangChain |
|---|---|---|---|
| Type | Visual platform | Workflow automation | Development framework |
| Usage | Web interface | Web interface | Python code |
| Learning curve | Low | Medium | Higher |
| Flexibility | Medium | High | Very high |
| RAG support | Built-in | Via nodes | Via code |
| Agent support | Built-in | Via AI nodes | LangGraph |
| Deployment | Docker | Docker/npm | pip |
| Best for | Non-technical users | Automation enthusiasts | Developers |
| Open source | Yes | Yes (Community Edition) | Yes |
Choosing the Right Tool
- Want to build AI apps quickly without code —> Choose Dify
- Need to integrate AI into automation workflows —> Choose n8n
- Need fully customized AI applications and know Python —> Choose LangChain/LangGraph
- You can combine them: Use Dify for rapid prototyping, n8n for automation scheduling, and LangChain for core logic