Skip to content
reaatechREAATECH

Files · OpenRouter Lead Intake Agent for Small Business

20 (0 binary, 290.7 kB total)attempt 4

README.md·2215 B·markdown
markdown
# OpenRouter Lead Intake Agent for Small Business
 
A Next.js 14 API-based lead intake system for small businesses that accepts lead submissions through a web API, classifies them using an AI agent mesh, stores them for follow-up, and notifies sales reps via SMS.
 
## Architecture
 
The system is built as a Next.js 14 App Router project with a single POST `/api/leads` endpoint. It follows a multi-stage pipeline:
 
1. **Auth** — API key validation via `@reaatech/agent-auth-proxy-core`
2. **Validation** — Zod schema validation for lead data (name, email, phone, message, source)
3. **Classification** — AI-based lead classification via `@reaatech/agent-mesh-gateway` (confidence scoring + intent detection)
4. **Routing** — High-confidence leads get SMS notification + handoff ticket; low-confidence leads are stored for follow-up
5. **Memory** — Lead data stored via `@reaatech/agent-memory` with agent memory extraction
6. **Notification** — Twilio SMS with retry logic for high-priority leads
7. **Handoff** — Agent handoff ticket creation via `@reaatech/agent-handoff`
 
## Quick Start
 
```bash
pnpm install
cp .env.example .env
# Fill in your API keys and credentials
pnpm dev
```
 
### Environment Variables
 
| Variable | Description |
|---|---|
| `API_KEY` | API key for authenticating requests |
| `TWILIO_ACCOUNT_SID` | Twilio account SID |
| `TWILIO_AUTH_TOKEN` | Twilio auth token |
| `TWILIO_PHONE_NUMBER` | Twilio phone number (E.164 format) |
| `OPENAI_API_KEY` | OpenAI API key for agent memory |
| `LOG_LEVEL` | Logging level (default: info) |
 
## API
 
### POST /api/leads
 
**Request Headers:**
- `x-api-key`: Your API key
 
**Request Body:**
```json
{
  "name": "John Doe",
  "email": "john@example.com",
  "phone": "+15551234567",
  "message": "I'm interested in your services",
  "source": "web"
}
```
 
**Source enum:** `web`, `email`, `phone`, `referral`, `other`
 
**Success Response (200):**
```json
{
  "success": true,
  "leadId": "req-abc123",
  "priority": "high",
  "nextSteps": "sms_sent_and_handoff_created"
}
```
 
## Development
 
```bash
pnpm typecheck    # TypeScript type checking
pnpm lint         # ESLint
pnpm test         # Run tests with coverage
```
 
## License
 
MIT