agent.shopFor()
command. You can execute a number of web-based workflows, including tracking e-commerce prices across multiple retailers, aggregating product deals in real time, and automating price comparisons to help users make informed purchasing decisions.
Here’s a summary of what the AgP JS SDK empowers you to do when monitoring prices across e-commerce websites or carrying our other shopping-related tasks:
- Define a list of products to monitor.
- Use an agent to search for each product across e-commerce websites.
- Receive real-time updates when information is available.
- Log the prices or messages to the console.
agent.shopFor()
method. You’ll see how the AgP JS SDK uses agents to scan the web and extract information, track progress in real time, and report results — all with minimal code.
Monitor e-commerce prices
Situation: You want to track product prices across multiple online retailers — for example, to find the best deal on the latest iPhone, MacBook, or AirPods — but manually checking websites is slow and inconsistent. You need a way to automate these searches and collect real-time updates efficiently. Problem: How can you automatically search for multiple products across e-commerce sites, monitor price changes, and receive live updates — all without building complex scraping or API integrations from scratch? Solution: The AgP JS SDK lets you automate price tracking using theagent.shopFor()
command. It enables you to define a list of products, execute concurrent search tasks across multiple retailers, and receive live updates as new pricing data or deals are found. With real-time event monitoring and automated completion handling, you can seamlessly aggregate and compare e-commerce data without writing repetitive code.
Step 1: Initialize the SDK
Start by initializing the SDK and setting up authentication with Portal-H. This ensures that your agent can securely access the web and run shopping tasks.Step 2: Define the products
Create a list of product names that you want to track. Each product in this array will become a separate shopping task.Step 3: Start shopping tasks
Use theagent.shopFor()
command to search for each product online. The SDK will handle the browsing and information gathering automatically.
Step 4: Subscribe to real-time updates
Receive live updates from the agent while it searches.You’ll see messages such as price findings or deal comparisons in your console.
Step 5: Wait for task completion
Ensure each task completes before moving to the next one.Step 6: Put it all together and run
Here’s a complete example that includes all previous steps, assembled and ready to run:Browser example
Outcome
The AgP JS SDK, running the above code asyncronously, will follow a sequence that:- Initializes the SDK and authenticates through Portal-H.
- Provides real-time updates.
- Generates an accurate and detailed response, for example: