8
n8n 中文网amn8n.com

Gmail附件备份到Google Drive

中级

这是一个IT Ops领域的自动化工作流,包含 8 个节点。主要使用 Code, Gmail, GoogleDrive, GmailTrigger 等节点。 Gmail附件备份到Google Drive

前置要求
  • Google 账号和 Gmail API 凭证
  • Google Drive API 凭证

分类

工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "meta": {
    "instanceId": "7d8066d2f56a07000fe7d753d3eeabf0ecdf68413466f30d10afe0906f058427",
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "9b0e3c5c-6f27-4034-b281-960b039b883a",
      "name": "Gmail 触发器",
      "type": "n8n-nodes-base.gmailTrigger",
      "position": [
        0,
        -20
      ],
      "parameters": {
        "filters": {
          "sender": "akhilgadiraju@gmail.com"
        },
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        }
      },
      "credentials": {
        "gmailOAuth2": {
          "id": "wqFUFuFpF5eRAp4E",
          "name": "Gmail OAuth2 - Akhil"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "c68ebbfb-8fad-4f2b-837b-fb8ac0ffe4df",
      "name": "Gmail",
      "type": "n8n-nodes-base.gmail",
      "position": [
        220,
        -20
      ],
      "webhookId": "2614ede2-d4ce-4490-9792-8157980bece3",
      "parameters": {
        "simple": false,
        "options": {
          "downloadAttachments": true,
          "dataPropertyAttachmentsPrefixName": "attachment_"
        },
        "messageId": "={{ $json.id }}",
        "operation": "get"
      },
      "credentials": {
        "gmailOAuth2": {
          "id": "wqFUFuFpF5eRAp4E",
          "name": "Gmail OAuth2 - Akhil"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "40b97338-6ffe-4cfd-869e-a50815808a89",
      "name": "替换我",
      "type": "n8n-nodes-base.noOp",
      "position": [
        800,
        -20
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "0d4ae5a5-51d5-4917-8a88-7828d2f0e5ea",
      "name": "Google Drive",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        620,
        -20
      ],
      "parameters": {
        "name": "={{ $('Gmail Trigger').item.json.id + \"_\" + $now + \"_\" + \"backup_attachment\" }}",
        "driveId": {
          "__rl": true,
          "mode": "list",
          "value": "My Drive",
          "cachedResultUrl": "https://drive.google.com/drive/my-drive",
          "cachedResultName": "My Drive"
        },
        "options": {},
        "folderId": {
          "__rl": true,
          "mode": "list",
          "value": "1aZmIqT9jG-GqW_OIGT3HWvRb6JalTlBi",
          "cachedResultUrl": "https://drive.google.com/drive/folders/1aZmIqT9jG-GqW_OIGT3HWvRb6JalTlBi",
          "cachedResultName": "DOcs"
        },
        "inputDataFieldName": "=data"
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "LxzMJWxwgbnYKUly",
          "name": "Google Drive - Akhil"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "3f2bd52a-7637-4b65-bae3-daebc5f664de",
      "name": "代码",
      "type": "n8n-nodes-base.code",
      "position": [
        420,
        -20
      ],
      "parameters": {
        "jsCode": "return Object.entries(items[0].binary).map(([key, value]) => {\n  return {\n    binary: {\n      data: value\n    }\n  };\n});"
      },
      "typeVersion": 2
    },
    {
      "id": "c0ae6ad0-7f25-4912-9bbd-7610ef61d6cd",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        140,
        -120
      ],
      "parameters": {
        "color": 4,
        "width": 260,
        "height": 80,
        "content": "### 更改发件人筛选器"
      },
      "typeVersion": 1
    },
    {
      "id": "0552dd8a-341e-4a67-ad12-8bab41371685",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        560,
        140
      ],
      "parameters": {
        "color": 4,
        "height": 180,
        "content": "### 更改目标文件夹"
      },
      "typeVersion": 1
    },
    {
      "id": "f19c4cff-b85d-4ac3-99d7-bf70e61fe5bb",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        740,
        -140
      ],
      "parameters": {
        "height": 100,
        "content": "### 添加上传后逻辑"
      },
      "typeVersion": 1
    }
  ],
  "pinData": {},
  "connections": {
    "Code": {
      "main": [
        [
          {
            "node": "Google Drive",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Gmail": {
      "main": [
        [
          {
            "node": "Code",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Replace Me": {
      "main": [
        []
      ]
    },
    "Google Drive": {
      "main": [
        [
          {
            "node": "Replace Me",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Gmail Trigger": {
      "main": [
        [
          {
            "node": "Gmail",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。

这个工作流适合什么场景?

中级 - IT 运维

需要付费吗?

本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。

工作流信息
难度等级
中级
节点数量8
分类1
节点类型6
难度说明

适合有一定经验的用户,包含 6-15 个节点的中等复杂度工作流

作者
外部链接
在 n8n.io 查看

分享此工作流