Skip to content
reaatech

Files · Review Response Agent for Independent Restaurants

81 (1 binary, 601.0 kB total)attempt 1

README.md·4369 B·markdown
markdown
# Review Response Agent for Independent Restaurants
 
> Automatically craft consistent, on-brand replies to Yelp, Google, and TripAdvisor reviews.
 
## Problem
 
Restaurant owners and managers spend hours each week manually writing replies to online reviews. Each platform has its own tone expectations, and maintaining a consistent brand voice across all of them is nearly impossible at scale. This recipe solves that.
 
## Solution
 
An AI-powered review response agent that:
 
- Generates personalized, on-brand replies using LLMs
- Stores and recalls brand voice preferences per restaurant
- Applies safety guardrails to prevent inappropriate responses
- Caches responses to reduce costs on repeated review patterns
- Exposes an Agent-to-Agent (A2A) protocol for integration into larger systems
 
## Tech Stack
 
- **Next.js 16+** (App Router with Turbopack)
- **TypeScript** (strict mode)
- **Vercel AI SDK** (`ai@6.0.193`) with `@ai-sdk/openai-compatible`
- **Zod** (`zod@4.4.3`) for runtime validation
- **6 REAA packages** (see below)
 
## REAA Packages
 
| Package | Role |
|---|---|
| `@reaatech/a2a-reference-core` | A2A protocol task and agent card schemas |
| `@reaatech/a2a-reference-client` | A2A client for agent-to-agent communication |
| `@reaatech/agent-memory` | Persistent brand voice memory and retrieval |
| `@reaatech/llm-cache` | Semantic caching of LLM responses |
| `@reaatech/guardrail-chain` | Configurable safety and tone guardrails |
| `@reaatech/a2a-reference-observability` | Structured logging, tracing, and metrics |
 
## Third-Party Packages
 
| Package | Role |
|---|---|
| `ai@6.0.193` | Vercel AI SDK for LLM text generation |
| `@ai-sdk/openai-compatible` | OpenAI-compatible provider for the AI SDK |
| `zod@4.4.3` | Runtime schema validation and type inference |
| `dotenv@17.4.2` | Environment variable loading from `.env` files |
 
## Setup
 
```bash
pnpm install
cp .env.example .env
```
 
Edit `.env` and set your `LLM_ENDPOINT` and `LLM_API_KEY`.
 
```bash
pnpm dev
```
 
The server starts at `http://localhost:3000`.
 
## API Documentation
 
### Health Check
 
```bash
curl http://localhost:3000/api/health
```
 
Response: `{ "status": "ok", "uptime": 123.45, "version": "0.1.0" }`
 
### Brand Voice — Create
 
```bash
curl -X POST http://localhost:3000/api/reviews/brand-voice \
  -H "Content-Type: application/json" \
  -d '{
    "restaurantId": "mario-trattoria",
    "name": "Mario's Trattoria",
    "tone": "grateful",
    "keywords": ["pasta", "family", "authentic"],
    "guidelines": ["Always thank 5-star reviewers", "Offer a return visit to 4-star"],
    "greetingStyle": "Ciao",
    "signatureName": "Chef Mario"
  }'
```
 
### Brand Voice — Retrieve
 
```bash
curl "http://localhost:3000/api/reviews/brand-voice?restaurantId=mario-trattoria"
```
 
### Brand Voice — Delete
 
```bash
curl -X DELETE "http://localhost:3000/api/reviews/brand-voice?restaurantId=mario-trattoria"
```
 
### Generate Review Response
 
```bash
curl -X POST http://localhost:3000/api/reviews/generate \
  -H "Content-Type: application/json" \
  -d '{
    "review": {
      "platform": "yelp",
      "reviewerName": "Jane",
      "rating": 4,
      "body": "Great pasta!",
      "restaurantId": "mario-trattoria"
    },
    "brandVoice": {
      "restaurantId": "mario-trattoria",
      "name": "Mario'\''s Trattoria",
      "tone": "grateful",
      "greetingStyle": "Ciao",
      "signatureName": "Chef Mario",
      "keywords": ["pasta", "family"],
      "guidelines": ["Always thank 5-star reviewers", "Offer a return visit to 4-star"]
    }
  }'
```
 
### A2A Agent Card
 
```bash
curl http://localhost:3000/api/a2a/agent-card
```
 
### A2A Task
 
```bash
curl -X POST http://localhost:3000/api/a2a \
  -H "Content-Type: application/json" \
  -d '{ "task": { "id": "123", "type": "review-response-generation" } }'
```
 
## Brand Voice Setup
 
Define your restaurant's:
 
- **Tone**: `friendly`, `professional`, `apologetic`, `grateful`, or `witty`
- **Greeting style**: How each reply starts (e.g. "Ciao", "Hello", "Hey there")
- **Keywords**: Words that reflect your restaurant's identity
- **Guidelines**: Rules for response generation (e.g. "Always thank 5-star reviewers")
- **Signature name**: How each reply is signed
 
## Running Tests
 
```bash
pnpm test
```
 
Runs the Vitest suite with coverage reporting.
 
## License
 
MIT — see [LICENSE](./LICENSE).