8
n8n 中文网amn8n.com

每日天气机器人

中级

这是一个Personal Productivity领域的自动化工作流,包含 9 个节点。主要使用 Set, Telegram, FormTrigger, HttpRequest, ScheduleTrigger 等节点。 通过OpenWeatherMap向Telegram发送每日和按需天气报告

前置要求
  • Telegram Bot Token
  • 可能需要目标 API 的认证凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "EtMbMlSmiCmshLlm",
  "meta": {
    "instanceId": "00137a678c70b895ffbf480dac6a13dc8f053e854d987464a615f9ea30d97eee",
    "templateCredsSetupCompleted": true
  },
  "name": "每日天气机器人",
  "tags": [],
  "nodes": [
    {
      "id": "d5d3309c-a736-4244-8973-ee8bb4df9e5e",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -20,
        -100
      ],
      "parameters": {
        "width": 460,
        "height": 140,
        "content": "## 定时触发器(每日上午 08:00)"
      },
      "typeVersion": 1
    },
    {
      "id": "75c18662-b969-4f48-8a05-1429c2f81567",
      "name": "获取天气数据",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        20,
        340
      ],
      "parameters": {
        "url": "=https://api.openweathermap.org/data/2.5/weather?q={{ $json['City Name'] }},{{ $json['Country Name'] }}&APPID=key&units=metric",
        "options": {}
      },
      "typeVersion": 4.2
    },
    {
      "id": "3b84cd51-bf28-4a3d-af86-f2acbe1bf097",
      "name": "格式化天气消息",
      "type": "n8n-nodes-base.set",
      "position": [
        240,
        340
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "bb388fef-4f43-468e-bdb2-1a65c40f5194",
              "name": "message",
              "type": "string",
              "value": "={{ \n  (() => {\n    const desc = $json.weather[0].description;\n    const temp = $json.main.temp;\n    const hum = $json.main.humidity;\n    const pres = $json.main.pressure;\n    const wind = $json.wind.speed;\n    const city = $json.name;\n    const country = $json.sys.country;\n\n    // Convert UNIX timestamps to IST (Asia/Kolkata)\n    const sunrise = new Date($json.sys.sunrise * 1000).toLocaleTimeString('en-IN', { timeZone: 'Asia/Kolkata' });\n    const sunset = new Date($json.sys.sunset * 1000).toLocaleTimeString('en-IN', { timeZone: 'Asia/Kolkata' });\n\n    // Format current date in IST\n    const now = new Date();\n    const dateStr = now.toLocaleDateString('en-IN', {\n      weekday: 'long', year: 'numeric', month: 'long', day: 'numeric',\n      timeZone: 'Asia/Kolkata'\n    });\n\n    return `📅 ${dateStr}\n🌤 Weather in ${city}, ${country}:\nCondition: ${desc}\nTemperature: ${temp}°C\n💧 Humidity: ${hum}%\n🌬 Wind Speed: ${wind} m/s\n🔼 Pressure: ${pres} hPa\n🌅 Sunrise: ${sunrise}\n🌇 Sunset: ${sunset}`;\n  })()\n}}\n"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "c601e86a-28d1-4cc1-b643-ca95e14573b2",
      "name": "发送 Telegram 消息",
      "type": "n8n-nodes-base.telegram",
      "position": [
        460,
        340
      ],
      "webhookId": "7285e616-e38d-4b2a-bb06-3cbbe1a65fb6",
      "parameters": {
        "text": "={{ $json.message }}",
        "chatId": "telegramChatId",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "credentials": {
        "telegramApi": {
          "id": "NuFto4S6tg5Lkuvu",
          "name": "abhi today"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "ebf95ad7-5156-4032-87a4-11e85eb0c582",
      "name": "表单提交时",
      "type": "n8n-nodes-base.formTrigger",
      "position": [
        -220,
        220
      ],
      "webhookId": "9f30d988-032d-41cc-993c-600414c5f5b3",
      "parameters": {
        "options": {},
        "formTitle": "Daily Weather Bot",
        "formFields": {
          "values": [
            {
              "fieldLabel": "City Name"
            },
            {
              "fieldLabel": "Country Name"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "2d425b50-6bfc-433d-8baf-172384bd3181",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        380,
        720
      ],
      "parameters": {
        "height": 120,
        "content": "## Telegram 输出"
      },
      "typeVersion": 1
    },
    {
      "id": "3108b92c-6f97-4fee-b4bb-7140b2419f5d",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        20,
        720
      ],
      "parameters": {
        "width": 150,
        "height": 260,
        "content": "## API 调用"
      },
      "typeVersion": 1
    },
    {
      "id": "a7031c56-09ac-4d05-95fa-9ff7d82a6314",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -380,
        720
      ],
      "parameters": {
        "width": 200,
        "height": 260,
        "content": "## 每日计划"
      },
      "typeVersion": 1
    },
    {
      "id": "a757108c-961a-4cd2-8fa4-e583c26120ea",
      "name": "定时触发器",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -220,
        460
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "triggerAtHour": 8
            }
          ]
        }
      },
      "typeVersion": 1.2
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "bb82186d-3706-43b7-b69c-1a526777461d",
  "connections": {
    "Get Weather Data": {
      "main": [
        [
          {
            "node": "Format Weather Message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "Get Weather Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "On form submission": {
      "main": [
        [
          {
            "node": "Get Weather Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Weather Message": {
      "main": [
        [
          {
            "node": "Send Telegram Message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

中级 - 个人效率

需要付费吗?

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

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

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

作者
Abhishek Patoliya

Abhishek Patoliya

@abhishekpatoliya

Experienced n8n developer specializing in business process automation and system integrations. I've helped dozens of companies automate their workflows, from CRM synchronization to marketing automation pipelines. Whether you need a simple trigger-based workflow or a complex multi-branch automation, I can bring your ideas to life.

外部链接
在 n8n.io 查看

分享此工作流