Overview
The Internal Tickets Knowledge feature allows merchants to use their resolvedlive_supports tickets as a knowledge source for the AI. This document outlines the technical implementation and the privacy safeguards (PII redaction) in place.
Architecture
Data Flow
- Selection: Tickets are selected for embedding either manually (via the Dashboard UI) or automatically (via
auto_embed_ticketssetting). - Sync API: The
POST /api/websites/[id]/knowledge/tickets/syncendpoint is triggered. - Content Processing:
- The system fetches the ticket and its messages (
live_support_messages). - Content is formatted into a transcript (Q&A format).
- PII Redaction is applied to the message content.
- The system fetches the ticket and its messages (
- Embedding: The redacted content is inserted into
pending_chunkswith aticket://URL, triggering the standard embedding worker.
PII Redaction
To protect sensitive customer data, all ticket content passes through a redaction layer before being stored or embedded.Implementation
The redaction logic is located inapps/web/lib/chat/pii-redaction.ts.
What is Redacted?
The system useslib/chat/ticket-redaction.ts to redact the following PII types:
- Credit Cards: 13-19 digits with delimiters.
- Emails: Standard email patterns.
- Phone Numbers: Matches international and domestic formats.
- Personal IDs (SSN): Matches US SSN format (XXX-XX-XXXX).
- Addresses: Heuristic detection of street addresses.
- IP Addresses: IPV4 pattern.
[REDACTED_EMAIL], [REDACTED_PHONE].
System Note:
A system note is appended to the embedded ticket content to instruct the AI on how to handle these redacted fields.
Logic Location
- Utility:
apps/web/lib/chat/ticket-redaction.ts - Tests:
apps/web/lib/chat/ticket-redaction.test.ts
Database Schema
websites.auto_embed_tickets: Boolean flag to enable automatic processing.website_content: Stores the final embedded chunks. Tickets are identified byurlstarting withticket://.
