📋 Email Summarization
🎯 Mục tiêu bài học
Sau bài học này, bạn sẽ:
✅ Xây dựng single email summarizer workflow
✅ Tạo thread summarizer cho email conversations dài
✅ Build daily digest workflow tự động
✅ Extract action items từ emails và integrate Slack
Biến inbox overload thành concise summaries. Build workflows tóm tắt email, tạo daily digest, và extract action items.
🔍 Use Cases
Checkpoint
Bốn use cases chính của email summarization là gì?
📧 Single Email Summarizer
1// OpenAI System Prompt2const systemPrompt = `3You are an email summarizer. For each email, provide:41. **TL;DR** (1 sentence, max 15 words)52. **Key Points** (2-4 bullet points)63. **Action Items** (tasks to do, or "None")74. **Deadline** (if mentioned, or "None")85. **Reply Needed** (yes/no)910Format as clean text, not JSON.11Keep the language same as the original email.12`;1314// User message15const userMessage = `16From: ${$json.from}17Subject: ${$json.subject}18Date: ${$json.date}1920${$json.body}21`;Checkpoint
AI Summarizer trích xuất những thông tin chính nào từ email?
🧠 Thread Summarizer
1// Code node: Combine thread messages2const messages = $json.messages; // Array from Gmail Get Thread34const threadContent = messages.map((msg, i) => `5--- Message ${i + 1} ---6From: ${msg.from}7Date: ${msg.date}8${msg.body}9`).join("\n");1011const prompt = `12Summarize this email thread:13- Number of messages: ${messages.length}14- Participants: list all15- Key decisions made16- Open questions17- Action items per person1819Thread:20${threadContent}21`;2223return { prompt, messageCount: messages.length };Checkpoint
Thread Summarizer khác gì so với Single Email Summarizer?
📊 Daily Digest Workflow
1// Code node: Prepare digest prompt2const emails = $input.all();34const emailList = emails.map((e, i) => `5[${i + 1}] From: ${e.json.from}6Subject: ${e.json.subject}7Preview: ${e.json.body.substring(0, 200)}8`).join("\n---\n");910const digestPrompt = `11Create a morning email digest from ${emails.length} emails received today.1213Format:14## Email Digest - ${new Date().toLocaleDateString()}15Total: ${emails.length} emails1617### Urgent (needs immediate attention)18- [subject] from [sender] - [1 line summary]1920### Important (respond today)21- ...2223### FYI (no action needed)24- ...2526### Action Items27- [ ] task from email X2829Emails:30${emailList}31`;3233return { prompt: digestPrompt };Checkpoint
Daily Digest chia emails thành những nhóm priority nào?
⚡ Action Item Extraction
1// OpenAI prompt for action item extraction2const extractPrompt = `3Extract all action items from this email.4For each action item:5- Task description6- Assigned to (if mentioned)7- Due date (if mentioned) 8- Priority (high/medium/low based on context)910Return JSON array:11[12 {13 "task": "...",14 "assignedTo": "...",15 "dueDate": "...",16 "priority": "..."17 }18]1920Email:21From: ${$json.from}22Subject: ${$json.subject}23Body: ${$json.body}24`;Checkpoint
Action Item Extraction trích xuất những trường dữ liệu nào?
🛠️ Slack Integration
1// Format for Slack message2const summary = $json.summary;3const slackMessage = {4 blocks: [5 {6 type: "header",7 text: {8 type: "plain_text",9 text: `Email Summary: ${$json.subject}`10 }11 },12 {13 type: "section", 14 text: {15 type: "mrkdwn",16 text: `*From:* ${$json.from}\n*TL;DR:* ${summary.tldr}`17 }18 },19 {20 type: "section",21 text: {22 type: "mrkdwn", 23 text: `*Key Points:*\n${summary.keyPoints.map(p => `• ${p}`).join('\n')}`24 }25 }26 ]27};2829return slackMessage;Set up Gmail filter để chỉ summarize emails dài hơn 200 words. Emails ngắn không cần summary.
Checkpoint
Làm thế nào để format email summary cho Slack notification?
📝 Bài Tập Thực Hành
- Build single email summarizer với Slack notifications
- Create daily digest workflow chạy lúc 8 AM
- Extract action items và tạo Todoist/Trello tasks tự động
- Build thread summarizer cho email conversations dài
Checkpoint
Bạn đã hoàn thành daily digest workflow chưa? Mô tả kết quả?
🚀 Bài tiếp theo
Blog Post Generator — Xây dựng pipeline tự động tạo blog posts với AI.
