langgraphagentspythonecommerce

Build a Cross-Platform Product Research Agent with LangGraph

Build a LangGraph agent that searches Amazon and Walmart in parallel, pulls YouTube reviews for the top candidates, and returns a structured buying recommendation. Full code included.

10 min read

Before buying anything over $100, most people do the same ritual: open Amazon, open Walmart in another tab, Google for reviews, find a YouTube video, and spend 30 minutes deciding. It is tedious, the data is scattered, and you often miss that the Walmart price is $40 cheaper with free same-day pickup.

This guide builds a product research agent that runs that entire process in under 10 seconds. Given a product query, it fetches live prices and ratings from both Amazon and Walmart, pulls YouTube review videos for the top candidates, and returns a structured buying recommendation -- all in a single LangGraph agent call.

What You Will Build

A LangGraph agent that, given a query like "standing desk under $400", will:

  1. Search Amazon and Walmart simultaneously for matching products
  2. Cross-reference prices, ratings, review counts, and fulfillment options
  3. Find YouTube review videos for the top 2--3 candidates to surface real user sentiment
  4. Return a structured recommendation with price delta, best deal, and review links

This is a realistic daily use case. The multi-platform nature of the problem is exactly what makes it hard to solve with a single-source API.

Prerequisites

  • Python 3.10+
  • A Scavio API key (free tier includes 1,000 credits/month)
  • An OpenAI API key

Step 1: Install Dependencies

Bash
pip install langchain-scavio langchain-openai langgraph
Bash
export SCAVIO_API_KEY="sk_live_your_key"
export OPENAI_API_KEY="sk-your_openai_key"

Step 2: Define the Tools

The agent needs three tools: Amazon search, Walmart search, and YouTube search. All three come from langchain-scavio:

Python
from langchain_scavio import (
    ScavioAmazonSearch,
    ScavioWalmartSearch,
    ScavioYouTubeSearch,
)

tools = [
    ScavioAmazonSearch(max_results=5),
    ScavioWalmartSearch(max_results=5),
    ScavioYouTubeSearch(max_results=3),
]

Each tool has a description that the LLM uses to decide when to call it. The agent will invoke Amazon and Walmart in parallel for pricing, then YouTube for the shortlisted products.

Step 3: Build the Agent

Python
from langgraph.prebuilt import create_react_agent
from langchain_openai import ChatOpenAI

llm = ChatOpenAI(model="gpt-4o", temperature=0)

agent = create_react_agent(
    llm,
    tools=tools,
    state_modifier="""You are a product research assistant.
When given a product query:
1. Search Amazon AND Walmart for the product.
2. Compare prices, ratings, and review counts across both platforms.
3. For the top 2 candidates, search YouTube for "[product name] review".
4. Return a structured recommendation with:
   - Best price overall and where to buy
   - Price difference between platforms (if significant)
   - Rating comparison
   - Whether free shipping or pickup is available
   - 1-2 relevant YouTube review links
Keep the answer concise and actionable.""",
)

Step 4: Run It

Python
result = agent.invoke({
    "messages": [
        {
            "role": "user",
            "content": "I want to buy a KitchenAid stand mixer. Find me the best deal.",
        }
    ]
})

print(result["messages"][-1].content)

Here is what the agent actually does behind the scenes:

  1. Calls ScavioAmazonSearch with query "KitchenAid stand mixer"
  2. Calls ScavioWalmartSearch with the same query
  3. Compares the top results -- price, rating, stock, shipping
  4. Calls ScavioYouTubeSearch with "KitchenAid 5qt stand mixer review 2026"
  5. Synthesizes a recommendation

Example output:

Text
Best deal: KitchenAid Artisan Series 5-Qt Stand Mixer (Model KSM150PS)

Amazon: $349.95 — 4.8 stars (12,400 reviews), Prime free delivery tomorrow
Walmart: $329.00 — 4.7 stars (8,200 reviews), free shipping + free store pickup

Recommendation: Buy from Walmart. You save $20.95 and can pick it up today
if you have a store nearby. Ratings are nearly identical.

YouTube reviews:
- "KitchenAid 5Qt Stand Mixer - Is It Worth It in 2026?" — 180k views
  https://youtube.com/watch?v=...
- "KitchenAid vs Cuisinart: Which Stand Mixer Should You Buy?" — 94k views
  https://youtube.com/watch?v=...

Why Parallel Calls Matter

The Amazon and Walmart searches are independent -- there is no reason to wait for one before starting the other. LangGraph's create_react_agent can issue both calls in a single step when the LLM decides to use both tools together.

You can also enforce parallel execution explicitly if you want deterministic behavior regardless of what the LLM decides:

Python
import asyncio
from langchain_scavio import ScavioAmazonSearch, ScavioWalmartSearch

amazon = ScavioAmazonSearch(max_results=5)
walmart = ScavioWalmartSearch(max_results=5)

async def fetch_both(query: str):
    amazon_results, walmart_results = await asyncio.gather(
        amazon.ainvoke({"query": query}),
        walmart.ainvoke({"query": query}),
    )
    return amazon_results, walmart_results

amazon_data, walmart_data = asyncio.run(fetch_both("KitchenAid stand mixer"))

Both API calls complete in parallel. Total wall time is roughly the slower of the two requests rather than the sum.

Going Further: Price Drop Monitoring

The same agent pattern works as a scheduled job. Run it nightly against a watchlist of products and alert when a price drops below a threshold:

Python
watchlist = [
    {"query": "KitchenAid stand mixer", "max_price": 299},
    {"query": "Sony WH-1000XM6 headphones", "max_price": 280},
    {"query": "Instant Pot Duo 7-in-1", "max_price": 79},
]

async def check_deals():
    for item in watchlist:
        amazon_data, walmart_data = await fetch_both(item["query"])
        # Parse prices and compare against item["max_price"]
        # Send alert if below threshold
        ...

Each check costs 2 credits (one Amazon search + one Walmart search). A 100-item watchlist checked daily costs 6,000 credits/month -- well within the Project plan's 7,000 credits.

What Makes This Impossible With a Single-Platform API

The value here is not any individual search -- it is the cross-platform comparison. Amazon alone tells you the Amazon price. Walmart alone tells you the Walmart price. Only a unified API that returns structured data from both lets the LLM reason about the delta.

Data neededSingle-platform APIScavio
Amazon price + ratingAmazon API onlyYes
Walmart price + fulfillmentWalmart API onlyYes
YouTube review videosYouTube API onlyYes
All three in one call, one keyNoYes
Structured JSON for LLM reasoningVaries (often HTML)Yes

Full Agent Code

Python
import asyncio
from langgraph.prebuilt import create_react_agent
from langchain_openai import ChatOpenAI
from langchain_scavio import (
    ScavioAmazonSearch,
    ScavioWalmartSearch,
    ScavioYouTubeSearch,
)

tools = [
    ScavioAmazonSearch(max_results=5),
    ScavioWalmartSearch(max_results=5),
    ScavioYouTubeSearch(max_results=3),
]

agent = create_react_agent(
    ChatOpenAI(model="gpt-4o", temperature=0),
    tools=tools,
    state_modifier="""You are a product research assistant.
When given a product query:
1. Search Amazon AND Walmart for the product.
2. Compare prices, ratings, review counts, and shipping options.
3. Search YouTube for reviews of the top 1-2 candidates.
4. Return a concise buying recommendation with the best deal and why.""",
)

def research_product(query: str) -> str:
    result = agent.invoke({
        "messages": [{"role": "user", "content": query}]
    })
    return result["messages"][-1].content

if __name__ == "__main__":
    print(research_product("I want to buy a Ninja air fryer, find me the best deal"))

Next Steps