🛍️ Product Shopping Assistant - India
A conversational-first shopping agent powered by Vercel AI SDK, Google Gemini, and Google Shopping API (via SerpApi). This is a product shopping ONLY assistant that helps users find and compare products from Indian online stores.
Key Features:
- 🤖 Conversational AI that understands shopping needs
- 🔍 Google Shopping search (India-specific, English)
- 🔗 NEW! Amazon product lookup by link - Get instant details + cross-platform price comparison
- ⭐ Intelligent filtering: Top 5 products by rating & price
- 💰 Price comparisons in INR (₹)
- 🏪 Focus on trusted Indian retailers (Amazon.in, Flipkart, Croma, etc.)
- 🎯 Smart sorting: Highest ratings first, then lowest prices
-
Copy
.env.exampleto.envand add your API keys:GEMINI_API_KEY- Required for the AI agent (get from https://aistudio.google.com/app/apikey)SERPAPI_KEY- Required for Google Shopping searches (get from https://serpapi.com/)- Optional:
DEFAULT_MODEL- Gemini model to use (default: gemini-1.5-flash)
-
Install dependencies:
npm install
-
Build the project:
npm run build
The agent autonomously decides when to search for products and can chain multiple tool calls:
# Basic usage
node ./dist/index.js agent "Find me the best iPhone under 60000 in Mumbai"
# With interactive preference prompts
node ./dist/index.js agent "Show me laptops" --interactive
# Specify location and preferred stores
node ./dist/index.js agent "Gaming phones" --location "Bengaluru, India" --stores "Amazon,Flipkart"
# Get structured JSON output with full trace
node ./dist/index.js agent "Best headphones" --json
# Use a specific Gemini model
node ./dist/index.js agent "Smartwatches under 5000" -m gemini-1.5-proNEW! Conversational shopping assistant with intelligent product filtering:
- Searches in English for India (
gl=in,hl=en) - Returns TOP 5 products only (highest rated, best priced)
- Smart sorting: Rating (high→low) then Price (low→high)
- Filters out products without ratings
- Prioritizes Indian merchants
# Start interactive shopping session
node ./dist/index.js chat-enhanced
# Single query with enhanced filtering
node ./dist/index.js ask-enhanced "Best laptop under 50000"Example Conversations:
You: I need a gaming laptop under 40K
Agent: What specs do you need? RAM, processor type?
You: 8GB RAM, good graphics
Agent: Got it! Gaming laptop, 8GB+ RAM, good graphics, under ₹40K. Should I search?
You: yes
Agent: [Shows top 5 laptops with ratings, prices, stores]
Paste any Amazon.in product link to get instant details + cross-platform price comparison:
# Start enhanced agent
node ./dist/index.js chat-enhanced
# Then paste Amazon link:
You: https://www.amazon.in/dp/B08N5WRWNW give me details
Agent: [Shows product details: price, rating, reviews, specs]
Would you like me to compare prices on other platforms?
You: yes
Agent: [Searches Flipkart, Croma, etc. and shows price comparison]Supported Amazon URL formats:
https://www.amazon.in/dp/ASINhttps://www.amazon.in/gp/product/ASINhttps://amazon.in/Product-Name/dp/ASIN- Direct ASIN code (e.g.,
B08N5WRWNW)
What you get:
- 🏷️ Product name and title
- 💵 Current Amazon price
- ⭐ Star rating + review count
- 📋 Key specifications
- 💬 Top customer reviews (3 snippets)
- 🔗 Direct purchase link
- 💡 Automatic offer to compare prices across platforms
📖 See DOCS/AMAZON_LOOKUP.md for detailed guide
Interactive chat session with context memory and autonomous tool use:
# Start conversational agent (maintains context across turns)
node ./dist/index.js chat-agent
# With preferences
node ./dist/index.js chat-agent --location "Mumbai, India" --stores "Amazon,Flipkart"
# Commands in chat:
# - Type your message naturally
# - "clear" - Reset conversation history
# - "exit" - Quit# Simple chat (single prompt, no context)
node ./dist/index.js chat "Hello, what's the weather?"
# Interactive conversation loop (with context, no tools)
node ./dist/index.js converse
# Direct search (no AI)
node ./dist/index.js search "iPhone 14" -n 5
# Ask with tool orchestration (older non-agent mode)
node ./dist/index.js ask "Where to buy iPhone?"The enhanced agent implements intelligent result processing:
- Fetch: Requests 20-30 products from Google Shopping API
- Filter: Keeps only products with ratings and valid prices
- Sort: First by rating (high→low), then by price (low→high)
- Top 5: Returns only the best 5 products
- Insights: Calculates price ranges, average ratings, review counts
Result Quality Guarantee:
- ⭐ All products have customer ratings
- 💰 Valid prices in INR (₹)
- 🏪 Trusted Indian merchants prioritized
- 📊 Sorted for best value (quality + price)
Search Parameters:
engine:google_shopping(ONLY - no web search)gl:in(India region)hl:en(English language)google_domain:google.co.incurrency:INRlocation: "India"
JSON Fields Extracted:
title- Product nameextracted_price- Price as number (for sorting)price- Formatted price stringsource- Store name (Amazon.in, Flipkart, etc.)rating- Star rating (1-5)reviews- Number of customer reviewsproduct_link- Direct link to product pagethumbnail- Product image URL
- Shopping Focus: ONLY discusses products and shopping
- Context Memory: Remembers budget, preferences, past searches
- Natural Chat: Asks about needs before searching
- Smart Tool Use: Searches only when user needs product options
- No Generic AI: Redirects non-shopping questions politely
Uses Vercel AI SDK with Gemini function-calling:
-
Autonomous tool selection
-
Multi-step reasoning
-
Query analysis and refinement
-
Result synthesis with insights
-
Error recovery and fallbacks
- Prices displayed in ₹ (INR)
-
Interactive Mode: Optionally prompts for user preferences (budget, stores, location) before searching
-
Streaming Responses: Real-time token streaming for better UX
-
Structured Output: Use
--jsonflag to get full execution trace with tool calls and results
# Start shopping session
node ./dist/index.js chat-enhanced
You: Hi, I need a laptop for college
Assistant: Hey! I'd love to help you find a great laptop for college! 🎓
Let me ask a few questions to find the perfect match:
What's your budget? (e.g., under 50000 INR)
You: Around 40000
Assistant: Perfect! ₹40,000 is a good budget for a student laptop.
What will you mainly use it for?
- Basic tasks (browsing, docs, videos)?
- Programming/coding?
- Design/video editing?
- Gaming?
You: Programming and some light gaming
Assistant: Got it! So you'll need decent specs - good processor, 8GB+ RAM.
Any preferences? (Intel/AMD? Specific brands?)
You: No preference, just want good value
Assistant: Let me search for the best laptops in your budget...
🔍 Searching Google Shopping (India): "laptop programming gaming under 40000 India"
📦 Raw results: 25 products
⭐ Top 5 best products (by rating & price)
- Requires `GEMINI_API_KEY` and `SERPAPI_KEY` in `.env`
- Default model is `gemini-1.5-flash` (fast and cost-effective)
- Agent iterates up to 5 steps by default (configurable with `--max-iterations`)
- For production use, consider adding rate limiting, retry logic, and comprehensive error handling