Files · Automated review response agent for tire shops
83 (1 binary, 609.3 kB total)attempt 1
README.md·4465 B·markdown
markdown
# Automated Review Response Agent for Tire Shops
> Never leave an angry Google or Yelp review unanswered again with context-aware, on-brand replies.
A tutorialized reference solution from [reaatech.com](https://reaatech.com), demonstrating how to build production-grade AI systems with the `@reaatech/*` package family.
## Problem
After a rough alignment job, a customer posts a one-star review on Google. The shop owner is too busy turning wrenches to reply promptly, and the negative review festers, scaring away potential customers. When they finally do respond, it's rushed and defensive, making things worse. The shop's online reputation is fragile; a few unanswered complaints can tank their rating.
This solution gives tire shop owners an automated review response agent that generates empathetic, accurate responses referencing the actual work order — without sounding robotic. It ingests reviews via a Hono API, retrieves work-order context from memory, routes through guardrails and an LLM router, and presents generated responses for approval in a Next.js dashboard.
## Setup
```bash
cp .env.example .env
```
Then fill in the following environment variables in `.env`:
- `LLM_API_KEY` — Your LLM provider API key
- `LLM_BASE_URL` — Base URL for the LLM API (default: `https://api.openai.com/v1`)
- `LLM_MODEL` — Model ID to use
- `LANGFUSE_PUBLIC_KEY` — Langfuse project public key
- `LANGFUSE_SECRET_KEY` — Langfuse project secret key
## Architecture
This recipe wires six `@reaatech/*` packages into a Next.js + Hono stack:
| Package | Role |
|---------|------|
| `@reaatech/agent-memory-core` | Memory data model — `Memory`, enums (`MemoryType`, `MemoryImportance`, `MemorySource`, `MemoryLifecycle`), similarity helpers |
| `@reaatech/agent-memory-retrieval` | Semantic + recency retrieval — `MemoryRetriever`, `ContextInjector`, `RetrievalStrategy` |
| `@reaatech/llm-router-core` | Routing types and Zod validation — `ModelDefinitionSchema`, `RoutingRequestSchema`, `RoutingDecision` |
| `@reaatech/llm-router-strategies` | Cost and capability routing — `CostOptimizedStrategy`, `CapabilityBasedStrategy`, `StrategyOrchestrator` |
| `@reaatech/guardrail-chain` | Guardrail pipeline orchestration — `ChainBuilder`, `ChainResult` |
| `@reaatech/guardrail-chain-guardrails` | Built-in guardrails — `PIIRedaction`, `PromptInjection`, `ToxicityFilter`, `TopicBoundary`, `SentimentAnalysis` |
## How it works
1. **Ingest** — Review arrives via Hono API (`POST /api/reviews`)
2. **Retrieve** — Work-order context is looked up from memory
3. **Guard (input)** — Input passes through PII redaction, prompt injection detection, and topic boundary checks
4. **Route** — LLM router selects the best model by capability and cost
5. **Generate** — AI composes an empathetic, on-brand response referencing the specific work order
6. **Guard (output)** — Generated response passes toxicity and sentiment checks
7. **Store** — Review + response pair is stored in memory for future context
8. **Approve** — Shop owner reviews and approves the response in the dashboard
## Running locally
```bash
pnpm install
pnpm typecheck # TypeScript type checking
pnpm test # vitest run with coverage
pnpm dev # next dev
```
## API reference
| Method | Endpoint | Description |
|--------|----------|-------------|
| POST | `/api/reviews` | Create a new review |
| GET | `/api/reviews` | List reviews with filtering |
| POST | `/api/responses/generate` | Generate a response for a review |
| POST | `/api/responses/approve` | Approve a generated response |
| GET | `/api/health` | Health check |
## Tech stack
- **Framework:** Next.js 16 (App Router)
- **API layer:** Hono
- **Schema validation:** Zod
- **Observability:** Langfuse
- **LLM provider:** Agnostic (OpenAI SDK with configurable base URL)
- **Test runner:** Vitest with coverage
## Project layout
```
app/ Next.js App Router pages + API routes
src/
adapters/ In-memory store and embedder adapters
api/ Hono route handlers
lib/ Memory, LLM router, guardrails, LLM client, observability
services/ Review response orchestration
tests/ vitest suite (mirrors src/)
packages/ API references for every dependency (read these first)
DEV_PLAN.md build plan for this recipe
```
## License
MIT — see [LICENSE](./LICENSE).