8
n8n 中文网amn8n.com

使用OpenWeatherMap跟踪每小时天气状况并同步到Google Sheets

中级

这是一个Other, AI领域的自动化工作流,包含 6 个节点。主要使用 If, Set, HttpRequest, GoogleSheets, ScheduleTrigger 等节点,结合人工智能技术实现智能自动化。 使用OpenWeatherMap和Google Sheets追踪每小时天气状况

前置要求
  • 可能需要目标 API 的认证凭证
  • Google Sheets API 凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "1yA5mcestRYljmFM",
  "meta": {
    "instanceId": "3fed23de697c60307f3b4f5caeafbeffabaf7bbd62c1b20ae70d5faf5a9806b4",
    "templateCredsSetupCompleted": true
  },
  "name": "使用OpenWeatherMap跟踪每小时天气状况并同步到Google Sheets",
  "tags": [
    {
      "id": "F1KjxL3SjfvVqZqo",
      "name": "training-n8n",
      "createdAt": "2025-04-29T10:40:13.332Z",
      "updatedAt": "2025-04-29T10:40:13.332Z"
    }
  ],
  "nodes": [
    {
      "id": "472b4930-ac62-4adc-af65-4a3e46e18cac",
      "name": "计划触发器",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        0,
        0
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "hours"
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "a0fe192b-1b84-48d3-8896-c21f0fe26855",
      "name": "Google Sheets",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        900,
        -140
      ],
      "parameters": {
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "",
          "cachedResultUrl": "",
          "cachedResultName": ""
        },
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": ""
        },
        "authentication": "serviceAccount"
      },
      "credentials": {
        "googleApi": {
          "id": "zezjM010IlXk8xFU",
          "name": "Google Service Account training"
        }
      },
      "typeVersion": 4.5
    },
    {
      "id": "7cc21aa3-69bc-40d8-bea2-aee3bc27920c",
      "name": "从OpenWeatherMap获取天气数据",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        220,
        0
      ],
      "parameters": {
        "url": "=https://api.openweathermap.org/data/2.5/weather?q=Pasay,ph&APPID={{ $credentials.openWeatherMap.apiKey }}",
        "options": {}
      },
      "typeVersion": 4.2
    },
    {
      "id": "373b6f87-cc09-412d-9293-c18c889c4f0a",
      "name": "如果正在下雨",
      "type": "n8n-nodes-base.if",
      "position": [
        400,
        0
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "or",
          "conditions": [
            {
              "id": "c593374b-7a9f-4c8d-aa6c-3dfa2c11bbcc",
              "operator": {
                "type": "number",
                "operation": "lt"
              },
              "leftValue": "={{ $json.main.temp }}",
              "rightValue": 303
            },
            {
              "id": "24c06a68-c333-45c3-bf0e-0457448d3d2e",
              "operator": {
                "type": "string",
                "operation": "contains"
              },
              "leftValue": "={{ $json.weather[0].description }}",
              "rightValue": "rain"
            }
          ]
        }
      },
      "notesInFlow": true,
      "typeVersion": 2.2
    },
    {
      "id": "01f1394c-9d53-4a5a-a4ab-6146b1872a91",
      "name": "格式化数据",
      "type": "n8n-nodes-base.set",
      "position": [
        640,
        -140
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "a62d02e7-0baf-429a-bbf5-e5028020d723",
              "name": "city",
              "type": "string",
              "value": "={{ $json.name }}"
            },
            {
              "id": "0951f83b-578f-4300-97fd-464ac0a3152b",
              "name": "temperature (K)",
              "type": "string",
              "value": "={{ $json.main.temp }}"
            },
            {
              "id": "27f2d8f9-a841-4c38-bc68-ba1f5c8a716e",
              "name": "humidity",
              "type": "string",
              "value": "={{ $json.main.humidity }}"
            },
            {
              "id": "b0571687-07fa-432e-acd6-86c671f96875",
              "name": "conditions",
              "type": "string",
              "value": "={{ $json.weather[0].description }}"
            },
            {
              "id": "98f115fc-a91c-434d-b5d7-bab39aac8e98",
              "name": "status",
              "type": "string",
              "value": "higher than average temperature"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "33cb4c1b-d10c-4010-b49c-057469ec20f3",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        160,
        -80
      ],
      "parameters": {
        "width": 380,
        "height": 260,
        "content": "### 获取天气信息并检查是否下雨"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "a481a1a4-3b62-44d4-ad25-94debc8b353c",
  "connections": {
    "Google Sheets": {
      "main": [
        []
      ]
    },
    "If is raining": {
      "main": [
        [
          {
            "node": "Format the data",
            "type": "main",
            "index": 0
          }
        ],
        []
      ]
    },
    "Format the data": {
      "main": [
        [
          {
            "node": "Google Sheets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "Get Weather Data from OpenWeatherMap",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Weather Data from OpenWeatherMap": {
      "main": [
        [
          {
            "node": "If is raining",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

中级 - 其他, 人工智能

需要付费吗?

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

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

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

作者
ist00dent

ist00dent

@ist00dent

I’m a dedicated automation engineer passionate about no-code and low-code solutions. I design and implement robust n8n workflows—integrating APIs, databases, and messaging—to eliminate manual tasks and accelerate delivery. Leveraging Python and C#, I build scalable, adaptable automations that empower teams to focus on high-value work.

外部链接
在 n8n.io 查看

分享此工作流