{
  "id": "swyQswrcWUlafM3c",
  "name": "Dynamic Weather Forecast Bot",
  "tags": [],
  "nodes": [
    {
      "id": "145867c4-b1cf-4079-b198-d2342493cfac",
      "name": "When clicking \u2018Execute workflow\u2019",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -208,
        112
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "ff7f8295-5e8d-4b0f-9d56-7b7213901d9d",
      "name": "Schedule Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -208,
        304
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "triggerAtHour": 9
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "7547bfad-428e-4901-8b18-846884f0faab",
      "name": "Fetch Weather Data",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        16,
        208
      ],
      "parameters": {
        "url": "https://api.open-meteo.com/v1/forecast?latitude=35.469&longitude=140.2981&daily=temperature_2m_min,temperature_2m_max&hourly=temperature_2m&current=temperature_2m,relative_humidity_2m",
        "options": {}
      },
      "typeVersion": 4.3
    },
    {
      "id": "a86a70a0-527b-4b2b-9022-4d4531a141ee",
      "name": "Format Daily Summary",
      "type": "n8n-nodes-base.code",
      "position": [
        240,
        208
      ],
      "parameters": {
        "jsCode": "const data = $input.all()[0].json;\n\n// Today's min/max temperature (from the first daily entry)\nconst minTemp = data.daily.temperature_2m_min[0];\nconst maxTemp = data.daily.temperature_2m_max[0];\n\n// Create the message\nconst message = `Today's high in Shibuya will be ${maxTemp}\u00b0C and the low will be ${minTemp}\u00b0C.`;\n\nreturn {\n  message\n};"
      },
      "typeVersion": 2
    },
    {
      "id": "693a2e08-fd54-41f3-b18c-b4105bd1d58b",
      "name": "Send Email Summary",
      "type": "n8n-nodes-base.gmail",
      "position": [
        464,
        208
      ],
      "parameters": {
        "sendTo": "user@example.com",
        "message": "= {{ $json.message }}\nHave a great day!",
        "options": {
          "appendAttribution": false
        },
        "subject": "Daily Weather Forecast"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "75a04b8e-d505-44f6-a2c6-56cad532637f",
      "name": "Send Slack Summary",
      "type": "n8n-nodes-base.slack",
      "position": [
        688,
        208
      ],
      "parameters": {
        "text": "=\u3010Weather Forecast\u3011\n{{ $('Format Daily Summary').item.json.message }}\nHave a great day!",
        "select": "channel",
        "channelId": {
          "__rl": true,
          "mode": "list",
          "value": "C09RLAAP0BY",
          "cachedResultName": "\u30bd\u30fc\u30b7\u30e3\u30eb"
        },
        "otherOptions": {
          "includeLinkToWorkflow": false
        },
        "authentication": "oAuth2"
      },
      "credentials": {
        "slackOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "bfe7d55e-51e2-4126-bb6b-9aa2a5e332f4",
      "name": "Workflow Description",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -880,
        16
      ],
      "parameters": {
        "width": 600,
        "height": 966,
        "content": "# Automate Weather Reports and AI-Powered Forecasts to Gmail and Slack\n\nThis workflow provides a comprehensive weather reporting system with two main functionalities: a scheduled daily summary and an interactive AI agent for dynamic queries.\n\n## How it works\n\nThis workflow operates in two distinct modes:\n\n1.  **Scheduled Daily Summary (Top Flow):**\n    *   Triggers automatically every day at 9:00 AM (customizable) or can be run manually.\n    *   Fetches the latest weather data for a specified location from the Open-Meteo API.\n    *   Formats a message with the day's maximum and minimum temperatures.\n    *   Sends this summary to a designated Gmail address and a Slack channel.\n\n2.  **AI-Powered Forecasts via Chat (Bottom Flow):**\n    *   When you send a message to the Chat Trigger webhook, it activates the AI Agent.\n    *   The AI Agent, powered by an OpenAI model, understands natural language questions.\n    *   The agent uses an HTTP Request tool to fetch real-time, specific data from the weather API to answer your question.\n    *   The generated answer is then sent back to you via both Gmail and Slack.\n\n## How to set up\n\n1.  **Configure Credentials:** Add your credentials for OpenAI, Gmail, and Slack.\n2.  **Set Your Location:** In the `Fetch Weather Data` and `HTTP Request Tool for AI` nodes, update the `latitude` and `longitude` in the URL to your desired location.\n3.  **Update Email and Slack:** In the `Send...` nodes for both flows, change the recipient email and select your desired Slack channel.\n4.  **Activate the Workflow!**"
      },
      "typeVersion": 1
    },
    {
      "id": "749e984d-1e8e-4424-b930-52c1bccfc39c",
      "name": "When chat message received",
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "position": [
        -208,
        632
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 1.3
    },
    {
      "id": "b52d6926-b3d1-456c-adfb-e04896b2162f",
      "name": "AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        72,
        632
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "8e3865ab-6e1f-42be-8902-d19d24a3af3b",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        16,
        856
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "c2c7a62a-28ce-4227-ab25-848448c21c98",
      "name": "Simple Memory",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        144,
        856
      ],
      "parameters": {},
      "typeVersion": 1.3
    },
    {
      "id": "e16ecb69-611f-4744-a9c2-299039d6bd2b",
      "name": "HTTP Request Tool for AI",
      "type": "n8n-nodes-base.httpRequestTool",
      "position": [
        304,
        864
      ],
      "parameters": {
        "url": "https://api.open-meteo.com/v1/forecast?latitude=35.469&longitude=140.2981&daily=temperature_2m_min,temperature_2m_max&hourly=temperature_2m&current=temperature_2m,relative_humidity_2m",
        "options": {}
      },
      "typeVersion": 4.3
    },
    {
      "id": "cedcf04f-4bd0-4290-8296-185947d90eb1",
      "name": "Send AI Response via Email",
      "type": "n8n-nodes-base.gmail",
      "position": [
        480,
        632
      ],
      "parameters": {
        "sendTo": "user@example.com",
        "message": "={{ $json.output }}",
        "options": {
          "appendAttribution": false
        },
        "subject": "AI Weather Assistant"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "da31f23a-7a1c-4acc-a0e1-6ba62fc49bc8",
      "name": "Send AI Response via Slack",
      "type": "n8n-nodes-base.slack",
      "position": [
        704,
        632
      ],
      "parameters": {
        "text": "={{ $('AI Agent').item.json.output }}",
        "select": "channel",
        "channelId": {
          "__rl": true,
          "mode": "list",
          "value": "C09RLAAP0BY",
          "cachedResultName": "\u30bd\u30fc\u30b7\u30e3\u30eb"
        },
        "otherOptions": {
          "includeLinkToWorkflow": false
        },
        "authentication": "oAuth2"
      },
      "credentials": {
        "slackOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "7520b78c-0505-4528-9668-d34c48366c41",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        128,
        16
      ],
      "parameters": {
        "width": 320,
        "content": "## Daily Summary Flow\nThis flow runs on a schedule to send a daily weather summary."
      },
      "typeVersion": 1
    },
    {
      "id": "24ae4b4e-3d66-41fe-9d9e-31c626722aef",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        0,
        448
      ],
      "parameters": {
        "width": 360,
        "content": "## AI Agent Flow\nThis flow is triggered by a chat message and uses an AI agent to answer specific weather questions."
      },
      "typeVersion": 1
    },
    {
      "id": "4fd0399a-41e2-4391-934f-509045d1cd90",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -32,
        1024
      ],
      "parameters": {
        "width": 460,
        "content": "### Agent Tools\nThese are the tools available to the AI Agent. It uses a language model (OpenAI), memory to recall conversation, and an HTTP Request tool to fetch live data."
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "680f0892-59d1-48c4-84e8-790a96c683d0",
  "connections": {
    "AI Agent": {
      "main": [
        [
          {
            "node": "Send AI Response via Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Simple Memory": {
      "ai_memory": [
        [
          {
            "node": "AI Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "Fetch Weather Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Weather Data": {
      "main": [
        [
          {
            "node": "Format Daily Summary",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Email Summary": {
      "main": [
        [
          {
            "node": "Send Slack Summary",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Daily Summary": {
      "main": [
        [
          {
            "node": "Send Email Summary",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request Tool for AI": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Send AI Response via Email": {
      "main": [
        [
          {
            "node": "Send AI Response via Slack",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When chat message received": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When clicking \u2018Execute workflow\u2019": {
      "main": [
        [
          {
            "node": "Fetch Weather Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}