Skip to content
reaatechREAATECH

Files · Mistral AI Lead Intake for Housecall Pro Field Service Bookings

83 (1 binary, 578.9 kB total)attempt 1

README.md·1986 B·markdown
markdown
# Mistral AI Lead Intake for Housecall Pro Field Service Bookings
 
> Convert inbound phone calls into structured Housecall Pro job bookings with an AI voice agent, automatically capturing customer details and scheduling.
 
## Architecture
 
Twilio PSTN call → Webhook → Twilio Media Streams (WebSocket) → Deepgram STT → Mistral AI Extraction → Structured Repair → Housecall Pro API
 
## Environment Variables
 
| Variable | Description | Required |
|---|---|---|
| `TWILIO_ACCOUNT_SID` | Twilio account SID | Yes |
| `TWILIO_AUTH_TOKEN` | Twilio auth token | Yes |
| `DEEPGRAM_API_KEY` | Deepgram speech-to-text API key | Yes |
| `ELEVENLABS_API_KEY` | ElevenLabs text-to-speech API key | Yes |
| `MISTRAL_API_KEY` | Mistral AI API key | Yes |
| `HOUSECALL_PRO_CLIENT_ID` | Housecall Pro OAuth2 client ID | Yes |
| `HOUSECALL_PRO_CLIENT_SECRET` | Housecall Pro OAuth2 client secret | Yes |
| `HOUSECALL_PRO_TOKEN_URL` | Housecall Pro OAuth2 token endpoint | Yes |
| `HOUSECALL_PRO_API_BASE_URL` | Housecall Pro API base URL | Yes |
| `MCP_ENDPOINT` | MCP server endpoint | Yes |
| `MCP_API_KEY` | MCP API key | Yes |
| `SESSION_TTL` | Session TTL in seconds | No |
| `BUDGET_LIMIT_PER_CALL` | Budget limit per AI call in USD | No |
 
## Getting Started
 
```bash
pnpm install
cp .env.example .env   # fill in real values
pnpm dev               # starts Next.js dev server
```
 
## API Endpoints
 
- `POST /api/call/incoming` — Twilio voice webhook, returns TwiML with `<Connect><Stream>` for Media Streams
- WebSocket `/api/call/stream` — Twilio Media Streams handler (requires separate `ws` server running alongside Next.js)
- `GET /api/status` — Health check returning `{ status: "ok", timestamp }`
 
## Testing
 
```bash
pnpm test   # vitest run with coverage
```
 
## Deployment
 
All env vars must be set. The WebSocket handler needs a WS server next to Next.js. The `ws` package must be installed separately (already in deps).
 
## License
 
MIT — see [LICENSE](./LICENSE).