gmail-workflows について
gmail-workflowsは、Gmail自動化ワークフローの設計と実装を支援するスキルです。メール、添付ファイル、関連記録を整理する人向けに、n8nのワークフローテンプレートに基づくパターンとGoogle Apps Scriptの実装方法を紹介します。
主な機能
- 01メールを絞り込み添付ファイルをGoogle Driveに保存
- 02条件に応じたラベル付けとメールのアーカイブ
- 03顧客メールの整理と通知の転送
- 04請求書の収集とスプレッドシートの更新
- 05メール指標の追跡とレポート生成
活用シーン
- 01メールの請求書添付を自動でアーカイブする
- 02顧客やプロジェクト別に受信メールを整理する
- 03新しい添付ファイルを分類してDriveに保存する
- 04メール件数や返信時間を集計する
インストール
コマンドをコピーしてターミナルで実行します。
$
npx skills add https:/ / github.com/ claude-office-skills/ skills --skill gmail-workflowsインストール後、Claude Code で/gmail-workflowsを入力して読み込まれたか確認します。
詳細
Gmail ワークフロー
添付ファイルの管理、メールの整理、Google Drive との連携を行うインテリジェントなワークフローで Gmail を自動化します。n8n の 7,800 件以上のワークフローテンプレートに基づいています。
概要
このスキルを使うと、次のような Gmail 自動化ワークフローを設計して実装できます。
- 添付ファイルを Google Drive に自動保存する
- スマートラベルでメールを整理する
- 処理済みメールをアーカイブする
- Slack/メールで通知を送信する
- メールの指標を追跡する
主要なワークフローテンプレート
1. Gmail 添付ファイルマネージャー
目的:メールから添付ファイルを自動抽出し、Google Drive に保存します。
ワークフローの手順:
┌─────────────┐ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐
│ Gmail │───▶│ Filter by │───▶│ Extract │───▶│ Upload to │
│ Trigger │ │ Criteria │ │ Attachments │ │ Google Drive│
└─────────────┘ └─────────────┘ └─────────────┘ └─────────────┘
│
┌─────────────┐ ┌─────────────┐ │
│ Send │◀───│ Apply Label │◀───┘
│ Notification│ │ & Archive │
└─────────────┘ └─────────────┘
設定:
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: "/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}"
ベストプラクティス:
- スパムの処理を避けるため、送信者を具体的に指定してフィルタリングします
- ストレージの問題を防ぐため、ファイルサイズの上限を設定します
- 簡単に見つけられるよう、日付ベースのフォルダー構成を使用します
- 重複アップロードを避けるため、重複検出を有効にします
2. 請求書の自動アーカイブ
目的:メールから請求書を自動収集して整理します。
ワークフローの手順:
Gmail Trigger → Detect Invoice → Extract PDF → OCR/Parse → Save to Drive → Update Spreadsheet → Archive Email
設定:
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: "/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. クライアントとのコミュニケーション整理
目的:クライアントのメールをプロジェクト/クライアントごとに自動で整理します。
設定:
rules:
- name: "Client A Emails"
condition:
from_domain: "clienta.com"
actions:
- apply_label: "Clients/Client A"
- forward_to: "[email protected]"
- save_attachments: "/Clients/Client A/{subject}"
- name: "Project X Updates"
condition:
subject_contains: ["Project X", "PX-"]
actions:
- apply_label: "Projects/Project X"
- add_to_task: "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. メール分析ダッシュボード
目的:メールの指標を追跡してレポートを作成します。
追跡する指標:
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: "every Monday 9am"
- output: Google Sheets
- notify: Slack #email-metrics
実装ガイド
n8n を使用する
// n8n Workflow: Gmail to Google Drive
{
"nodes": [
{
"name": "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 Script を使用する
// 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();
}
一般的なワークフローパターン
パターン 1:フィルター → 処理 → 整理 → 通知
Email arrives
│
▼
┌─────────────────┐
│ Apply Filters │ → Skip if doesn't match
│ (sender, subject│
│ attachment) │
└────────┬────────┘
│
▼
┌─────────────────┐
│ Process Content │ → Extract data, attachments
│ │
└────────┬────────┘
│
▼
┌─────────────────┐
│ Organize │ → Save files, apply labels
│ │
└────────┬────────┘
│
▼
┌─────────────────┐
│ Notify │ → Slack, email, SMS
│ │
└─────────────────┘
パターン 2:バッチ処理
schedule: "daily at 6am"
steps:
1. 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:条件付きルーティング
conditions:
- if: attachment_type == "pdf" AND subject contains "invoice"
then: route_to_finance_folder
- if: from_domain in ["important-client.com"]
then: priority_handling + immediate_notification
- if: attachment_size > 10MB
then: save_to_large_files_folder + skip_backup
- default:
then: standard_processing
トラブルシューティング
よくある問題
| 問題 | 解決策 |
|---|---|
| 添付ファイルが検出されない | MIME タイプのフィルターを確認し、トリガーの頻度を上げます |
| ファイルが重複する | ハッシュ値またはファイル名による重複排除を有効にします |
| レート制限 | トリガーの頻度を下げ、バッチ処理を使用します |
| 権限エラー | OAuth 認証情報を再認証します |
| 大きなファイルのアップロードに失敗する | サイズ制限を設定し、チャンク分割アップロードを使用します |
セキュリティに関する考慮事項
-
OAuth スコープ:必要最小限の権限を要求します
- 読み取りには
gmail.readonly - ラベル付け/アーカイブには
gmail.modify - Drive へのアクセスには
drive.file
- 読み取りには
-
データプライバシー:
- メールの内容をログに記録しないでください
- 認証情報には安全なストレージを使用します
- 保持ポリシーを実装します
-
アクセス制御:
- ワークフローを変更できるユーザーを制限します
- 自動化のアクティビティを監査します
- 専用のサービスアカウントを使用します
出力例
日次メールレポート:
# 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 | [email protected] | /Finance/Invoices | 09:15 |
| Report_Q4.xlsx | [email protected] | /Reports/Q4 | 10:30 |
| Contract_v2.docx | [email protected] | /Contracts | 14:22 |
## Labels Applied
- Finance/Invoices: 5 emails
- Projects/Active: 12 emails
- Clients/Priority: 8 emails
## Pending Actions
- 3 emails require manual review
- 2 large attachments need approval
Gmail ワークフロースキル - Claude Office Skills の一部
コメント
Markdown 対応