E-004: AI Conversation Pipeline

Status: Done Owner: @bilal

What Was Done

LLM Tool-Use Orchestration (ADR-017 Phase 1)

  • process.ts rewritten — Claude tool use replaces keyword state machine
  • Emergency keyword detection kept as safety gate (gas/fire/flood bypass)
  • Removed: hasRichDetail(), prefix detection, buildDetailRequest()
  • System prompt aligned — LLM generates contextual follow-ups via tools
  • Tool handlers: ask_for_details, ask_for_photo, create_issue, respond, escalate
  • gathering_state column on conversations

Identity-First Conversations (ADR-017 Phase 2)

  • identity_status column (UNIDENTIFIED → IDENTIFIED → CONFIRMED → ACTIVE)
  • State transitions in processInboundMessage() — identity gating before LLM tools
  • Channel-specific identity challenge prompts
  • LLM-powered identity extraction + fuzzy tenant matching
  • Property confirmation step (single/multi-property selection)
  • Auto-confirm for OTP-authenticated chat + high-confidence phone matches
  • create_issue gated behind CONFIRMED/ACTIVE identity

Meta WhatsApp Provider

  • Webhook route + provider adapter for Meta WhatsApp API

Document AI Setup (DOC-AI-001, 002)

  • visibleToAI toggle in GraphQL + document modal UI
  • Seed script with house rules + boiler manual (2 docs, 3 chunks, stub embeddings)