Gmailの請求書PDFをGoogle DriveとSheetsに転送する
中級
これは自動化ワークフローで、12個のノードを含みます。主にIf, Gmail, Filter, GoogleDrive, GmailTriggerなどのノードを使用。 Gmail の請求書 PDF が自動のに Google ドライブにアップロードされ、スプレッドシートに記録されます
前提条件
- •Googleアカウント + Gmail API認証情報
- •Google Drive API認証情報
- •Google Sheets API認証情報
カテゴリー
-
ワークフロープレビュー
ノード接続関係を可視化、ズームとパンをサポート
ワークフローをエクスポート
以下のJSON設定をn8nにインポートして、このワークフローを使用できます
{
"id": "OOH6DNGDDDuKrcjk",
"meta": {
"templateCredsSetupCompleted": true
},
"name": "Gmail Invoice PDF to Google Drive and Sheets",
"tags": [],
"nodes": [
{
"id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"name": "Gmailトリガー",
"type": "n8n-nodes-base.gmailTrigger",
"position": [
224,
304
],
"parameters": {
"simple": false,
"filters": {
"sender": [],
"labelIds": [
"CATEGORY_PERSONAL"
],
"readStatus": "unread"
},
"options": {
"downloadAttachments": true
},
"pollTimes": {
"item": [
{
"mode": "everyMinute"
}
]
}
},
"typeVersion": 1.1
},
{
"id": "note1-2345-6789-abcd-ef1234567891",
"name": "付箋",
"type": "n8n-nodes-base.stickyNote",
"position": [
128,
80
],
"parameters": {
"color": 5,
"width": 280,
"height": 216,
"content": "## 📧 Gmail Trigger\nThis node monitors your Gmail inbox for new emails containing invoices. It checks every minute for unread emails with 'invoice' in the subject line and downloads any PDF attachments.\n\n**Configure:** Connect your Gmail account credentials"
},
"typeVersion": 1
},
{
"id": "filter-node-123-456-789-abcdef123456",
"name": "PDF添付ファイルあり?",
"type": "n8n-nodes-base.filter",
"position": [
448,
304
],
"parameters": {
"options": {},
"conditions": {
"options": {
"version": 1,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "cond123",
"operator": {
"type": "number",
"operation": "gt"
},
"leftValue": "={{ Object.keys($binary ?? {}).length }}",
"rightValue": 0
},
{
"id": "45eb8d9f-575d-4920-b236-2ea5be8ade19",
"operator": {
"name": "filter.operator.equals",
"type": "string",
"operation": "equals"
},
"leftValue": "",
"rightValue": ""
}
]
}
},
"typeVersion": 2
},
{
"id": "note2-3456-7890-bcde-f12345678902",
"name": "付箋1",
"type": "n8n-nodes-base.stickyNote",
"position": [
432,
480
],
"parameters": {
"color": 3,
"width": 260,
"height": 140,
"content": "## 🔍 Filter Check\nThis filter ensures we only process emails that actually have attachments (PDFs). Emails without attachments are filtered out."
},
"typeVersion": 1
},
{
"id": "gdrive-upload-123-456-789-abcdef654321",
"name": "Google Driveにアップロード",
"type": "n8n-nodes-base.googleDrive",
"position": [
896,
304
],
"parameters": {
"name": "={{ $json.filename || 'invoice_' + $now.toFormat('yyyyMMdd_HHmmss') + '.pdf' }}",
"driveId": {
"__rl": true,
"mode": "list",
"value": "My Drive"
},
"options": {},
"folderId": {
"__rl": true,
"mode": "list",
"value": "root",
"cachedResultName": "/ (Root folder)"
},
"inputDataFieldName": "=attachment_0"
},
"typeVersion": 3
},
{
"id": "note3-4567-8901-cdef-234567890123",
"name": "付箋2",
"type": "n8n-nodes-base.stickyNote",
"position": [
864,
80
],
"parameters": {
"color": 4,
"width": 300,
"height": 180,
"content": "## 📁 Google Drive Upload\nEach PDF attachment is uploaded to your Google Drive. Files are named using the original filename or a timestamp if not available.\n\n**Configure:** \n- Connect Google Drive credentials\n- Optionally specify a folder ID instead of 'root'"
},
"typeVersion": 1
},
{
"id": "gsheets-append-123-456-789-fedcba098765",
"name": "Google Sheetsに記録",
"type": "n8n-nodes-base.googleSheets",
"position": [
1120,
304
],
"parameters": {
"columns": {
"value": {
"name": "={{ $json.name }}"
},
"schema": [
{
"id": "kind",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "kind",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "id",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "id",
"defaultMatch": true,
"canBeUsedToMatch": true
},
{
"id": "name",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "name",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "mimeType",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "mimeType",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "starred",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "starred",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "trashed",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "trashed",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "explicitlyTrashed",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "explicitlyTrashed",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "parents",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "parents",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "spaces",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "spaces",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "version",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "version",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "webContentLink",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "webContentLink",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "webViewLink",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "webViewLink",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "iconLink",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "iconLink",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "hasThumbnail",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "hasThumbnail",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "thumbnailVersion",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "thumbnailVersion",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "viewedByMe",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "viewedByMe",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "createdTime",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "createdTime",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "modifiedTime",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "modifiedTime",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "modifiedByMeTime",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "modifiedByMeTime",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "modifiedByMe",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "modifiedByMe",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "owners",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "owners",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "lastModifyingUser",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "lastModifyingUser",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "shared",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "shared",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "ownedByMe",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "ownedByMe",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "downloadRestrictions",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "downloadRestrictions",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "capabilities",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "capabilities",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "viewersCanCopyContent",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "viewersCanCopyContent",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "copyRequiresWriterPermission",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "copyRequiresWriterPermission",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "writersCanShare",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "writersCanShare",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "permissions",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "permissions",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "permissionIds",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "permissionIds",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "originalFilename",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "originalFilename",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "fullFileExtension",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "fullFileExtension",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "fileExtension",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "fileExtension",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "md5Checksum",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "md5Checksum",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "sha1Checksum",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "sha1Checksum",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "sha256Checksum",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "sha256Checksum",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "size",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "size",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "quotaBytesUsed",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "quotaBytesUsed",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "headRevisionId",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "headRevisionId",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "isAppAuthorized",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "isAppAuthorized",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "linkShareMetadata",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "linkShareMetadata",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "inheritedPermissionsDisabled",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "inheritedPermissionsDisabled",
"defaultMatch": false,
"canBeUsedToMatch": true
}
],
"mappingMode": "autoMapInputData",
"matchingColumns": [
"id"
],
"attemptToConvertTypes": false,
"convertFieldsToString": false
},
"options": {},
"operation": "appendOrUpdate",
"sheetName": {
"__rl": true,
"mode": "name",
"value": ""
},
"documentId": {
"__rl": true,
"mode": "id",
"value": ""
}
},
"typeVersion": 4.5
},
{
"id": "note4-5678-9012-def0-345678901234",
"name": "付箋3",
"type": "n8n-nodes-base.stickyNote",
"position": [
896,
496
],
"parameters": {
"color": 6,
"width": 320,
"height": 240,
"content": "## 📊 Google Sheets Logging\nRecords invoice details in a spreadsheet including:\n- Date/time received\n- Sender email\n- Subject line\n- PDF filename\n- Google Drive link\n- File and Email IDs\n\n**Configure:**\n- Connect Google Sheets credentials\n- Add your spreadsheet ID\n- Ensure sheet has headers matching the column names"
},
"typeVersion": 1
},
{
"id": "gmail-mark-read-123-456-789-0987654321ab",
"name": "メールを既読にする",
"type": "n8n-nodes-base.gmail",
"position": [
1344,
304
],
"webhookId": "4e776efa-c75c-428c-aad3-a959fa6fe667",
"parameters": {
"messageId": "={{ $('Gmail Trigger').item.json.id }}",
"operation": "markAsRead"
},
"typeVersion": 2.1
},
{
"id": "note5-6789-0123-ef01-456789012345",
"name": "付箋4",
"type": "n8n-nodes-base.stickyNote",
"position": [
1376,
112
],
"parameters": {
"color": 2,
"width": 280,
"content": "## ✅ Mark as Processed\nAfter successfully uploading the PDF and logging to sheets, the original email is marked as read so it won't be processed again.\n\n**Note:** Uses same Gmail credentials as trigger"
},
"typeVersion": 1
},
{
"id": "note6-7890-1234-f012-567890123456",
"name": "付箋5",
"type": "n8n-nodes-base.stickyNote",
"position": [
-272,
336
],
"parameters": {
"width": 400,
"height": 424,
"content": "## 🚀 Setup Instructions\n\n1. **Gmail OAuth2**: Connect your Gmail account in all Gmail nodes\n2. **Google Drive OAuth2**: Connect your Google Drive account\n3. **Google Sheets OAuth2**: Connect your Google Sheets account\n4. **Spreadsheet Setup**: \n - Create a Google Sheet\n - Add headers: Date, Sender, Subject, Filename, Drive_Link, File_ID, Email_ID\n - Copy the spreadsheet ID from the URL\n - Paste it in the Google Sheets node\n5. **Optional**: Change the Drive folder from 'root' to a specific folder ID\n6. **Test**: Send yourself an email with 'invoice' in subject and a PDF attached"
},
"typeVersion": 1
},
{
"id": "5f57d83d-03a6-4729-aa66-a8ad05d946d6",
"name": "条件分岐",
"type": "n8n-nodes-base.if",
"position": [
672,
304
],
"parameters": {
"options": {},
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "f8e67ccc-5871-4413-ad2a-57849477c0d8",
"operator": {
"type": "boolean",
"operation": "true",
"singleValue": true
},
"leftValue": "={{ $binary && Object.keys($binary).length > 0 }}",
"rightValue": ""
}
]
}
},
"typeVersion": 2.2
}
],
"active": false,
"pinData": {},
"settings": {
"timezone": "America/New_York",
"errorWorkflow": "",
"executionOrder": "v1",
"saveManualExecutions": true,
"saveExecutionProgress": true,
"saveDataErrorExecution": "all",
"saveDataSuccessExecution": "all"
},
"connections": {
"5f57d83d-03a6-4729-aa66-a8ad05d946d6": {
"main": [
[
{
"node": "gdrive-upload-123-456-789-abcdef654321",
"type": "main",
"index": 0
}
]
]
},
"a1b2c3d4-e5f6-7890-abcd-ef1234567890": {
"main": [
[
{
"node": "filter-node-123-456-789-abcdef123456",
"type": "main",
"index": 0
}
]
]
},
"filter-node-123-456-789-abcdef123456": {
"main": [
[
{
"node": "5f57d83d-03a6-4729-aa66-a8ad05d946d6",
"type": "main",
"index": 0
}
]
]
},
"gsheets-append-123-456-789-fedcba098765": {
"main": [
[
{
"node": "gmail-mark-read-123-456-789-0987654321ab",
"type": "main",
"index": 0
}
]
]
},
"gdrive-upload-123-456-789-abcdef654321": {
"main": [
[
{
"node": "gsheets-append-123-456-789-fedcba098765",
"type": "main",
"index": 0
}
]
]
}
}
}よくある質問
このワークフローの使い方は?
上記のJSON設定コードをコピーし、n8nインスタンスで新しいワークフローを作成して「JSONからインポート」を選択、設定を貼り付けて認証情報を必要に応じて変更してください。
このワークフローはどんな場面に適していますか?
中級
有料ですか?
このワークフローは完全無料です。ただし、ワークフローで使用するサードパーティサービス(OpenAI APIなど)は別途料金が発生する場合があります。
関連ワークフロー
AI驱动のメール分诊与自動回复系统,統合OpenAIエージェントとGmail
AI驱动のメール分诊与自動回复系统,統合OpenAIエージェントとGmail
If
Set
Gmail
+
If
Set
Gmail
68 ノードAbdullahi Ahmed
コンテンツ作成
基于AIのMISエージェント
基于AIの管理信息系统エージェント
If
Set
Code
+
If
Set
Code
129 ノードKumar Shivam
サポート
Gmail、OpenAI、そしてGoogleスプレッドシートを使った敏捷開発の細化準備の自動化
Gmail、OpenAI、そしてGoogleシートを使った敏捷な振り返り準備の自動化
If
Set
Gmail
+
If
Set
Gmail
51 ノードWillemijn
プロダクト
[MW] AIサポートアシスタント - クラウド版
Gmail、Googleスプレッドシート、ERPデータとGPT-4o AIで顧客サポートを自動処理
If
Set
Gmail
+
If
Set
Gmail
25 ノードAOE Agent Lab
人工知能
GPT-4o-miniを使ってGmailからGoogle Sheetsへホテル予約リクエストを自動化
GPT-4o-miniでGmailのホテル予約リクエストをGoogle Sheetsへ自動入力
If
Set
Code
+
If
Set
Code
29 ノードGtaras
文書抽出
アクセルレーション隊スプリント計画の自動化
OpenAI、Googleカレンダー、Gmailを使ってアジャイルチームのスプリント計画を自動化
If
Set
Code
+
If
Set
Code
52 ノードWillemijn
プロダクト