Lesson 21medium10 min

Adding the OpenWeatherMap Intelligence Tool

Integrate real-time weather forecasts so the agent can provide transit and outdoor meeting advice.

Learning Objectives

  • Obtain and configure an OpenWeatherMap API key
  • Attach OpenWeatherMap as an agent tool with dynamic city arguments
  • Verify weather observations in agent thought logs

Adding the OpenWeatherMap Intelligence Tool

A thorough executive assistant monitors weather conditions to warn about commute disruptions or outdoor meeting conflicts.

Setting Up OpenWeatherMap

  1. Sign up at openweathermap.org and copy your free API key.
  2. In n8n, drag from the AI Agent Tools port and search for OpenWeatherMap.
  3. Tool Name: get_weather_forecast
  4. Tool Description:
    Retrieve current weather conditions, temperature, and precipitation forecasts for a given city name.
    
  5. Configure the tool parameters to allow dynamic city queries:
    • City: ={{ $fromAI('city', 'The city name to query, e.g. San Francisco') }}
Advertisement

Testing the Tool

Run a test query: "What is the weather in San Francisco today?" Inspect the execution trace: notice the agent emitting a tool call to get_weather_forecast with {"city": "San Francisco"}.