Skip to content
reaatech

Files · Auto-repair call intake agent for service advisors

77 (1 binary, 624.4 kB total)attempt 2

README.md·2683 B·markdown
markdown
# Auto-repair call intake agent for service advisors
 
> Automate inbound 'how much to fix X' calls so advisors stay in the bay.
 
A tutorialized reference solution from [reaatech.com](https://reaatech.com), demonstrating how to build production-grade AI systems with the `@reaatech/*` package family.
 
## Architecture
 
The system is composed of three main layers:
 
- **Next.js status dashboard** — App Router pages exposing system health, active
  call counts, and uptime. Serves as the operator-facing UI.
- **Fastify WebSocket server** — Runs alongside the dashboard as a custom server
  (`src/server.ts`). Handles WebSocket connections from Twilio's `<Stream>`
  verb, routes bidirectional audio through the voice pipeline.
- **Twilio telephony handshake** — Twilio's telephony API initiates an HTTP
  request to `/twilio/incoming-call` which responds with TwiML containing a
  `<Connect><Stream>` directive. The browser-side WebSocket (in Twilio's media
  servers) streams audio to the Fastify server for processing.
 
## Prerequisites
 
The following accounts and credentials are required:
 
- **Twilio** — phone number with voice capabilities, Account SID, Auth Token
- **Deepgram** — API key for speech-to-text
- **ElevenLabs** — API key for text-to-speech
- **OpenAI** — API key for LLM-based repair assessment
- **Langfuse** — API host + public/secret keys for observability tracing
 
## Running locally
 
```bash
pnpm install
pnpm test            # vitest run with coverage
pnpm dev             # next dev
```
 
## Project layout
 
```
app/                  Next.js App Router pages + API routes
src/
  config.ts           environment / app configuration
  types.ts            shared TypeScript types
  instrumentation.ts  OpenTelemetry / Langfuse init
  index.ts            public API barrel
  server.ts           Fastify + WebSocket server bootstrap
  stt/
    stt-adapter.ts    Deepgram speech-to-text adapter
  tts/
    tts-adapter.ts    ElevenLabs text-to-speech adapter
  telephony/
    twilio-handler.ts Twilio stream connection manager
  pipeline/
    voice-pipeline.ts orchestrates STT → LLM → TTS flow
  handoff/
    escalation-router.ts  human-agent escalation logic
  session/
    session-store.ts  in-memory call session tracking
  observability/
    telemetry.ts      Langfuse tracing and observability
  lib/
    pricing-db.ts     pricing lookup data / logic
  llm/
    repair-advisor.ts OpenAI-based repair assessment
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).