8
n8n 中文网amn8n.com

使用OpenWeatherMap和Gmail发送每日天气报告到邮箱

中级

这是一个Personal Productivity领域的自动化工作流,包含 6 个节点。主要使用 Code, Cron, Gmail, HttpRequest 等节点。 使用OpenWeatherMap和Gmail发送每日天气报告到邮箱

前置要求
  • Google 账号和 Gmail API 凭证
  • 可能需要目标 API 的认证凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "meta": {
    "instanceId": "2000c64071c20843606b95c63795bb0797c41036047055a6586498e855b96efc",
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "ee5c851f-b27a-4e3b-8072-983ba221f2b1",
      "name": "每日计划(上午 8 点)",
      "type": "n8n-nodes-base.cron",
      "position": [
        32,
        368
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "5a4f19c1-37cb-4802-ab9c-437791774ffd",
      "name": "获取天气数据",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        288,
        368
      ],
      "parameters": {
        "url": "https://api.openweathermap.org/data/2.5/weather?q={{ encodeURIComponent('London') }}&units=metric&appid=YOUR_OPENWEATHERMAP_API_KEY",
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "8d9c1007-5c33-4217-bf9d-bb62a17a6959",
      "name": "格式化天气报告",
      "type": "n8n-nodes-base.code",
      "position": [
        544,
        368
      ],
      "parameters": {
        "jsCode": "const weatherData = $input.first().json;\n\nconst city = weatherData.name;\nconst description = weatherData.weather[0].description;\nconst temp = weatherData.main.temp;\nconst feelsLike = weatherData.main.feels_like;\nconst humidity = weatherData.main.humidity;\nconst windSpeed = weatherData.wind.speed;\n\nconst report = `\nGood morning!\n\nHere's your daily weather report for ${city}:\n\nConditions: ${description.charAt(0).toUpperCase() + description.slice(1)}\nTemperature: ${temp}°C (Feels like: ${feelsLike}°C)\nHumidity: ${humidity}%\nWind Speed: ${windSpeed} m/s\n\nHave a great day!\n`;\n\nreturn [{ json: { report: report, city: city } }];"
      },
      "typeVersion": 2
    },
    {
      "id": "76c9bf47-e0af-4d92-ad91-3fa8bb368dc3",
      "name": "发送邮件报告",
      "type": "n8n-nodes-base.gmail",
      "position": [
        784,
        368
      ],
      "webhookId": "205790d9-c8d1-4f7c-b576-f9d47cdbdd47",
      "parameters": {
        "sendTo": "your_email@example.com",
        "message": "={{ $json.report }}",
        "options": {},
        "subject": "Daily Weather Report for {{ $json.city }}",
        "emailType": "text"
      },
      "credentials": {
        "gmailOAuth2": {
          "id": "LVRUgE95PAvkE1Mc",
          "name": "Gmail account 2"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "f610daff-486e-4ef6-a20d-6f86451873ee",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -32,
        32
      ],
      "parameters": {
        "width": 416,
        "height": 240,
        "content": "## 每日天气报告发送至邮件"
      },
      "typeVersion": 1
    },
    {
      "id": "83443a67-aa2c-44e1-b8cf-89ddb35f2c67",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        480,
        32
      ],
      "parameters": {
        "width": 528,
        "height": 464,
        "content": "## 设置步骤"
      },
      "typeVersion": 1
    }
  ],
  "pinData": {},
  "connections": {
    "Fetch Weather Data": {
      "main": [
        [
          {
            "node": "Format Weather Report",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Daily Schedule (8 AM)": {
      "main": [
        [
          {
            "node": "Fetch Weather Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Weather Report": {
      "main": [
        [
          {
            "node": "Send Email Report",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

中级 - 个人效率

需要付费吗?

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

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

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

作者
David Olusola

David Olusola

@dae221

I help ambitious businesses eliminate operational bottlenecks and scale faster with AI automation. My clients typically see 40-60% efficiency gains within 90 days. Currently accepting 3 new projects this quarter - david@daexai.com

外部链接
在 n8n.io 查看

分享此工作流