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


"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:
Gemini API Key: Get yours from [Google AI Studio](https://makersuite.google.com/)
OpenWeather API Key: Sign up for a free API key on [OpenWeatherMap](https://openweathermap.org/api)
Create a .env
file with your API keys:
GEMINI_API_KEY=your_google_api_key
WEATHER_API_KEY=your_openweather_api_key
Subscribe to my newsletter
Read articles from Shivam Kumar directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
