contact-filter

Implements and maintains the shared contact filter system across ChatbotX frontend and backend.

722|195|Updated Dec 9, 2024
One-click install
npx skills add https://github.com/ChatbotXIO/ChatbotX --skill contact-filter
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: contact-filter
Source: https://github.com/ChatbotXIO/ChatbotX/tree/main/.agents/skills/contact-filter
Command: npx skills add https://github.com/ChatbotXIO/ChatbotX --skill contact-filter

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

The ChatbotX contact filter model is shared across the contacts list, conversations, and broadcast audiences, and a single change touches Zod schemas, UI configs, and SQL query builders in two packages. This Skill guides you through adding filter fields or operators without breaking the critical invariants that keep results correct.

Core Features & Use Cases

  • Add filter fields safely: Follow the exact sequence from the contactFilterFields enum through CONTACT_FILTER_FIELD_DEFINITIONS to the buildConditionWhere SQL case.
  • Keep operator rules in sync: Update both STATIC_OPERATOR_RULES (Zod validation) and staticFieldRules (UI enablement) so the UI never offers an operator the backend rejects.
  • Preserve NULL/negation logic: Implement negative and is-empty operators that correctly match NULL rows using three-valued SQL logic and EXISTS subqueries.
  • Use Case: You need to add a new "subscription tier" filter for broadcast audiences. The Skill walks you through the enum, definition entry, both operator-rule sources, the SQL case with NULL handling, and the test checklist.

Quick Start

Ask the assistant to add a new contact filter field to the ChatbotX contact filter system following the documented checklist.

Frequently Asked Questions about contact-filter

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add a new contact filter field in ChatbotX?

Add the field key to the contactFilterFields enum, add an entry to CONTACT_FILTER_FIELD_DEFINITIONS with a schemaKind and optionSource, update operator rules in both STATIC_OPERATOR_RULES and staticFieldRules, then implement a buildConditionWhere case in the backend query builder.

Why does my new contact filter silently return no filtering?

The filter no-ops when the field is defined but has no case in buildConditionWhere, because the default branch returns an empty condition. Implement the SQL case in packages/database/src/queries/contact-filter.ts to fix it.

How do negative filter operators handle NULL values in SQL?

Negative and is-empty operators must also match rows where the value is NULL, since SQL NOT (x = y) drops NULLs. The system wraps negation operators in an OR with an isNull check and uses NOT EXISTS for relation fields.

Does the contact filter support nested condition groups like (A OR B) AND C?

No, the filter schema is flat with a single top-level operator of and or or. Nested groups are not supported, so cross-cutting constraints like the broadcast 24-hour window are enforced in the backend query instead.

How do I hide filter fields for specific contexts like broadcasts?

Pass excludeFields to ContactFilter, ContactFilterDialog, or ContactListFilterPanel. It removes the field from the add-condition list and prunes existing conditions referencing it via pruneExcludedConditions.