Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions kits/review-analyzer/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
REVIEW_ANALYZER_FLOW_ID = "YOUR_FLOW_ID"
LAMATIC_API_URL = "YOUR_LAMATIC_API_URL"
LAMATIC_PROJECT_ID = "YOUR_LAMATIC_PROJECT_ID"
LAMATIC_API_KEY = "YOUR_LAMATIC_API_KEY"
94 changes: 94 additions & 0 deletions kits/review-analyzer/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
# Review Analyzer Kit

An AI-powered Chrome Extension that scrapes product reviews from e-commerce sites (like Amazon) and uses [Lamatic.ai](https://lamatic.ai) to synthesize customer consensus, extract key pros/cons, and calculate a Trust Score to identify fake or low-effort reviews.

## 🚀 Overview
Review Analyzer is built with Next.js and Tailwind CSS, communicating with a Lamatic AI flow backend. By loading the Chrome Extension, users can trigger review scraping with a single click. The scraped data is securely passed to a Next.js server, which runs the reasoning agent workflow on Lamatic AI to generate the summary dashboard.

### 🎯 The Problem (AgentKit Challenge)
Online shoppers are overwhelmed by hundreds of reviews per product, many of which are fake, low-effort, or artificially inflated. It takes too much time to read through them to find the true consensus, pros, and cons.

### 💡 The Value & Solution
This extension solves the problem by providing a simple, one-click solution. It scrapes the reviews and uses a Lamatic AI agent to:
- Save time by summarizing the overall sentiment.
- Extract a clean list of the top Pros and Cons.
- Calculate a **Trust Score (0-100)** to identify suspicious, fake, or duplicate reviews.
This makes e-commerce research faster, safer, and entirely automated.

## 🛠️ Folder Structure
```
kits/review-analyzer/
├── lamatic.config.ts # Metadata definition
├── config.json # Legacy config to pass CI validation
├── agent.md # Agent capability & setup document
├── README.md # This guide
├── constitutions/
│ └── default.md # LLM behavior guide
├── flows/
│ └── review-analyzer.ts # Flow config exported from Lamatic Studio
└── apps/ # Next.js web application & Chrome Extension
├── package.json # Next.js dependencies
├── app/ # Next.js page router (iframe popup view)
├── lib/ # Library files (lamatic client)
├── actions/ # Server Actions calling Lamatic flow
└── extension/ # Chrome Extension (manifest, scripts, popup iframe)
```

---

## 🔑 Setup & Installation

### Step 1: Clone the Repo & Install Dependencies
First, clone your fork and install Next.js dependencies:
```bash
cd kits/review-analyzer/apps
npm install
```

### Step 2: Set up Environment Variables
Create a `.env.local` file inside the `apps` directory with the following keys:
```bash
# Lamatic Flow ID
REVIEW_ANALYZER_FLOW_ID="your-flow-id"

# Lamatic Credentials (Get from Settings in Lamatic Studio)
LAMATIC_API_URL="https://studio.lamatic.ai/api/your-project-url"
LAMATIC_PROJECT_ID="your-project-id"
LAMATIC_API_KEY="your-api-key"
```

### Step 3: Run the Next.js App
Start the Next.js server locally to act as the backend API bridge for the Chrome Extension:
```bash
npm run dev
```
The Next.js dashboard will be running at `http://localhost:3000`.

### Step 4: Install the Chrome Extension
1. Open Google Chrome and navigate to `chrome://extensions/`.
2. Enable **Developer mode** using the toggle switch in the top-right corner.
3. Click the **Load unpacked** button in the top-left corner.
4. Select the `kits/review-analyzer/apps/extension` folder from your local directory.
5. The extension is now active in your browser.

---

## 🧠 Lamatic Flow Workflow Setup

In the [Lamatic Cloud Studio](https://studio.lamatic.ai):
1. Create a new flow named `review-analyzer`.
2. **Define the Input**: Set the trigger to API (GraphQL). The input schema should take an array of strings (e.g. `reviews: [String]`).
3. **Add LLM Node**: Use Claude 3.5 Sonnet or GPT-4o. Set the system prompt to analyze the reviews, compile a consensus summary, isolate key pros & cons, and detect suspicious patterns (such as exact text duplication, excessively short phrasing, or repetitive reviews) to assign a **Trust Score (0 to 100)**.
4. **Define the Output**: Map the output to a GraphQL schema returning the following fields:
- `summary`: string
- `pros`: string[]
- `cons`: string[]
- `trustScore`: int
- `trustLabel`: string
- `analysisDetail`: string
5. **Deploy**: Deploy the flow to retrieve your Flow ID and Project details, and populate `.env.local`.

---

## 🤝 Contributing
Feel free to open issues or PRs! To submit your changes to the AgentKit repo, ensure your PR is labeled with `agentkit-challenge`.
58 changes: 58 additions & 0 deletions kits/review-analyzer/agent.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Agent Identity: Review Analyzer

## Overview
Review Analyzer is an AI-powered assistant designed to help e-commerce shoppers make informed decisions instantly. By scraping and analyzing hundreds of reviews from product pages, it delivers a clear consensus, highlights critical pros & cons, and calculates a Trust Score to identify fake or sponsored comments.

## Purpose
The sheer volume of reviews on sites like Amazon makes it impossible for shoppers to read everything, and many reviews are generated by bots, incentivized programs, or contains low-effort filler. Review Analyzer:
- **Saves Time**: Aggregates and synthesizes hundreds of reviews into a few readable sentences.
- **Exposes Hidden Flaws**: Isolates negative feedback that might be buried under five-star ratings.
- **Protects from Fraud**: Audits reviews for bot-like phrasing, repetitive patterns, or sponsored templates to score review trust.

## Flows

### 1. `review-analyzer` Flow
This is the primary flow triggered by the Chrome Extension. It takes scraped reviews, processes them using a large language model (Claude 3.5 Sonnet or GPT-4o) through Lamatic AI, and returns a structured analysis.

- **Trigger**: API Trigger (GraphQL execution).
- **Processing**:
- Summarizes the overall customer sentiment and consensus.
- Extracts lists of distinct Pros and Cons.
- Examines individual review properties (length, repetitive words, generic bot-like phrasing) to calculate an aggregate Trust Score.
- **Output**: JSON payload returning:
- `summary`: The general consensus summary.
- `pros`: A list of product benefits.
- `cons`: A list of product drawbacks or complaints.
- `trustScore`: Score from 0 to 100 indicating review reliability.
- `trustLabel`: Sentiment classification of trust (e.g. "Highly Trusted", "Needs Review", "Unreliable").
- `analysisDetail`: Explanation of why the trust score was assigned.

## Guardrails
- **Input Limit**: The flow handles a maximum of 50 reviews per call to optimize response time and LLM token limits.
- **Content Security**: Content is filtered to strip HTML tags and scripts before LLM processing to prevent prompt injection.
- **Language Boundaries**: If reviews are in languages other than English, the LLM will automatically translate the summary and pros/cons into English while processing.

## Environment Setup
The Next.js bridge app requires the following environment variables:

| Variable Name | Description | Source |
|---|---|---|
| `REVIEW_ANALYZER_FLOW_ID` | Flow ID of the deployed Lamatic flow | Lamatic Studio Flow page |
| `LAMATIC_API_URL` | Endpoint URL for the Lamatic project | Lamatic Studio API Settings |
| `LAMATIC_PROJECT_ID` | Project ID in Lamatic | Lamatic Studio Settings |
| `LAMATIC_API_KEY` | Secret API key for authentication | Lamatic Studio API Settings |

## Quickstart
1. Set up the environment variables in `apps/.env.local`.
2. Deploy your workflow in the Lamatic AI Studio and export it to `flows/review-analyzer.ts`.
3. Run `npm install` and `npm run dev` in the `apps/` directory.
4. Load the Chrome Extension folder `apps/extension` into your Chrome browser via `chrome://extensions`.
5. Visit any Amazon or e-commerce product page, click the extension icon, and view the analysis.

## Common Failure Modes

| Symptom | Cause | Resolution |
|---|---|---|
| Trust Score is always 100 | LLM prompt failed to detect patterns or reviews are too sparse | Ensure the scraped reviews are correctly parsed and passed. Add more diverse reviews to the page. |
| Extension popup shows connection error | Next.js server is not running or env variables are incorrect | Ensure Next.js is running at the configured URL (`http://localhost:3000`) and the API credentials are valid. |
| Scraper yields empty results | Target site updated their DOM/classnames | Update the selectors in `content.js` to match the new review container class names on the target e-commerce site. |
4 changes: 4 additions & 0 deletions kits/review-analyzer/apps/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
REVIEW_ANALYZER_FLOW_ID = "YOUR_FLOW_ID"
LAMATIC_API_URL = "YOUR_LAMATIC_API_URL"
LAMATIC_PROJECT_ID = "YOUR_LAMATIC_PROJECT_ID"
LAMATIC_API_KEY = "YOUR_LAMATIC_API_KEY"
29 changes: 29 additions & 0 deletions kits/review-analyzer/apps/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules

# next.js
/.next/
/out/

# production
/build

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.pnpm-debug.log*

# env files
.env
.env.local
.env.*.local

# vercel
.vercel

# typescript
*.tsbuildinfo
next-env.d.ts
1 change: 1 addition & 0 deletions kits/review-analyzer/apps/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
legacy-peer-deps=true
155 changes: 155 additions & 0 deletions kits/review-analyzer/apps/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
# Reddit Scout by Lamatic.ai

<p align="center">
<a href="https://reddit-scout-tawny.vercel.app/" target="_blank">
<img src="https://img.shields.io/badge/Live%20Demo-black?style=for-the-badge" alt="Live Demo" />
</a>
</p>

**Reddit Scout** is an AI-powered product review research tool built with [Lamatic.ai](https://lamatic.ai). It searches Reddit for real user opinions and generates structured, scannable review summaries for any product or topic.

[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https://github.com/Lamatic/AgentKit&root-directory=kits/agentic/reddit-scout&env=REDDIT_SCOUT_FLOW_ID,LAMATIC_API_URL,LAMATIC_PROJECT_ID,LAMATIC_API_KEY&envDescription=Your%20Lamatic%20Reddit%20Scout%20keys%20are%20required.)

---

## The Problem

When researching a product before buying, the most honest opinions live on Reddit — not in influencer reviews or star ratings. But finding and reading through dozens of Reddit threads is time-consuming. People manually Google "site:reddit.com [product] reviews", open 10 tabs, read hundreds of comments, and try to mentally synthesize what the consensus is. This takes 15-20 minutes per product and is hard to do consistently.

**Nobody has built a focused tool that automates this specific workflow.**

## The Approach

Reddit Scout is a single-purpose tool: type a product name, get a structured review summary from Reddit.

**How it works:**

1. User enters a product or topic (e.g., "HP Victus", "Sony WH-1000XM5")
2. An LLM generates Reddit-scoped search queries
3. Google Serper API finds the most relevant Reddit threads
4. Serper's scrape endpoint extracts full thread content (posts + comments)
5. A second LLM analyzes all content and produces a structured summary

**Tech stack:**
- **Lamatic AI** — orchestrates the entire flow (search, scrape, analyze)
- **Google Serper API** — Reddit-scoped web search and thread scraping
- **Next.js** — clean, fast frontend
- **ReactMarkdown** — renders AI output as formatted markdown

## The Result

A clean, single-page app where users type a product name and get a structured review in seconds:

- **Overall Sentiment** — positive/negative split at a glance
- **What Users Love** — key pros from real users
- **Common Complaints** — honest downsides
- **Notable User Quotes** — direct quotes with context
- **Frequently Discussed Features** — what keeps coming up
- **Final Verdict** — direct recommendation

**Live demo:** [reddit-scout-tawny.vercel.app](https://reddit-scout-tawny.vercel.app/)

## Tradeoffs & Assumptions

- **Scrape vs. full crawl:** We use Serper's scrape endpoint (single-page) instead of Firecrawl (which doesn't support Reddit). This means we get thread content but not all nested comments — we capture the most relevant discussion.
- **10 threads per search:** We scrape the top 10 Reddit results. This balances speed (~20s) with coverage. More threads would mean longer wait times.
- **No caching:** Every search hits the API fresh. Adding a cache layer would reduce costs for repeated queries but wasn't needed for this scope.
- **Single product search:** No comparison mode (e.g., "X vs Y") — keeping the scope narrow and the output clean.

---

## Lamatic Setup

Before running this project, you must build and deploy the flow in Lamatic, then wire its config into this codebase.

**Pre: Build in Lamatic**
1. Sign in or sign up at https://lamatic.ai
2. Create a project
3. Click "+ New Flow" and select "Flow"
4. Build the Reddit Scout flow:
- Trigger Node (GraphQL) with input `{ "query": "string" }`
- LLM Node: Generate Reddit search query
- Web Search Node (Serper): Search Google scoped to Reddit
- Code Node: Extract URLs from search results
- Batch Node: Iterate over URLs
- Web Search Node (Serper Scrape): Scrape each Reddit thread
- Code Node: Extract all scraped text
- LLM Node: Analyze and generate structured review summary
- Response Node: Return with output mapping `{ "answer": "{{LLMNode.output.generatedResponse}}" }`
5. Configure providers and API credentials (Serper API key)
6. Deploy the flow in Lamatic and obtain your .env keys

**Post: Wire into this repo**
1. Create a `.env` file and set the keys
2. Install and run locally:
- `npm install`
- `npm run dev`
3. Deploy (Vercel recommended):
- Import your repo, set the project's Root Directory to `kits/agentic/reddit-scout`
- Add env vars in Vercel (same as your `.env`)
- Deploy and test your live URL

---

## Key Features
- Searches Reddit for product reviews using Google Serper API
- Scrapes full Reddit thread content via Serper scrape endpoint
- AI-generated structured review summaries with sentiment analysis
- Pros/cons extraction and notable user quotes
- Clean markdown rendering of results

---

## Required Keys and Config

| Item | Purpose | Where to Get It |
|------|---------|-----------------|
| Lamatic API Key | Authentication for Lamatic AI APIs | [lamatic.ai](https://lamatic.ai) |
| Serper API Key | Google Search API for Reddit search | [serper.dev](https://serper.dev) |

### 1. Environment Variables

Create `.env.local` with:

```bash
REDDIT_SCOUT_FLOW_ID = "YOUR_FLOW_ID"
LAMATIC_API_URL = "YOUR_API_ENDPOINT"
LAMATIC_PROJECT_ID = "YOUR_PROJECT_ID"
LAMATIC_API_KEY = "YOUR_API_KEY"
```

### 2. Install & Run

```bash
npm install
npm run dev
# Open http://localhost:3000
```

---

## Repo Structure

```
/actions
└── orchestrate.ts # Lamatic workflow orchestration
/app
└── page.tsx # Main search form UI
/components
├── header.tsx # Header component
└── ui # shadcn/ui components
/lib
└── lamatic-client.ts # Lamatic SDK client
/public
└── lamatic-logo.png # Lamatic branding
/flows
└── reddit-scout/ # Exported Lamatic flow
/package.json # Dependencies & scripts
```

---

## License

MIT License

Loading
Loading