テンプレート:Gmailの添付ファイル処理

上級

これはFile Management分野の自動化ワークフローで、22個のノードを含みます。主にGmail, Slack, Filter, Switch, SplitOutなどのノードを使用。 Gmail添付ファイルマネージャー、Google Driveアップロードとスマートフィルターを含む

前提条件
  • Googleアカウント + Gmail API認証情報
  • Slack Bot Token または Webhook URL
  • Google Drive API認証情報
  • ターゲットAPIの認証情報が必要な場合あり

カテゴリー

ワークフロープレビュー
ノード接続関係を可視化、ズームとパンをサポート
ワークフローをエクスポート
以下のJSON設定をn8nにインポートして、このワークフローを使用できます
{
  "id": "Z3wOGZdXKSlSWzgO",
  "meta": {
    "instanceId": "5b61629a145a38a93588ff78addb36f97647fd75c5392fcb856e858941f87d19",
    "templateCredsSetupCompleted": true
  },
  "name": "TEMPLATE Process attached files in Gmail",
  "tags": [],
  "nodes": [
    {
      "id": "fc56a7c7-e89d-46f6-88d1-a6b4c8ce7364",
      "name": "メールを既読化してアーカイブ",
      "type": "n8n-nodes-base.gmail",
      "position": [
        -80,
        -80
      ],
      "webhookId": "0dd820ff-1f3e-4e9e-9fb8-922f59eabf8c",
      "parameters": {
        "labelIds": [
          "UNREAD",
          "INBOX"
        ],
        "messageId": "={{ $('Filter based on sender or receiver').item.json.id }}",
        "operation": "removeLabels"
      },
      "credentials": {},
      "typeVersion": 2.1
    },
    {
      "id": "1327a765-2c40-40ef-929f-dfb0790cf048",
      "name": "付箋メモ",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -928,
        -560
      ],
      "parameters": {
        "color": 5,
        "width": 1344,
        "height": 432,
        "content": "## Information\nTemplate created by Smultron Studio (https://smultronstudio.com/en) - feel free to reach out at hello@smultronstudio.com\n\n### Instructions (numbers refer to red cards):\n1. Configure credentials\n2. Configure credentials\n3. If you have one or many specific senders for the emails to be processed in this workflow, specify here\n4. If you want a filter on which file types to process, specify here\n5. If you want to process multiple file types and need separate paths, build that here\n6. Configure where to post or upload the files\n7. Configure credentials and customize Slack message\n\n#### Modifications:\nThis template is a skeleton to customize for your use case. It sorts out the n8n specific references and logic to process the files fetched from an email in Gmail.\n\n#### List of mimeTypes for filtering:\nhttps://docs.cloud.google.com/appengine/docs/legacy/standard/php/mail/mail-with-headers-attachments"
      },
      "typeVersion": 1
    },
    {
      "id": "f50f6e40-1b10-48da-9440-1cffe6f6d323",
      "name": "メッセージを送信",
      "type": "n8n-nodes-base.slack",
      "position": [
        592,
        -336
      ],
      "webhookId": "92ba6b9b-92d1-47a8-bf51-103a5598212d",
      "parameters": {
        "text": "=Did something with {{$('Loop attachments').all().length}} files received from {{ $('Trigger on incoming email with attachment').item.json.from.value[0].address }}",
        "otherOptions": {}
      },
      "typeVersion": 2.3
    },
    {
      "id": "5c972c0f-dc9f-4056-a4b5-99bd62ea1a83",
      "name": "添付ファイル付き受信メールでトリガー",
      "type": "n8n-nodes-base.gmailTrigger",
      "position": [
        -864,
        80
      ],
      "parameters": {
        "simple": false,
        "filters": {
          "q": "has:attachment -label:DRAFT"
        },
        "options": {
          "downloadAttachments": true
        },
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        }
      },
      "credentials": {},
      "typeVersion": 1.3
    },
    {
      "id": "d4504562-3549-4d70-8b60-37e8c027adc7",
      "name": "ファイルタイプに基づくフィルタ",
      "type": "n8n-nodes-base.filter",
      "position": [
        144,
        144
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "or",
          "conditions": [
            {
              "id": "5b96c7b7-5896-4e65-89e2-69e679346f42",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $binary.values()[0].mimeType }}",
              "rightValue": "application/zip"
            },
            {
              "id": "ac183995-c533-4698-a2e7-8601f7420c79",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $binary.values()[0].mimeType }}",
              "rightValue": "text/plain"
            },
            {
              "id": "0a949152-7478-4b66-a2c2-e52798627eba",
              "operator": {
                "type": "string",
                "operation": "exists",
                "singleValue": true
              },
              "leftValue": "={{ $binary.values()[0].mimeType }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.2,
      "alwaysOutputData": true
    },
    {
      "id": "75ebfebd-0d76-45e1-b722-6ebcc159460d",
      "name": "異なるファイルタイプを個別処理",
      "type": "n8n-nodes-base.switch",
      "position": [
        368,
        128
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "zip",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "48e9243a-8e5b-4f5d-90e7-4c78b0580a76",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $binary.values()[0].mimeType }}",
                    "rightValue": "application/zip"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "no file",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "c9b50caa-7335-469f-a863-e24836c1ca79",
                    "operator": {
                      "type": "object",
                      "operation": "empty",
                      "singleValue": true
                    },
                    "leftValue": "={{ $input.first().json }}",
                    "rightValue": "0"
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {
          "fallbackOutput": "extra"
        }
      },
      "typeVersion": 3.3
    },
    {
      "id": "e653ee4e-cf13-4d51-b43b-79920f5add10",
      "name": "ZIPを解凍",
      "type": "n8n-nodes-base.compression",
      "position": [
        528,
        48
      ],
      "parameters": {
        "outputPrefix": "=file_",
        "binaryPropertyName": "={{ Object.keys($binary)[0] }}"
      },
      "typeVersion": 1.1
    },
    {
      "id": "faf61d9d-2e43-4c6c-b23c-08c85042e1fe",
      "name": "webhook にファイルを投稿",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1056,
        272
      ],
      "parameters": {
        "url": "https://n8n.com:8443/webhook/[unique-id]",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "contentType": "binaryData",
        "inputDataFieldName": "={{ Object.keys($binary)[0] }}"
      },
      "typeVersion": 4.2
    },
    {
      "id": "f96f3ca8-fa1a-4f0c-b0a3-e7b6d9527a72",
      "name": "添付ファイルをループ処理",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        -272,
        80
      ],
      "parameters": {
        "options": {
          "reset": false
        }
      },
      "typeVersion": 3
    },
    {
      "id": "febc18da-137c-4759-b21d-ec1910778a98",
      "name": "付箋メモ1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -928,
        -112
      ],
      "parameters": {
        "color": 6,
        "width": 1904,
        "height": 560,
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "9ebd9a7e-bc46-4d8c-81b9-c621394683a0",
      "name": "付箋メモ2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        432,
        -560
      ],
      "parameters": {
        "width": 544,
        "height": 432,
        "content": "## Notification out\nNotify in Slack that files has been processed"
      },
      "typeVersion": 1
    },
    {
      "id": "512d195b-ffab-42db-9c60-dd9f60cde8fe",
      "name": "付箋メモ3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        720,
        64
      ],
      "parameters": {
        "color": 3,
        "width": 192,
        "height": 448,
        "content": "## 6. Upload file somewhere\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nConfigure or replace this node with some other destination for your files."
      },
      "typeVersion": 1
    },
    {
      "id": "44de5019-f2fd-4c87-bc91-a3c789b18ae5",
      "name": "付箋メモ4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        96,
        16
      ],
      "parameters": {
        "color": 3,
        "width": 192,
        "height": 496,
        "content": "## 4. Filter based on file type\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nIf you expect one or more file types, you can specify that here. \n\nOr if you only want to process a specific file type in emails with multiple attachments."
      },
      "typeVersion": 1
    },
    {
      "id": "3260063c-d547-418e-af65-2de4f80eaf35",
      "name": "付箋メモ5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        320,
        0
      ],
      "parameters": {
        "color": 3,
        "width": 368,
        "height": 512,
        "content": "## 5. Treat different file types separate\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nIf you expect multiple file types that requires different processing, build those paths here (like decompressing zip files). \n\nIf you filter to only process one specific file type or will process all files the same then you can remove this part. "
      },
      "typeVersion": 1
    },
    {
      "id": "79a0bfcf-c12a-4c78-af7a-7174a9f6c8e0",
      "name": "付箋メモ6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -912,
        -16
      ],
      "parameters": {
        "color": 3,
        "width": 192,
        "height": 272,
        "content": "## 1. Trigger\nConfigure your credentials here"
      },
      "typeVersion": 1
    },
    {
      "id": "f25b842d-2324-42f2-9f4a-847098d2669f",
      "name": "付箋メモ7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -128,
        -176
      ],
      "parameters": {
        "color": 3,
        "width": 192,
        "height": 288,
        "content": "## 2. Archive\nConfigure your credentials here"
      },
      "typeVersion": 1
    },
    {
      "id": "367f6c68-5b16-4062-8be8-8a5094b24c0a",
      "name": "付箋メモ8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -704,
        -16
      ],
      "parameters": {
        "color": 3,
        "width": 208,
        "height": 272,
        "content": "## 3. Filter sender/receiver\n"
      },
      "typeVersion": 1
    },
    {
      "id": "16094578-c919-4cd3-8a6b-4bf730426f11",
      "name": "付箋メモ9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        544,
        -448
      ],
      "parameters": {
        "color": 3,
        "height": 288,
        "content": "## 7. Slack notification\nConfigure your credentials here"
      },
      "typeVersion": 1
    },
    {
      "id": "35253661-cf9c-414d-a0ad-b9f4bf9fa83a",
      "name": "Google Driveにファイルをアップロード",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        768,
        160
      ],
      "parameters": {
        "name": "={{ $binary.values()[0].fileName }}",
        "driveId": {
          "__rl": true,
          "mode": "list",
          "value": "My Drive"
        },
        "options": {},
        "folderId": {
          "__rl": true,
          "mode": "list",
          "value": "root",
          "cachedResultName": "/ (Root folder)"
        },
        "inputDataFieldName": "={{ Object.keys($binary)[0] }}"
      },
      "credentials": {},
      "typeVersion": 3
    },
    {
      "id": "44a5eaa9-181c-4871-9a66-00927e293dd0",
      "name": "付箋メモ10",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        992,
        176
      ],
      "parameters": {
        "color": 3,
        "width": 256,
        "height": 272,
        "content": "## 8. Example\nThis is a webhook example to replace the Google Drive node (6)"
      },
      "typeVersion": 1
    },
    {
      "id": "95604855-1bf5-485c-bd31-65b4352b6cec",
      "name": "送信者/受信者に基づくフィルタ",
      "type": "n8n-nodes-base.filter",
      "position": [
        -656,
        80
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "or",
          "conditions": [
            {
              "id": "dab0779d-b14a-481c-80d6-33c356009ef5",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.from.value[0].address }}",
              "rightValue": "sender@domain.tld"
            },
            {
              "id": "09479cf5-3c9a-4dab-a987-016462db5470",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.to.value[0].address }}",
              "rightValue": "recipient@domain.tld"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "87a1ecf3-63d8-4bb4-9426-f4c9afbc40e7",
      "name": "分割出力",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        -448,
        80
      ],
      "parameters": {
        "options": {},
        "fieldToSplitOut": "$binary"
      },
      "typeVersion": 1
    }
  ],
  "active": true,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "8fd24c8f-f0fe-48e5-bf27-da6a79d17f5e",
  "connections": {
    "87a1ecf3-63d8-4bb4-9426-f4c9afbc40e7": {
      "main": [
        [
          {
            "node": "f96f3ca8-fa1a-4f0c-b0a3-e7b6d9527a72",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "e653ee4e-cf13-4d51-b43b-79920f5add10": {
      "main": [
        [
          {
            "node": "35253661-cf9c-414d-a0ad-b9f4bf9fa83a",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "f50f6e40-1b10-48da-9440-1cffe6f6d323": {
      "main": [
        []
      ]
    },
    "f96f3ca8-fa1a-4f0c-b0a3-e7b6d9527a72": {
      "main": [
        [
          {
            "node": "fc56a7c7-e89d-46f6-88d1-a6b4c8ce7364",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "d4504562-3549-4d70-8b60-37e8c027adc7",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "faf61d9d-2e43-4c6c-b23c-08c85042e1fe": {
      "main": [
        []
      ]
    },
    "d4504562-3549-4d70-8b60-37e8c027adc7": {
      "main": [
        [
          {
            "node": "75ebfebd-0d76-45e1-b722-6ebcc159460d",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "fc56a7c7-e89d-46f6-88d1-a6b4c8ce7364": {
      "main": [
        [
          {
            "node": "f50f6e40-1b10-48da-9440-1cffe6f6d323",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "35253661-cf9c-414d-a0ad-b9f4bf9fa83a": {
      "main": [
        [
          {
            "node": "f96f3ca8-fa1a-4f0c-b0a3-e7b6d9527a72",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "95604855-1bf5-485c-bd31-65b4352b6cec": {
      "main": [
        [
          {
            "node": "87a1ecf3-63d8-4bb4-9426-f4c9afbc40e7",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "75ebfebd-0d76-45e1-b722-6ebcc159460d": {
      "main": [
        [
          {
            "node": "e653ee4e-cf13-4d51-b43b-79920f5add10",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "f96f3ca8-fa1a-4f0c-b0a3-e7b6d9527a72",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "35253661-cf9c-414d-a0ad-b9f4bf9fa83a",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "5c972c0f-dc9f-4056-a4b5-99bd62ea1a83": {
      "main": [
        [
          {
            "node": "95604855-1bf5-485c-bd31-65b4352b6cec",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
よくある質問

このワークフローの使い方は?

上記のJSON設定コードをコピーし、n8nインスタンスで新しいワークフローを作成して「JSONからインポート」を選択、設定を貼り付けて認証情報を必要に応じて変更してください。

このワークフローはどんな場面に適していますか?

上級 - ファイル管理

有料ですか?

このワークフローは完全無料です。ただし、ワークフローで使用するサードパーティサービス(OpenAI APIなど)は別途料金が発生する場合があります。

ワークフロー情報
難易度
上級
ノード数22
カテゴリー1
ノードタイプ11
難易度説明

上級者向け、16ノード以上の複雑なワークフロー

作成者
Ossian Madisson

Ossian Madisson

@ossian

AI & Automation consultant with many years of experience from both devops and business management. A solid combination to really understand where technology can create real business value. My focus is to help businesses in Sweden work smarter and achieve more by applying technology in a useful and responsible way. Feel free to contact me at ossian@smultronstudio.com or schedule a short call at https://smultronstudio.com

外部リンク
n8n.ioで表示

このワークフローを共有

カテゴリー

カテゴリー: 34