Nội dung bài họcLesson content
n8n là gì?What is n8n?
n8n là công cụ automation workflow mã nguồn mở. Kéo thả nodes (webhook, HTTP, AI, database, email) thành pipeline. Tự động hóa: khi có email → AI phân loại → lưu database → gửi notification. n8n tự host hoặc dùng cloud n8n.io.n8n is an open-source automation workflow tool. Drag and drop nodes (webhook, HTTP, AI, database, email) into a pipeline. Automate: when email arrives → AI classifies → save to database → send notification. Self-host or use n8n.io cloud.
Workflow: Webhook → AI → DatabaseWorkflow: Webhook → AI → Database
Pipeline điển hình: (1) Webhook node nhận POST request. (2) OpenAI node phân tích nội dung. (3) Postgres/SQLite node lưu kết quả. (4) Email node gửi thông báo. Mỗi node nhận output từ node trước, xử lý, gửi cho node sau.A typical pipeline: (1) Webhook node receives POST request. (2) OpenAI node analyzes content. (3) Postgres/SQLite node saves result. (4) Email node sends notification. Each node takes the previous node's output, processes it, sends to the next.
Webhook node: nhận triggerWebhook node: receiving triggers
Webhook node tạo URL endpoint. Khi có HTTP request đến, workflow chạy. Cấu hình: method (GET/POST), path, auth. Webhook URL: https://your-n8n.com/webhook/abc123. Test bằng curl hoặc Postman. Webhook là điểm bắt đầu phổ biến nhất cho workflow.A Webhook node creates a URL endpoint. When an HTTP request arrives, the workflow runs. Configure: method (GET/POST), path, auth. Webhook URL: https://your-n8n.com/webhook/abc123. Test with curl or Postman. Webhooks are the most common workflow starting point.
# Test webhook bằng curl
curl -X POST https://your-n8n.com/webhook/abc123 \
-H "Content-Type: application/json" \
-d '{
"email": "[email protected]",
"subject": "Hỏi về sản phẩm",
"body": "Cho tôi hỏi giá sản phẩm X"
}'
# Workflow:
# 1. Webhook nhận request
# 2. OpenAI phân loại: "sales inquiry"
# 3. Database lưu: email, category, timestamp
# 4. Email notify: [email protected]
AI node: tích hợp OpenAIAI node: integrating OpenAI
n8n có OpenAI node tích hợp sẵn. Cấu hình: API key, model (gpt-4o-mini), prompt. Input từ node trước (vd: email body). Output là text AI trả về. Dùng cho: phân loại, tóm tắt, trả lời tự động, trích xuất thông tin.n8n has a built-in OpenAI node. Configure: API key, model (gpt-4o-mini), prompt. Input from the previous node (e.g., email body). Output is the AI's text response. Use for: classification, summarization, auto-reply, information extraction.