Files · Vertex AI Lead Intake for Jobber Field Service Booking
77 (1 binary, 669.3 kB total)attempt 2
README.md·2726 B·markdown
markdown
# Vertex AI Lead Intake for Jobber Field Service Booking
AI-powered 24/7 phone lead capture that qualifies callers and books new jobs directly in Jobber, even after business hours.
## Problem
Home service businesses miss after-hours calls and struggle to convert leads efficiently, as manual booking from voicemails and web forms causes double-booking and lost opportunities.
## Architecture
Twilio webhook → Next.js API → voice-agent-core Pipeline (STT → Vertex AI LLM → TTS) → session-continuity → confidence-router {ROUTE | CLARIFY | FALLBACK} → Jobber API
### Flow
1. **Inbound Call**: Twilio sends a webhook to `/api/calls/inbound`
2. **Voice Pipeline**: The handler returns TwiML with `<Connect><Stream>` pointing to a LiveKit media server
3. **Session Management**: `@reaatech/session-continuity` manages conversation state
4. **Lead Classification**: After the call, `@reaatech/confidence-router` classifies the lead type and confidence
5. **Routing**:
- **ROUTE** (high confidence): Creates a client and job request via Jobber REST API
- **CLARIFY** (medium confidence): Flags for human review
- **FALLBACK** (low confidence): Initiates handoff to a live dispatcher via `@reaatech/agent-handoff`
6. **Cost Tracking**: `@reaatech/llm-cost-telemetry` tracks Vertex AI spend
7. **Nightly Eval**: `@reaatech/agent-eval-harness-gate` runs regression tests on the intake flow
## Lead Types
- `new_installation` - Installing new equipment
- `repair` - Fixing broken equipment
- `estimate` - Requesting a price quote
- `follow_up` - Checking on existing request status
## Setup
### Environment Variables
Copy `.env.example` to `.env` and fill in the values:
- **Twilio**: `TWILIO_ACCOUNT_SID`, `TWILIO_AUTH_TOKEN`, `TWILIO_PHONE_NUMBER`
- **Google Cloud**: `GOOGLE_CLOUD_PROJECT`, `GOOGLE_CLOUD_LOCATION`, `GOOGLE_APPLICATION_CREDENTIALS`
- **Jobber**: `JOBBER_API_URL`, `JOBBER_CLIENT_ID`, `JOBBER_CLIENT_SECRET`
- **LiveKit**: `LIVEKIT_API_KEY`, `LIVEKIT_API_SECRET`, `LIVEKIT_URL`
- **Langfuse**: `LANGKFUSE_PUBLIC_KEY`, `LANGKFUSE_SECRET_KEY`, `LANGKFUSE_HOST`
### Twilio Configuration
Configure your Twilio phone number's voice webhook to point at:
```
https://your-domain.com/api/calls/inbound
```
And the status callback to:
```
https://your-domain.com/api/calls/status
```
## API Endpoints
| Method | Path | Description |
|--------|------|-------------|
| POST | `/api/calls/inbound` | Twilio voice webhook for incoming calls |
| POST | `/api/calls/status` | Twilio status callback |
## Development
```bash
pnpm dev # Start development server
pnpm typecheck # Type-check source code
pnpm lint # Lint source code
pnpm test # Run tests with coverage
```