8
n8n 中文网amn8n.com

使用API、电子邮件和Google Drive生成每周能耗报告

中级

这是一个Document Extraction, Multimodal AI领域的自动化工作流,包含 12 个节点。主要使用 Code, Cron, EmailSend, GoogleDrive, HttpRequest 等节点。 使用EnergiDataService、电子邮件和Google Drive生成每周能耗报告

前置要求
  • Google Drive API 凭证
  • 可能需要目标 API 的认证凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "5if9twDNChTpUQFf",
  "meta": {
    "instanceId": "14e4c77104722ab186539dfea5182e419aecc83d85963fe13f6de862c875ebfa"
  },
  "name": "使用 API、电子邮件和 Google Drive 生成每周能耗报告",
  "tags": [],
  "nodes": [
    {
      "id": "4827c44f-1995-4cd9-837f-f06c55ce9697",
      "name": "每周计划(周一上午 8 点)",
      "type": "n8n-nodes-base.cron",
      "position": [
        -200,
        200
      ],
      "parameters": {
        "triggerTimes": {
          "item": [
            {
              "hour": 8,
              "mode": "everyWeek",
              "weekday": "monday"
            }
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "028bf36b-a75b-474d-a596-dcd8f4db7c20",
      "name": "获取能耗数据",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        20,
        200
      ],
      "parameters": {
        "url": "https://api.energidataservice.dk/dataset/ConsumptionDE35Hour",
        "options": {}
      },
      "typeVersion": 1
    },
    {
      "id": "f0fa171b-52b2-4350-8d0f-808117715e30",
      "name": "规范化记录",
      "type": "n8n-nodes-base.code",
      "position": [
        240,
        200
      ],
      "parameters": {
        "jsCode": "const itemlist = $input.first().json.records;\nreturn itemlist.map(r => ({ json: r }));"
      },
      "typeVersion": 2
    },
    {
      "id": "a47b2980-6da2-4dbc-bb09-d23d4b936d9f",
      "name": "转换为文件",
      "type": "n8n-nodes-base.convertToFile",
      "position": [
        460,
        200
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 1.1
    },
    {
      "id": "613baa2d-3929-4e88-aa65-5303860dcfb4",
      "name": "发送电子邮件周报",
      "type": "n8n-nodes-base.emailSend",
      "position": [
        680,
        100
      ],
      "parameters": {
        "text": "Please find attached the latest weekly energy consumption report.",
        "options": {},
        "subject": "Weekly Energy Consumption Report",
        "toEmail": "test@yopmail.com",
        "fromEmail": "test@yopmail.com",
        "attachments": "=data"
      },
      "typeVersion": 1
    },
    {
      "id": "588f3a86-3932-499f-b3aa-e60cbc2c8ebd",
      "name": "报告文件上传到 Google Drive",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        680,
        300
      ],
      "parameters": {
        "name": "=energy_report_{{ $now.format('yyyy_MM_dd_HH_ii_ss') }}",
        "driveId": {
          "__rl": true,
          "mode": "list",
          "value": "My Drive"
        },
        "options": {},
        "folderId": {
          "__rl": true,
          "mode": "list",
          "value": "root",
          "cachedResultName": "/ (Root folder)"
        }
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "GrSonA33DqizXziW",
          "name": "Google Drive account 4"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "7c910c92-a9d4-4a2e-9e91-69d859ea633f",
      "name": "便签:节点说明1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -240,
        40
      ],
      "parameters": {
        "width": 160,
        "height": 120,
        "content": "📝 - **每周计划(周一上午 8 点)**:每周一上午 8 点触发。"
      },
      "typeVersion": 1
    },
    {
      "id": "ff3f08c5-430d-4b3e-8ef5-f3f93d32efe7",
      "name": "便签:节点说明2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -20,
        40
      ],
      "parameters": {
        "width": 160,
        "height": 120,
        "content": "📝 - **获取能耗数据**:调用 EnergiDataService.dk API。"
      },
      "typeVersion": 1
    },
    {
      "id": "1627fcfa-d1f6-40f5-90dd-0352b2a6fb63",
      "name": "便签:节点说明3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        200,
        40
      ],
      "parameters": {
        "width": 160,
        "height": 120,
        "content": "📝 - **规范化记录**:扁平化 JSON 响应(records → items)。"
      },
      "typeVersion": 1
    },
    {
      "id": "48440a87-317b-47e4-808c-b07e6411bdd0",
      "name": "便签:节点说明4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        420,
        40
      ],
      "parameters": {
        "width": 160,
        "height": 120,
        "content": "📝 - **转换为文件**:将项目转换为 CSV(二进制 `data`)。"
      },
      "typeVersion": 1
    },
    {
      "id": "dd003fb3-dccc-4e2f-90d4-f9acbdcca301",
      "name": "便签:节点说明5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        660,
        -40
      ],
      "parameters": {
        "width": 160,
        "height": 120,
        "content": "📝 - **电子邮件周报**:通过电子邮件发送 CSV 文件。"
      },
      "typeVersion": 1
    },
    {
      "id": "2f2425e1-86d2-499c-be72-3f42d723385c",
      "name": "便签:节点说明6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        660,
        500
      ],
      "parameters": {
        "width": 160,
        "height": 120,
        "content": "📝 - **上传文件到 Drive**:将 CSV 保存到 Google Drive。"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "c9007e5b-7c88-4384-97bf-12dff0a2672c",
  "connections": {
    "Convert to File": {
      "main": [
        [
          {
            "node": "Send Email Weekly Report",
            "type": "main",
            "index": 0
          },
          {
            "node": "Report File Upload to Google Drive",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Energy Data": {
      "main": [
        [
          {
            "node": "Normalize Records",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Normalize Records": {
      "main": [
        [
          {
            "node": "Convert to File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Weekly (Mon 8AM)": {
      "main": [
        [
          {
            "node": "Fetch Energy Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

中级 - 文档提取, 多模态 AI

需要付费吗?

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

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

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

作者
WeblineIndia

WeblineIndia

@weblineindia

A Leading Software Engineering, Consulting & Outsourcing Services Company in USA & India serving Clients Globally since 1999.

外部链接
在 n8n.io 查看

分享此工作流