๐ŸŒ† Aware AI Agent: Weather, Local Insights, and Smart Conversations

Shivam KumarShivam Kumar
2 min read

"Kya haal hai Delhi ke?" โ€” this simple, casual question triggers an AI-powered agent that not only shares real-time weather updates but also offers local insights about the city. Ask anything โ€” from the best places to visit, to how the job market is โ€” and the agent responds like an informed local.

In this post, we'll walk through how to build an AI agent that: - Detects city names and intent from casual user messages (in Hinglish or English) - Shares live weather updates using the OpenWeather API - Stays in context about that city and answers follow-up questions naturally - Uses chain-of-thought reasoning to answer questions like a thoughtful local


Let's build this intelligent city-aware agent using Google Gemini Flash and Node.js!

๐Ÿš€ What We'll Build

An AI agent that can:

  • โœ… Understand casual city mentions from a variety of user inputs

  • โœ… Fetch real-time weather data based on the mentioned city

  • โœ… Respond intelligently with insights on that city

  • โœ… Remain in "city mode" for all subsequent follow-up questions

  • โœ… Use Chain of Thought reasoning to offer detailed, logical responses, like: -

    • "What's famous in Delhi?"

    • "What are the must-visit places in Goa?"

    • "How's the job market in Bangalore?"

The key feature here is that the agent stays focused on the city โ€” and can provide smart, step-by-step reasoning to back its answers.


โš™๏ธ Tech Stack

  • LLM: Google Gemini 1.5 Flash via API

  • Weather API: OpenWeatherMap (for live weather updates)

  • Runtime: Node.js (for the backend and logic handling)

  • Input: Command-line interface (CLI) using Node's readline

  • Reasoning: Chain-of-Thought (CoT) prompting for detailed, accurate answers


๐Ÿ“ฆ Prerequisites

Before diving into the code, make sure you have these setup:

Create a .env file with your API keys:

GEMINI_API_KEY=your_google_api_key
WEATHER_API_KEY=your_openweather_api_key
0
Subscribe to my newsletter

Read articles from Shivam Kumar directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Shivam Kumar
Shivam Kumar