8
n8n 中文网amn8n.com

AI重命名的 Gmail 附件保存到 Drive

中级

这是一个AI Summarization, Multimodal AI领域的自动化工作流,包含 10 个节点。主要使用 Set, Gmail, Merge, GoogleDrive, Agent 等节点。 使用 GPT-4o 自动重命名 Gmail 附件并保存到 Google Drive

前置要求
  • Google 账号和 Gmail API 凭证
  • Google Drive API 凭证
  • OpenAI API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移

无法加载工作流预览

导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "name": "AI重命名的 Gmail 附件保存到 Drive",
  "tags": [],
  "nodes": [
    {
      "name": "计划触发器",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        0,
        0
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "hours"
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "name": "AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        1120,
        124
      ],
      "parameters": {
        "text": "=You are an expert content analyser and file naming assistant...\ntext: {{ $json.text }}\ndate: {{ $json.info.CreationDate }}",
        "options": {},
        "promptType": "define"
      },
      "typeVersion": 2.2
    },
    {
      "name": "OpenAI 聊天模型",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        1192,
        348
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini",
          "cachedResultName": "gpt-4o-mini"
        },
        "options": {}
      },
      "typeVersion": 1.2
    },
    {
      "name": "上传文件",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        1696,
        0
      ],
      "parameters": {
        "name": "={{ $json.output }}",
        "driveId": {
          "__rl": true,
          "mode": "list",
          "value": "My Drive"
        },
        "options": {},
        "folderId": {
          "__rl": true,
          "mode": "url",
          "value": ""
        },
        "inputDataFieldName": "attachment_1"
      },
      "typeVersion": 3
    },
    {
      "name": "标记消息为已读",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1920,
        0
      ],
      "parameters": {
        "messageId": "={{ $('Set Required Fields').item.json.id }}",
        "operation": "markAsRead"
      },
      "typeVersion": 2.1
    },
    {
      "name": "合并数据以上传",
      "type": "n8n-nodes-base.merge",
      "position": [
        1472,
        0
      ],
      "parameters": {
        "mode": "combine",
        "options": {},
        "combineBy": "combineByPosition"
      },
      "typeVersion": 3.2
    },
    {
      "name": "获取带附件的未读消息",
      "type": "n8n-nodes-base.gmail",
      "position": [
        224,
        0
      ],
      "parameters": {
        "filters": {
          "readStatus": "unread"
        },
        "operation": "getAll"
      },
      "typeVersion": 2.1
    },
    {
      "name": "设置必填字段",
      "type": "n8n-nodes-base.set",
      "position": [
        448,
        0
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "name": "id",
              "type": "string",
              "value": "={{ $json.id }}"
            },
            {
              "name": "threadId",
              "type": "string",
              "value": "={{ $json.threadId }}"
            },
            {
              "name": "from.value[0].name",
              "type": "string",
              "value": "={{ $json.from.value[0].name }}"
            },
            {
              "name": "date",
              "type": "string",
              "value": "={{ $json.date }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "name": "下载附件",
      "type": "n8n-nodes-base.gmail",
      "position": [
        672,
        0
      ],
      "parameters": {
        "simple": false,
        "options": {
          "downloadAttachments": true
        },
        "messageId": "={{ $json.id }}",
        "operation": "get"
      },
      "typeVersion": 2.1
    },
    {
      "name": "从附件中提取",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        896,
        0
      ],
      "parameters": {
        "options": {},
        "operation": "pdf",
        "binaryPropertyName": "attachment_0"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "81cda4d6-8828-4b64-8afe-88b302168717",
  "connections": {
    "AI Agent": {
      "main": [
        [
          {
            "node": "Merge Data for Upload",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Upload file": {
      "main": [
        [
          {
            "node": "Mark message as read",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "Get Unread Messages with Attachments",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Set Required Fields": {
      "main": [
        [
          {
            "node": "Download Attachments",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download Attachments": {
      "main": [
        [
          {
            "node": "Extract from Attachments",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge Data for Upload": {
      "main": [
        [
          {
            "node": "Upload file",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract from Attachments": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Merge Data for Upload",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Unread Messages with Attachments": {
      "main": [
        [
          {
            "node": "Set Required Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

中级 - AI 摘要总结, 多模态 AI

需要付费吗?

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

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

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

作者
Matt Chong | n8n Creator

Matt Chong | n8n Creator

@mattxchong

Automation nerd fueled by good coffee, deep curiosity, and clean flows.

外部链接
在 n8n.io 查看

分享此工作流