Files · xAI Grok Voice Agent for Jobber Field Service Booking
67 (1 binary, 607.1 kB total)attempt 1
README.md·3045 B·markdown
markdown
# xAI Grok Voice Agent for Jobber Field Service Booking
> Let customers book field service jobs by phone — calls are automatically transcribed, understood by xAI Grok, and dispatched as new jobs in Jobber.
A tutorialized reference solution from [reaatech.com](https://reaatech.com), demonstrating how to build production-grade AI systems with the `@reaatech/*` package family.
## How It Works
1. **Twilio** receives an inbound PSTN call and streams audio via Media Streams WebSocket
2. **Deepgram** transcribes speech to text (STT) in real-time using Nova-2 model
3. **xAI Grok** extracts booking intent and structured job details from the transcribed conversation
4. **Confidence Router** determines whether to route, clarify, or fallback based on confidence thresholds
5. **Jobber API** creates a new field service job when intent is confirmed
6. **ElevenLabs** converts the agent's response to speech (TTS) and streams it back to the caller
## Prerequisites
- [Twilio](https://twilio.com) account — phone number with Voice capability
- [Deepgram](https://deepgram.com) account — API key with STT access
- [ElevenLabs](https://elevenlabs.io) account — API key with TTS access
- [xAI](https://x.ai) account — API key for Grok model access
- [Jobber](https://getjobber.com) account — OAuth client ID and secret
- [Langfuse](https://langfuse.com) account (optional) — observability and tracing
## Environment Variables
| Variable | Description |
|----------|-------------|
| `TWILIO_ACCOUNT_SID` | Twilio account SID |
| `TWILIO_AUTH_TOKEN` | Twilio auth token |
| `DEEPGRAM_API_KEY` | Deepgram STT API key |
| `ELEVENLABS_API_KEY` | ElevenLabs TTS API key |
| `XAI_API_KEY` | xAI Grok API key |
| `JOBBER_CLIENT_ID` | Jobber OAuth client ID |
| `JOBBER_CLIENT_SECRET` | Jobber OAuth client secret |
| `JOBBER_API_BASE_URL` | Jobber API base URL (default: `https://api.getjobber.com/api/v1`) |
| `LANGFUSE_PUBLIC_KEY` | Langfuse public key (optional) |
| `LANGFUSE_SECRET_KEY` | Langfuse secret key (optional) |
| `LANGFUSE_BASE_URL` | Langfuse base URL (optional) |
| `WS_PORT` | WebSocket server port (default: `3001`) |
| `CONFIDENCE_ROUTE_THRESHOLD` | Confidence threshold for routing (default: `0.8`) |
| `CONFIDENCE_FALLBACK_THRESHOLD` | Confidence threshold for fallback (default: `0.3`) |
## Running locally
```bash
pnpm install
pnpm test # vitest run with coverage
pnpm dev # next dev
```
## Project Structure
```
app/ Next.js App Router pages + API routes
api/health/ Health check endpoint
src/ Services, lib, adapters
lib/ Shared libraries (types, Jobber client, router, session, agent)
server/ Express server, WebSocket handler, Jobber glue
api/ Voice webhook route
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).