🚀 快速安装
复制以下命令并运行,立即安装此 Skill:
npx skills add https://skills.sh/claude-office-skills/skills/gmail-workflows
💡 提示:需要 Node.js 和 NPM
Gmail 工作流 (Gmail Workflows)
通过智能工作流自动化 Gmail,实现附件管理、邮件整理和 Google Drive 集成。基于 n8n 的 7,800+ 工作流模板。
概述 (Overview)
此技能帮助您设计和实现 Gmail 自动化工作流,以实现:
- 自动将附件保存到 Google Drive
- 通过智能标签整理邮件
- 归档已处理的邮件
- 通过 Slack/邮件发送通知
- 跟踪邮件指标
核心工作流模板 (Core Workflow Templates)
1. Gmail 附件管理器 (Gmail Attachment Manager)
目的 (Purpose): 自动从邮件中提取附件并保存到 Google Drive
工作流步骤 (Workflow Steps):
┌─────────────┐ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐
│ Gmail │───▶│ 按条件筛选 │───▶│ 提取 │───▶│ 上传到 │
│ 触发器 │ │ (Filter by │ │ 附件 │ │ Google Drive│
│ (Trigger) │ │ Criteria) │ │ (Extract │ │ (Upload to │
└─────────────┘ └─────────────┘ │ Attachments)│ │ Google Drive│
│ └─────────────┘ └─────────────┘
│ │
│ ┌─────────────┐ │
└───────────▶│ 发送 │◀────────┘
│ 通知 │
│ (Send │
│ Notification│
└─────────────┘
配置 (Configuration):
trigger:
type: gmail_new_email
filters:
has_attachment: true
from: ["*@company.com", "*@vendor.com"]
subject_contains: ["发票 (invoice)", "报告 (report)", "合同 (contract)"]
actions:
- extract_attachments:
file_types: [pdf, xlsx, docx, csv]
max_size_mb: 25
- upload_to_drive:
folder_path: "/附件/{year}/{month} (/Attachments/{year}/{month})"
naming_pattern: "{文件名}_{发件人}_{日期} ({filename}_{sender}_{date})"
create_folder_if_missing: true
- organize_email:
apply_label: "已处理/附件 (Processed/Attachments)"
mark_as_read: true
archive: true
- notify:
channel: slack
message: "新附件已保存:{文件名} 来自 {发件人} (New attachment saved: {filename} from {sender})"
最佳实践 (Best Practices):
- 使用特定的发件人筛选条件以避免处理垃圾邮件 (Use specific sender filters to avoid processing spam)
- 设置文件大小限制以防止存储问题 (Set file size limits to prevent storage issues)
- 使用基于日期的文件夹结构以便于检索 (Use date-based folder structure for easy retrieval)
- 启用重复检测以避免重复上传 (Enable duplicate detection to avoid redundant uploads)
2. 发票自动归档器 (Invoice Auto-Archiver)
目的 (Purpose): 自动从邮件中收集和整理发票
工作流步骤 (Workflow Steps):
Gmail 触发器 → 检测发票 → 提取 PDF → OCR/解析 → 保存到云端硬盘 → 更新电子表格 → 归档邮件
(Gmail Trigger → Detect Invoice → Extract PDF → OCR/Parse → Save to Drive → Update Spreadsheet → Archive Email)
配置 (Configuration):
trigger:
subject_patterns:
- "invoice"
- "bill"
- "statement"
- "付款"
- "发票"
processing:
- detect_invoice:
methods: [主题关键词 (subject_keywords), 附件名称 (attachment_name), 发件人域名 (sender_domain)]
- extract_data:
fields: [发票号 (invoice_number), 金额 (amount), 日期 (date), 供应商 (vendor), 截止日期 (due_date)]
use_ocr: true
- save_to_drive:
folder: "/财务/发票/{year}/{vendor} (/Finance/Invoices/{year}/{vendor})"
naming: "{日期}_{供应商}_{金额} ({date}_{vendor}_{amount})"
- update_tracker:
spreadsheet: "发票跟踪表 (Invoice Tracker)"
columns: [日期 (Date), 供应商 (Vendor), 金额 (Amount), 发票号 (Invoice#), 状态 (Status), 文件链接 (File_Link)]
- archive:
label: "财务/发票 (Finance/Invoices)"
star: true
3. 客户沟通整理器 (Client Communication Organizer)
目的 (Purpose): 按项目/客户自动整理客户邮件
配置 (Configuration):
rules:
- name: "客户 A 邮件 (Client A Emails)"
condition:
from_domain: "clienta.com"
actions:
- apply_label: "客户/客户 A (Clients/Client A)"
- forward_to: "team-a@company.com"
- save_attachments: "/客户/客户 A/{主题} (/Clients/Client A/{subject})"
- name: "项目 X 更新 (Project X Updates)"
condition:
subject_contains: ["Project X", "PX-"]
actions:
- apply_label: "项目/项目 X (Projects/Project X)"
- add_to_task: "项目 X 看板 (Project X Board)"
- notify_slack: "#project-x"
- name: "紧急请求 (Urgent Requests)"
condition:
subject_contains: ["紧急 (URGENT)", "尽快 (ASAP)", "紧急"]
is_unread: true
actions:
- apply_label: "优先级/紧急 (Priority/Urgent)"
- send_sms: "+1234567890"
- move_to_inbox: true
4. 邮件分析仪表板 (Email Analytics Dashboard)
目的 (Purpose): 跟踪邮件指标并生成报告
要跟踪的指标 (Metrics to Track):
daily_metrics:
- emails_received: 计数(收件箱) (count-inbox)
- emails_sent: 计数(已发送) (count-sent)
- response_time_avg: 平均回复时间 (avg-reply_time)
- unread_count: 未读计数 (count-unread)
- attachment_count: 计数(有附件) (count-has_attachment)
weekly_report:
- top_senders: 按发件人分组计数 (group_by-from, count)
- busiest_hours: 按小时分组计数 (group_by-hour, count)
- label_distribution: 按标签分组计数 (group_by-label, count)
- response_rate: 已发送 / 已接收 (sent / received)
automation:
- schedule: "每周一上午 9 点 (every Monday 9am)"
- output: Google 表格 (Google Sheets)
- notify: Slack #email-metrics
实现指南 (Implementation Guide)
使用 n8n (Using n8n)
// n8n 工作流:Gmail 到 Google Drive (n8n Workflow: Gmail to Google Drive)
{
"nodes": [
{
"name": "Gmail 触发器 (Gmail Trigger)",
"type": "n8n-nodes-base.gmailTrigger",
"parameters": {
"pollTimes": { "item": [{ "mode": "everyMinute" }] },
"filters": { "labelIds": ["INBOX"] }
}
},
{
"name": "筛选附件 (Filter Attachments)",
"type": "n8n-nodes-base.if",
"parameters": {
"conditions": {
"boolean": [{
"value1": "={{ $json.hasAttachment }}",
"value2": true
}]
}
}
},
{
"name": "获取附件 (Get Attachments)",
"type": "n8n-nodes-base.gmail",
"parameters": {
"operation": "getAttachments",
"messageId": "={{ $json.id }}"
}
},
{
"name": "上传到云端硬盘 (Upload to Drive)",
"type": "n8n-nodes-base.googleDrive",
"parameters": {
"operation": "upload",
"folderId": "your-folder-id",
"name": "={{ $json.filename }}"
}
}
]
}
使用 Google Apps 脚本 (Using Google Apps Script)
// Gmail 到云端硬盘自动化 (Gmail to Drive Automation)
function processNewEmails() {
const threads = GmailApp.search('has:attachment is:unread');
const targetFolder = DriveApp.getFolderById('FOLDER_ID');
threads.forEach(thread => {
const messages = thread.getMessages();
messages.forEach(message => {
const attachments = message.getAttachments();
attachments.forEach(attachment => {
// 保存到云端硬盘 (Save to Drive)
const file = targetFolder.createFile(attachment);
// 使用日期和发件人重命名 (Rename with date and sender)
const newName = `${Utilities.formatDate(message.getDate(), 'GMT', 'yyyy-MM-dd')}_${message.getFrom()}_${attachment.getName()}`;
file.setName(newName);
});
// 标记为已处理 (Mark as processed)
message.markRead();
thread.addLabel(GmailApp.getUserLabelByName('已处理 (Processed)'));
});
});
}
// 设置触发器 (Set up trigger)
function setupTrigger() {
ScriptApp.newTrigger('processNewEmails')
.timeBased()
.everyMinutes(5)
.create();
}
常见工作流模式 (Common Workflow Patterns)
模式 1:筛选 → 处理 → 整理 → 通知 (Pattern 1: Filter → Process → Organize → Notify)
邮件到达 (Email arrives)
│
▼
┌─────────────────┐
│ 应用筛选条件 │ → 不匹配则跳过 (Skip if doesn't match)
│ (Apply Filters) │
└────────┬────────┘
│
▼
┌─────────────────┐
│ 处理内容 │ → 提取数据、附件 (Extract data, attachments)
│ (Process │
│ Content) │
└────────┬────────┘
│
▼
┌─────────────────┐
│ 整理 │ → 保存文件、应用标签 (Save files, apply labels)
│ (Organize) │
└────────┬────────┘
│
▼
┌─────────────────┐
│ 通知 │ → Slack、邮件、短信 (Slack, email, SMS)
│ (Notify) │
└─────────────────┘
模式 2:批量处理 (Pattern 2: Batch Processing)
schedule: "每天上午 6 点 (daily at 6am)"
steps:
1. 收集过去 24 小时内所有未处理的邮件 (Collect all unprocessed emails from last 24h)
2. 按类别分组(发票、报告、其他)(Group by category - invoices, reports, misc)
3. 批量上传到各自的云端硬盘文件夹 (Batch upload to respective Drive folders)
4. 生成摘要报告 (Generate summary report)
5. 向利益相关者发送每日摘要 (Send daily digest to stakeholders)
模式 3:条件路由 (Pattern 3: Conditional Routing)
conditions:
- if: 附件类型 == "pdf" 且 主题包含 "发票" (attachment_type == "pdf" AND subject contains "invoice")
then: 路由到财务文件夹 (route_to_finance_folder)
- if: 发件人域名 in ["important-client.com"]
then: 优先级处理 + 立即通知 (priority_handling + immediate_notification)
- if: 附件大小 > 10MB (attachment_size > 10MB)
then: 保存到大文件文件夹 + 跳过备份 (save_to_large_files_folder + skip_backup)
- default:
then: 标准处理 (standard_processing)
故障排除 (Troubleshooting)
常见问题 (Common Issues)
| 问题 (Issue) | 解决方案 (Solution) |
|---|---|
| 未检测到附件 (Attachments not detected) | 检查 MIME 类型筛选器,增加触发频率 (Check MIME type filters, increase trigger frequency) |
| 重复文件 (Duplicate files) | 按哈希值或文件名启用去重 (Enable deduplication by hash or filename) |
| 速率限制 (Rate limits) | 降低触发频率,使用批量处理 (Reduce trigger frequency, use batch processing) |
| 权限错误 (Permission errors) | 重新授权 OAuth 凭证 (Re-authorize OAuth credentials) |
| 大文件失败 (Large files failing) | 设置大小限制,使用分块上传 (Set size limits, use chunked upload) |
安全考虑 (Security Considerations)
- OAuth 范围 (OAuth Scopes): 请求最小权限 (Request minimal permissions)
gmail.readonly用于读取 (for reading)gmail.modify用于标签/归档 (for labels/archive)drive.file用于云端硬盘访问 (for Drive access)
- 数据隐私 (Data Privacy):
- 不要记录邮件内容 (Don’t log email content)
- 为凭证使用安全存储 (Use secure storage for credentials)
- 实施保留策略 (Implement retention policies)
- 访问控制 (Access Control):
- 限制谁可以修改工作流 (Limit who can modify workflows)
- 审计自动化活动 (Audit automation activities)
- 使用单独的服务账户 (Use separate service accounts)
输出示例 (Output Example)
每日邮件报告 (Daily Email Report):
# 邮件活动报告 - 2026-01-30 (Email Activity Report - 2026-01-30)
## 摘要 (Summary)
- 收到邮件 (Emails Received): 47
- 发送邮件 (Emails Sent): 23
- 已处理的附件 (Attachments Processed): 12
- 平均响应时间 (Average Response Time): 2.3 小时 (hours)
## 附件处理 (Attachment Processing)
| 文件 (File) | 发件人 (Sender) | 保存位置 (Saved To) | 时间 (Time) |
|----------|-----------|-------------|------|
| Invoice_Jan.pdf | vendor@co.com | /财务/发票 (/Finance/Invoices) | 09:15 |
| Report_Q4.xlsx | team@company.com | /报告/Q4 (/Reports/Q4) | 10:30 |
| Contract_v2.docx | legal@client.com | /合同 (/Contracts) | 14:22 |
## 已应用的标签 (Labels Applied)
- 财务/发票 (Finance/Invoices): 5 封邮件 (emails)
- 项目/进行中 (Projects/Active): 12 封邮件 (emails)
- 客户/优先 (Clients/Priority): 8 封邮件 (emails)
## 待处理操作 (Pending Actions)
- 3 封邮件需要人工审核 (3 emails require manual review)
- 2 个大附件需要批准 (2 large attachments need approval)
Gmail 工作流技能 – Claude 办公技能套件的一部分 (Gmail Workflows Skill – Part of Claude Office Skills)
📄 原始文档
完整文档(英文):
https://skills.sh/claude-office-skills/skills/gmail-workflows
💡 提示:点击上方链接查看 skills.sh 原始英文文档,方便对照翻译。
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。

评论(0)