MinAI - Về trang chủ
Lý thuyết
6/1335 phút
Đang tải...

Email Classification nâng cao

Xây dựng hệ thống phân loại email thông minh với AI trong n8n

📬 Email Classification nâng cao

0

🎯 Mục tiêu bài học

TB5 min

Sau bài học này, bạn sẽ:

✅ Xây dựng multi-level email classification system

✅ Implement routing logic dựa trên classification results

✅ Tạo smart labeling và confidence-based routing

✅ Track classification metrics cho analytics

Nâng cấp từ basic classification sang multi-level system với confidence scoring và auto-routing.

1

🏗️ Architecture

TB5 min
Diagram
Đang vẽ diagram...

Checkpoint

Mô tả architecture của multi-level email classification system?

2

📊 Multi-Level Classification

TB5 min
JavaScript
1// Code node: Build classification prompt
2const classifyPrompt = `
3Analyze this email and classify on multiple dimensions:
4
5Subject: ${$json.subject}
6From: ${$json.from}
7Body: ${$json.body}
8
9Classify with:
101. **Category**: support, sales, billing, partnership, spam, internal, personal
112. **Priority**: critical, high, medium, low
123. **Sentiment**: positive, negative, neutral, angry
134. **Intent**: question, complaint, request, information, feedback
145. **Department**: engineering, marketing, sales, hr, finance, general
15
16Return JSON:
17{
18 "category": "...",
19 "priority": "...",
20 "sentiment": "...",
21 "intent": "...",
22 "department": "...",
23 "confidence": 0.0-1.0,
24 "summary": "one-line summary",
25 "suggestedAction": "..."
26}`;
27
28return { prompt: classifyPrompt };

Checkpoint

Email được classify trên những dimensions nào?

3

🔧 Routing Logic

TB5 min
JavaScript
1// Code node: Route based on classification
2const result = JSON.parse($json.message.content);
3
4let route = "general";
5let actions = [];
6
7// Priority routing
8if (result.priority === "critical") {
9 actions.push("send_slack_alert");
10 actions.push("notify_manager");
11}
12
13// Category routing
14switch (result.category) {
15 case "support":
16 route = "support_team";
17 actions.push("create_ticket");
18 break;
19 case "sales":
20 route = "crm";
21 actions.push("create_lead");
22 break;
23 case "spam":
24 route = "archive";
25 actions.push("mark_spam");
26 break;
27 case "billing":
28 route = "finance";
29 actions.push("create_ticket");
30 break;
31}
32
33// Sentiment-based escalation
34if (result.sentiment === "angry" && result.priority !== "critical") {
35 result.priority = "high";
36 actions.push("escalate");
37}
38
39return {
40 ...result,
41 route,
42 actions,
43 processedAt: new Date().toISOString()
44};

Checkpoint

Sentiment-based escalation hoạt động như thế nào?

4

🏷️ Smart Labeling

TB5 min
Diagram
Đang vẽ diagram...
JavaScript
1// Code node: Generate Gmail labels
2const classification = $json;
3const labels = [];
4
5labels.push(`Priority/${classification.priority}`);
6labels.push(`Category/${classification.category}`);
7labels.push(`Department/${classification.department}`);
8
9if (classification.sentiment === "angry") {
10 labels.push("Needs-Attention");
11}
12
13return { labels, threadId: $json.threadId };

Checkpoint

Gmail labels được tạo tự động dựa trên những thông tin nào?

5

⚡ Confidence-Based Routing

TB5 min
JavaScript
1// IF node conditions
2// Branch 1: High confidence (auto-process)
3// Condition: $json.confidence >= 0.85
4
5// Branch 2: Medium confidence (review queue)
6// Condition: $json.confidence >= 0.5 AND < 0.85
7
8// Branch 3: Low confidence (manual)
9// Condition: $json.confidence < 0.5
Threshold Tuning

Bắt đầu với threshold 0.85 cho auto-routing. Monitor accuracy trong 1 tuần, rồi adjust. Nếu accuracy trên 95%, có thể giảm threshold xuống 0.8.

Checkpoint

Ba mức confidence routing là gì và threshold ban đầu nên đặt bao nhiêu?

6

📊 Analytics Dashboard

TB5 min
JavaScript
1// Code node: Track classification metrics
2const metrics = {
3 timestamp: new Date().toISOString(),
4 category: $json.category,
5 priority: $json.priority,
6 confidence: $json.confidence,
7 autoRouted: $json.confidence >= 0.85,
8 processingTime: Date.now() - $json.receivedAt
9};
10
11// Save to Google Sheets or database for analytics
12return metrics;

Checkpoint

Những metrics nào cần track để đánh giá classification system?

7

📝 Bài Tập Thực Hành

TB5 min
Exercises
  1. Build multi-level email classifier với 5 categories
  2. Implement confidence-based routing (auto vs manual)
  3. Add Gmail label automation based on classification
  4. Track metrics: accuracy, processing time, distribution

Checkpoint

Bạn đã hoàn thành multi-level classifier chưa? Accuracy đạt bao nhiêu?

🚀 Bài tiếp theo

Email Summarization — Tự động tóm tắt email dài và tạo daily digest với AI.