Build Weather Forecast AI Agent in 5 min

In Today's AI drive world, learn how to create AI Agents using n8n in few simple steps.

6 min read

In the realm of artificial intelligence, a significant shift is occurring from purely analytical AI to Agentic AI. While standard AI can analyse large datasets and provide insights, Agentic AI goes a step further: it acts. It can understand a request, determine the necessary steps, and use tools to achieve a goal.

Imagine a user asking, “Is it going to rain this weekend?” A standard chatbot might provide a historical average or a vague answer. An Agentic Weather AI, on the other hand, understands the location (from the user or context), uses a specialized tool to fetch real-time data, and then interprets that data to give a precise, conversational answer.

In this step-by-step guide, we will build a conversational weather assistant using n8n, Google Gemini, and the OpenWeatherMap API.

Clap and Comment, if you want a tutorial on what is n8n, and I will create a tutorial.

1. Prerequisites

Before starting, ensure you have:

  1. n8n Account: An n8n Cloud account(initial 14 days are free) or a self-hosted local instance.

  2. Google Gemini Api Key: Generated via Google AI Studio.

  3. OpenWeatherMap API Key: Sign up for a free account on OpenWeatherMap to get an API key.

Clap and Comment if you want to know how to set up n8n for free in local system

2. Architecture Overview

Our n8n workflow consists of five interconnected components:

  • Trigger: The entry point for our workflow. On Chat Message / Webhook (handles incoming user messages). This makes our agent accessible via simple HTTP requests.

  • AI Agent Node: It’s the central hub that receives the user’s message, manages the conversation, and decides which tool to use.

  • Chat Model: Google Gemini (powers natural language understanding).

  • Memory: n8n Simple Memory This allows the agent to maintain context over multiple messages (retains multi-turn context like remembering the location mentioned in the previous chats).

  • Tools: Two OpenWeatherMap nodes (one for current conditions, one for 5-day forecasts).

Now, let’s build it! 😜

Step 1: Set Up the Webhook Trigger

Create a new empty workflow. Add an On chat message (Chat Trigger) node. This automatically equips your agent with a test chat interface and an accessible API endpoint.


Illustration on how to create a Chat Trigger


Step 2: Configure the AI Agent Node

  • Add an AI Agent node to the canvas and connect it to the Chat Trigger.

  • It will connect from the Webhook node (chat node). Now when message/prompt is given to the chat Node it gets triggered and the message/prompt is forwarded to the AI Agent Node.

  • The AI Agent had multiple connecting nodes (Chat Model, Memory, Tool), for now, don’t worry about that.


Illustration on how to bind AI Agent to Chat Trigger

Step 3: Integrate the Google Gemini Model

We have created the AI Agent Node, but it is just a dummy node. It cannot perform any task. So we need to make it start by adding the Chat Model, Memory and the required tools. In this tutorial we will use Gemini Chat model as it is free as of today.

  • Click on the Chat Model’s + icon, which lists all the available chat models. Today we will be using Google Gemini Chat Model.

  • Credential: You need to create a Gemini API Key and need to use it to authenticate your requests.

  • Models: There are multiple models available, you can select that best suits me. In this tutorial we will use gemini-3.1-flash-lite

Illustration on how to bind Gemini Model to AI Agent

Clap and Comment, if you want to learn how to create a Gemini API key for n8n

Adding Credentials and Selecting Gemini Model

Now we can test the basic Workflow that we created. We can open the chat and then give our prompt and get the response as shown below.

Illustration of testing the workflow


Step 4: Add Conversation Memory

We will use n8n Simple Memory in this tutorial. Connect the Simple Memory node to the Memory socket on the AI Agent.
Set the Context Window Length to 5 or 10.

Why this matters: Without memory, asking “What’s the weather in Darjeeling?” followed by “What about tomorrow?” fails because the model forgets “Darjeeling”. Memory preserves this context.

Illustration on how to bind N8N Simple Mempry AI Agent

Below example shows why memory is important to preserve the context while conversing with the chat model.

Illustration showing why memory is important to preserve context

Step 5: Equip with OpenWeatherMap Tools

Now to fetch the weather detail we will use the openWeather API. We will create two separate nodes for the two different API calls (current weather and future weather). Each node will be connected to the Tool input on the AI Agent node.

Illustration on how to add OpenWeatherMap Tool

Once the tool is added we need to create the OpenWeatherMap API Key and add in the tool.
For current weather details we need to select Current Weather in the Operations
The API needs the location detail such as the CityName and the CountryCode. We cannot hardcode this value as it depends on the message/prompt/query. So, instead we need to infer these details from the prompt using below expression.

{{ $fromAI("city", "The city name and 2-letter country code separated by comma, e.g. Darjeeling, IN"
{{ $fromAI("city", "The city name and 2-letter country code separated by comma, e.g. Darjeeling, IN"
{{ $fromAI("city", "The city name and 2-letter country code separated by comma, e.g. Darjeeling, IN"

Illustration on how to extract the CityName from the message/prompt

Similarly for the future weather details we need to add the OpenWeatherMaponce more but in the Operation we need to select 5 Day Forecast. Then our weather forecast is complete as shown below.

Illustration showing the complete workflow for weather forecast.

Below is the illustration of whole workflow works to get the weather forecast for any city given in the prompt

Testing & Response Example

Click Open Chat in n8n and run a multi-turn conversation:

User: What is the current weather in Darjeeling?
Agent: The current weather in Darjeeling is 17.3°C with light rain. Humidity is at 96% with heavy cloud cover.

User: Give me the forecast for the next 3 days.
(The Agent uses memory to retain “Darjeeling” and triggers the 5-day forecast tool.)
Agent:
The weather in Darjeeling for the next three days will remain consistently
rainy with high humidity:

  • Aug 5: Light rain throughout the day. Temps between 16°C and 19°C.

  • Aug 6: Rain continuing, turning moderate by evening. Temps between 16°C and 23°C.

  • Aug 7: Scattered light rain. Temps ranging from 16°C to 20°C.

Next Steps & Enhancements (Missing Content Added)

  • Error Handling: Configure fallback outputs on the tool nodes if the OpenWeatherMap API limit is reached or if an invalid city name is given.

  • Production Deployment: Toggle the workflow from Draft to Active to expose the production webhook URL for production web applications or Telegram/Slack bots.

Summary

You’ve built an autonomous AI agent capable of managing memory, identifying missing parameter information, calling external weather APIs, and formatting responses.

  • How to create chat Trigger,

  • Bind AI Agent to the chat trigger.

  • How to select a Chat Model and add to the AI Agent.

  • How to add Memory to the AI Agent to preserve context

  • How to add OpenWeatherMap Tool to AI Agent to get weather forecast


Enjoyed this build? Leave a clap or comment if you’d like a follow-up guide on self-hosting n8n or building multi-agent systems!

Medium-link: link

Join the newsletter

Be the first to read our articles.

Create a free website with Framer, the website builder loved by startups, designers and agencies.