Commit Graph

5 Commits

Author SHA1 Message Date
eacfce6970 feat: POST /api/lead/:id/enrich for on-demand AI summary regen
Adds a new sidecar endpoint that forces regeneration of a lead's
aiSummary + aiSuggestedAction. Triggered by the call-desk Appointment
and Enquiry forms when an agent explicitly edits the caller's name —
the previous summary was built against stale identity and needs to be
refreshed from the corrected record.

Scope:

- src/call-events/lead-enrich.controller.ts (new): POST
  /api/lead/:id/enrich. Fetches the lead fresh via
  findLeadByIdWithToken, runs AiEnrichmentService.enrichLead() with
  recent activities for context, persists the new summary via
  updateLeadWithToken, and optionally invalidates the Redis
  caller-resolution cache for the phone (if provided in the request
  body) so the next incoming call does a fresh platform lookup.

- src/platform/platform-graphql.service.ts:
  - Added findLeadByIdWithToken. Selects staging-aligned field names
    (status/source/lastContacted) rather than the older
    leadStatus/leadSource/lastContactedAt names — otherwise the query
    is rejected by the deployed schema. Includes a fallback query
    shape in case a future platform version exposes `lead(id)`
    directly instead of `leads(filter: ...)`.
  - Fixed updateLeadWithToken response fragment to drop the broken
    `leadStatus` field selection. Every call to this method was
    failing against staging because the fragment asked for a field
    the schema no longer has.

- src/call-events/call-events.module.ts: registered
  LeadEnrichController and imported CallerResolutionModule so the
  new controller can inject CallerResolutionService for Redis cache
  invalidation.

The other field-rename issues in platform-graphql.service.ts
(findLeadByPhone/findLeadByPhoneWithToken/updateLead still select
leadStatus+leadSource and will keep failing against staging) are
deliberately untouched here — separate follow-up hotfix to keep this
commit focused on the enrich flow.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-07 13:53:46 +05:30
cec2526d37 feat: Phase 2 — missed call queue ingestion, auto-assignment, endpoints
- MissedQueueService: polls Ozonetel abandonCalls every 30s, dedup by phone
- Auto-assigns oldest PENDING_CALLBACK call on agent Ready (dispose + state change)
- GET /api/worklist/missed-queue, PATCH /api/worklist/missed-queue/:id/status
- Worklist query updated with callback fields and FIFO ordering
- PlatformGraphqlService.query() made public for server-to-server ops
- forwardRef circular dependency resolution between WorklistModule and OzonetelAgentModule

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-23 09:17:33 +05:30
6f7d408724 feat: add worklist engine with prioritized missed calls, follow-ups, and leads 2026-03-18 11:26:04 +05:30
22ac383107 feat: add call lookup endpoint with lead matching + AI enrichment, token passthrough on platform service 2026-03-18 09:11:15 +05:30
5b35c65e6e feat: add Platform GraphQL client service for lead lookup and CRUD
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-17 09:04:00 +05:30