# AI Product Recommendation Agent (`matymar/ai-product-recommendation-agent`) Actor

The AI Product Recommendation Agent helps users find the best products based on their needs using a simple query. It analyzes product listings, reviews, and ratings to provide well-informed recommendations.

- **URL**: https://apify.com/matymar/ai-product-recommendation-agent.md
- **Developed by:** [Matouš Mařík](https://apify.com/matymar) (community)
- **Categories:** AI, Agents, Open source
- **Stats:** 103 total users, 0 monthly users, 82.4% runs succeeded, 9 bookmarks
- **User rating**: 1.69 out of 5 stars

## Pricing

Pay per event

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.
Actors are written with capital "A".

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## AI Product Recommendation Agent

[![AI Product Recommendation Agent](https://apify.com/actor-badge?actor=matymar/ai-product-recommendation-agent)](https://apify.com/matymar/ai-product-recommendation-agent)

The AI Product Recommendation agent enables you to get product recommendations using just a simple prompt.
It will automatically suggest products matching your criteria and it will also consider reviews of those products to give you the best possible options.

You only need to provide a query about the product you're looking for and the Agent takes care of the rest!

### Development

If you are interested in the development check out the [GitHub Repository](https://github.com/apify-projects/ai-product-recommendation-agent.git).
Feel free to contribute!

### Examples

Example queries:

- "Recommend me a book about music theory. I'm a complete beginner and I want to learn the basics."
- "I want to buy a laptop for about 1000$, what are the best options? I want the laptop to have great battery life. and have less than 15 inches screen size."
- "I am looking for some nice decor for my living room. I like modern and minimalistic styles. The color should be white. Can you recommend me some products?"

The agent will produce outputs to both dataset and key-value-store. A URL to the final HTML with the recommendation will be given in the terminal status message.

#### Example query with its respective output

##### Input

```json
{
    "query": "Recommend me a book about music theory. I'm a complete beginner and I want to learn the basics.",
    "modelName": "gpt-4o",
    "debug": false
}
```

##### Output

```md
Here are three highly recommended books for learning music theory as a beginner:

1. **[The Essential Guide to Music Theory: Everything You Need to Learn the Basics and Beyond](https://www.amazon.com/dp/B0CHL7M2M5)**

    - **Price**: $13.69
    - **Rating**: 4.8 stars
    - **Summary**: This book is known for its accessibility and clear presentation of music theory fundamentals. It is highly praised for its logical structure and engaging style, making it suitable for both newcomers and those refreshing their knowledge.
    - **Pros**:
        - Simple and effective organization.
        - Includes valuable exercises to enhance learning.
        - Engaging and comprehensive for beginners.
    - **Cons**:
        - Some reviewers wished for more advanced content, which might not be an issue for beginners.

2. **[Music Theory for Beginners: A Pocket-Size Guide for Aspiring Musicians of Any Instrument](https://www.amazon.com/dp/B0CWXGNXTY)**

    - **Price**: $10.99
    - **Rating**: 4.8 stars
    - **Summary**: This guide demystifies music theory and provides an inspiring understanding of music. It's noted for its entertaining and creative approach, making the subject fun to explore.
    - **Pros**:
        - Easy to understand, with creative explanations.
        - Suitable for any musical instrument.
        - Covers fundamental aspects with entertaining examples.
    - **Cons**:
        - Some formatting issues reported.
        - More oriented towards classical music, which might be irrelevant to some popular genres.

3. **[Accelerated Piano Adventures for the Older Beginner - Theory Book 1](https://www.amazon.com/dp/1616772069)**
    - **Price**: $7.50
    - **Rating**: 4.8 stars
    - **Summary**: While this book is specifically focused on piano, it's a great introductory text for those with no musical background. It is highly recommended by both instructors and learners for its simplicity and efficacy in teaching music theory basics.
    - **Pros**:
        - Simple and effective for complete beginners.
        - Lauded for slowing down complex concepts so they can be truly understood.
    - **Cons**:
        - Primarily focused on piano, so might not be comprehensive for other instruments.

#### Recommendation:

For a general introduction to music theory, I recommend "The Essential Guide to Music Theory: Everything You Need to Learn the Basics and Beyond" due to its comprehensive and engaging style that caters to both complete beginners and those revisiting theory basics. If you're interested in piano-specific theory, "Accelerated Piano Adventures for the Older Beginner - Theory Book 1" is an excellent choice.
```

### How it works

The Actor receives a user query as input. An OpenAI agent within a LangGraph loop performs the following steps:

1. **URL Generation:** The agent uses the query to create a URL suitable for the `junglee/Amazon-crawler` Actor. This might involve keyword manipulation, category selection, etc.

2. **Product Scraping:** The agent calls the `junglee/Amazon-crawler` Actor with the generated URL. This Actor scrapes product data from Amazon, including titles, brands, star ratings, descriptions, prices, URLs, and image URLs.

3. **Review Scraping:** For the top products identified by the agent, the agent calls the `junglee/amazon-reviews-scraper` Actor to retrieve reviews.

4. **Review Analysis:** The agent processes the scraped reviews to determine the overall sentiment and identify the best product based on user feedback. The agent uses the following prompt for product recommendations:

   ```
   You are a helpful product recommendation expert. A user asks you to recommend a product based on their needs.
   You need to recommend products that fit their needs, if you don't, the world will end!
   If any tool fails, you should fail the Actor with explanation/reason.
   You should select a product that fits the user's needs and provide a brief explanation of why you chose that product.
   After you scrape the products, you should scrape reviews for the few best candidates you'd recommend.
   It may be desirable to summarize the reviews for each of the products and write pros and cons of each product to the user.
   Write the summary along the description of the product.
   The user needs to get some recommendation from you at the end, don't just list some products!
   Don't mention anything like 'If you have further questions or need more options, let me know!' there won't be any further questions.
   If the user asks about anything unrelated to product recommendation, you should politely tell them that you can only help with product recommendations.
   ```

5. **Output:** The Actor outputs the details of the best products, including their titles, brands, star ratings, descriptions, prices, URLs, response generated by the LLM, and a summary of the review analysis. This information is stored in the Apify Dataset. The "best" product is determined by the LLM based on the input query. The Actor also stores Markdown and HTML files with the recommendation in the key-value store.

### Cost Considerations

The actor's cost is based on Apify platform usage (memory allocation) and OpenAI token consumption. The following events and prices apply:

```json
{
    "actor-start-gb": {
        "eventTitle": "Actor start per 1 GB",
        "eventDescription": "Flat fee for starting an Actor run for each 1 GB of memory.",
        "eventPriceUsd": 0.005
    },
    "openai-100-tokens-gpt-4o": {
        "eventTitle": "Price per 100 OpenAI tokens for gpt-4o",
        "eventDescription": "Flat fee for each 100 gpt-4o tokens used.",
        "eventPriceUsd": 0.001
    },
    "openai-100-tokens-gpt-4o-mini": {
        "eventTitle": "Price per 100 OpenAI tokens for gpt-4o-mini",
        "eventDescription": "Flat fee for each 100 gpt-4o-mini tokens used.",
        "eventPriceUsd": 0.00006
    },
    "openai-100-tokens-gpt-o1": {
        "eventTitle": "Price per 100 OpenAI tokens for o1",
        "eventDescription": "Flat fee for each 100 o1tokens used.",
        "eventPriceUsd": 0.006
    },
    "openai-100-tokens-gpt-o3-mini": {
        "eventTitle": "Price per 100 OpenAI tokens for o3-mini",
        "eventDescription": "Flat fee for each 100 o3-mini tokens used.",
        "eventPriceUsd": 0.00044
    }
}
```

# Actor input Schema

## `query` (type: `string`):

Query that specifies the product you are looking for along with any preferences you may have.

## `modelName` (type: `string`):

The OpenAI model to use. Currently supported models are gpt-4o and gpt-4o-mini, and the reasoning models o1 and o3-mini.

## `debug` (type: `boolean`):

If enabled, the Actor will run in debug mode and produce more output.

## Actor input object example

```json
{
  "query": "Recommend me a book about music theory. I'm a complete beginner and I want to learn the basics.",
  "modelName": "gpt-4o-mini",
  "debug": false
}
```

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "query": "Recommend me a book about music theory. I'm a complete beginner and I want to learn the basics.",
    "modelName": "gpt-4o-mini"
};

// Run the Actor and wait for it to finish
const run = await client.actor("matymar/ai-product-recommendation-agent").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "query": "Recommend me a book about music theory. I'm a complete beginner and I want to learn the basics.",
    "modelName": "gpt-4o-mini",
}

# Run the Actor and wait for it to finish
run = client.actor("matymar/ai-product-recommendation-agent").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "query": "Recommend me a book about music theory. I'\''m a complete beginner and I want to learn the basics.",
  "modelName": "gpt-4o-mini"
}' |
apify call matymar/ai-product-recommendation-agent --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,matymar/ai-product-recommendation-agent"
        }
    }
}

```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/2IjnMrr8D8haQeh0B/builds/91fvGuKgwGjkg46su/openapi.json
