
As someone who works long hours in tech, weekends are precious for rest and spending quality time with family. However, one recurring task often took away those peaceful moments — buying groceries, especially packaged items like rice, pulses, masala, daal, soap etc. Every week, I found myself opening multiple tabs, comparing prices and offers from online stores like Amazon Fresh and Flipkart Minutes, and spending hours just to ensure I got the best deals.
Then it struck me: “Why not automate this repetitive task using AI Agent?” This thought sparked the creation of my own AI-powered grocery shopping assistant.
Shopping online for groceries, especially packaged items, can be tiring. Checking multiple websites for discounts, verifying reviews, and calculating delivery costs feels like an endless cycle. Often, by the time I made a choice, I was exhausted. I realized this was a perfect task for automation — something that computers excel at and humans find boring.
My grocery assistant is an AI-powered agent that automatically searches and compares packaged items on Amazon Fresh and Flipkart Minutes. It evaluates which store provides the best price, discounts, and quickest delivery, and even places the selected items into my shopping cart.
The assistant is easy to use:
- Manual Entry: You can easily type the packaged items you need (e.g., “Fortune Basmati Rice 5kg”).
- Scanner Feature: You can also upload a handwritten grocery list using a scanner, and the AI extracts the items automatically.
Once you provide your list, the AI handles the rest.
Here’s a simplified explanation of what’s happening:
- Gemini AI: Google’s advanced generative AI model helps make smart choices.
- Browser-use Library: Automates the web browsing using Playwright.
- Agent: Manages and coordinates all the tasks.
- Controller: Performs actions like clicking, typing, and navigating pages.
- DOM Service: Scans webpages to identify necessary information.
Browser-use consists of several key components that work together:
- Agent: The central component that coordinates everything
- Browser: Manages browser instances using Playwright
- Controller: Provides actions that can be performed in the browser
- DOM Service: Extracts and processes the web page structure
Here’s the core Python code using Google’s Gemini:
from browser_use import Agent, Browser, BrowserConfig
from langchain_google_genai import ChatGoogleGenerativeAI
import asyncio
import dotenv
import os
from datetime import datetime
from pydantic import SecretStr
# Load API key securely
dotenv.load_dotenv()
# Set up the Gemini AI model
llm_gemini = ChatGoogleGenerativeAI(
model='gemini-2.0-flash-exp',
api_key=SecretStr(os.getenv('GEMINI_API_KEY'))
)
# Configure browser automation
browser = Browser(
config=BrowserConfig(
chrome_instance_path='/Applications/Google Chrome.app/Contents/MacOS/Google Chrome'
)
)
# Defining the shopping task clearly for the agent
agent = Agent(
task="""
Compare packaged grocery items from Amazon Fresh and Flipkart Minutes based on the provided list.
Take screenshots, compare prices and delivery timelines, and select the best deal to add to the cart.
""",
llm=llm_gemini,
browser=browser,
)
# Running the AI assistant
async def main():
result = await agent.run()
print("Your AI grocery assistant has completed the comparisons and added items to your cart!")
await browser.close()
if __name__ == '__main__':
asyncio.run(main())
- Starting Up
- The browser opens automatically.
- Gemini AI prepares to make decisions.
2. Collecting Product Information
- Searches for each packaged item on Amazon Fresh and Flipkart Minutes.
- Takes screenshots and notes prices, discounts, and delivery fees.
3. Decision Making by AI
- Gemini evaluates and chooses the best product option available.
4. Automated Cart Update
- Adds the selected items into the online shopping cart and provides documented screenshots.
5. Report Generation
- Generates a summary report showing comparisons and selected items clearly.
Automating grocery shopping for packaged items has genuinely improved my life. It freed up my weekends, allowed me more family time, and made shopping stress-free. Now, I confidently get the best deals without spending hours on research.
I’m a Google Cloud enthusiast and AI developer on a mission to transform innovative ideas into tangible solutions. You can find more of my work on GitHub and connect with Linkedin. Follow along for more AI magic!
Clone the GitHub repo, try out the code, and let the possibilities fuel your imagination. With power of browser use agent, you can do so many things. Here’s to shaping the future of AI, together!
Don’t forget to like, share, and clap if you found this useful!
Source Credit: https://medium.com/google-cloud/effortless-grocery-shopping-creating-an-ai-agent-with-gemini-to-automate-your-purchases-a1c51973633b?source=rss—-e52cf94d98af—4