CRM · AI natural-language customer filter

A prompt box that turns a plain-language audience description into structured customer filters, which are then prepended to whatever filters are already applied.

AreaCRM
Routescrm.users.index · crm.segments.new
Centre modulesai
Staff levelsas per customer list / segment builder
Modelsuser
UI labelai.error
Coverage2 use cases · 1 happy · 5 failure

Known issues (2)

How it works

Only available when auth.center.hasAIUserFilter. The prompt is sent as a query parameter to /api/v4/client_filter, and the JSON returned is reshaped into Filter objects, each resolved to a group filter through userFilters → groupFilterCode → groupFilters. If any filter cannot be matched to a group, the code throws and reports to Sentry. Privacy-conscious by design: the analytics events (AI_FILTER_REQUESTED, AI_FILTER_SUCCEEDED, AI_FILTER_FAILED) deliberately send only the prompt length, filter count and filter types — never the prompt text, because it may contain customer data. Note the prompt is interpolated into the URL without encodeURIComponent, so prompts containing & or # will be truncated.

Use cases

Why someone opens this (2)

  • A marketer describing an audience in words instead of assembling six filter rows by hand.
  • Quickly exploring a population before saving the result as a segment.

Path map

flowchart LR
    F(["AI natural-language customer filter"]):::feat
    F --> H1["Prompt converted to filters"]:::ok
    F -.-> X1["Empty prompt"]:::bad
    F -.-> X2["No usable filter returned"]:::bad
    F -.-> X3["Unmappable filter key"]:::bad
    F -.-> X4["Network failure"]:::bad
    F -.-> X5["Prompt containing URL-special characters"]:::bad
    classDef feat fill:#157068,stroke:#157068,color:#ffffff,font-weight:bold
    classDef ok fill:#e3f1ea,stroke:#0d6b42,color:#0d4a2e
    classDef bad fill:#f7e6e2,stroke:#9a2d1c,color:#6e1f13

Happy paths

Prompt converted to filters

  1. User types e.g. ‘women between 25 and 34 with a valid email in Madrid’.
  2. _fetchClientFilter calls the API and parses the returned filter JSON.
  3. Each entry is mapped to a Filter with its group, operation and values.
  4. onApplyFilter prepends them to the existing filters and AI_FILTER_SUCCEEDED is tracked.

Failure paths

QA checklist

Tick these off while regression-testing this feature. The boxes are plain Markdown, so progress is visible in git diffs.

  • ✅ Prompt converted to filters
  • ⛔ Empty prompt
  • ⛔ No usable filter returned
  • ⛔ Unmappable filter key
  • ⛔ Network failure
  • ⛔ Prompt containing URL-special characters

Implementation


Generated from doc/feature-inventory.json · id crm-ai-filter · commit 276788ca6