Automatically detect and optionally redact personally identifiable information (PII) in user-generated text across posts, comments, and messages.
Automatically locate and classify personally identifiable information (PII) within text content (Posts, Comments, Messages) and optionally redact it before display or export.
PII Detection is available on Max plan and above. It is disabled by default; contact Support to have the feature flag enabled for your network.
Each processed text item (post, comment, or message) that runs through PII Detection counts toward your AI Moderation quota. Large backfills or bulk imports can consume quota quickly—coordinate with Support before running retrospective scans.
Staging / sandbox environments share quota policies; throttle batch operations or segment traffic if you are load‑testing PII detection.
The core schema is augmented with an embedded PII block per detection. (Shown conceptually below — actual shape may be array-based in future revisions.)
Copy
Ask AI
{ "...": "other content fields", "pii": { "category": "string", // e.g. email, phone, name "offset": 123, // UTF-16 / SDK string index start "length": 14, // number of characters in match "confidenceScore": 0.96 // 0..1 model confidence }}
If multiple PII entities are present, SDKs may expose them as a list. Plan for zero, one, or many.
PII data is accessed through helper methods exposed on Post / Comment / Message models. Use redaction helpers to mask selected categories before rendering.
Supported today on Backend API, native Android & iOS SDKs. Web / React Native can consume metadata via API but must implement redaction manually. UIKit has no built‑in toggle yet (see integration section below).
let piiInfo: AmityPII = post.getPIIData()piiInfo.offset // Start indexpiiInfo.length // Length of detected entitypiiInfo.category // Category returned by serverpiiInfo.confidence // 0.0 - 1.0
Redaction Helper
Copy
Ask AI
let post: AmityPost// Mask all categories with '*': Hi Steve -> Hi *****let redactedAll = post.redactedText()// Mask only email entities, use '#'let redactedEmail = post.redactedText(piiCategories: [.email], replaceChar: "#")
Cache (original, redacted) pairs if you offer a moderator reveal toggle.
Below is the model structure (as provided) used within the Android SDK:
Copy
Ask AI
class AmityPII( val offset: Int, // Start index of detected entity val length: Int, // Length of the entity val confidence: Double, // 0.0 - 1.0 confidence score val category: Category // Normalized category type)sealed class Category { object EMAIL : Category() object PHONE_NUMBER : Category() object IP_ADDRESS : Category() object ADDRESS : Category() object PASSPORT_NUMBER : Category() class OTHERS(val value: String) : Category() // For categories not enumerated above}
Categories like Person, PersonType, LicensePlate, SortCode, BankAccountNumber, DriversLicenseNumber, and generic IDs are surfaced via Category.OTHERS(value) when a dedicated constant is not defined. Handle them gracefully (e.g., map OTHERS(“Person”) to a user-friendly label and redaction policy).
Q: Can I force server-side redaction so raw text never leaves?
A: Roadmap item; today redaction is client-driven using provided metadata. Q: What if multiple overlapping detections occur?
A: Use highest-confidence or merge spans before rendering. Q: Do offsets reflect UTF-8 or UTF-16?
A: Follow SDK string index semantics (documented per platform); when in doubt, validate with sample extraction.
Although UIKit does not yet ship a pre-wired PII redaction toggle, you can layer the redacted text helpers into the relevant content rendering components:
Generate the redacted variant via redactedText(...) (choose categories / replacement char).
Assign to the text label / attributed string before layout.
Keep both original and redacted strings in memory if you offer a user role–based toggle (e.g., moderators can reveal originals). Avoid recomputing on every bind to reduce UI churn.
If you cache redacted content, ensure cache keys include the selected category set and replacement character to prevent stale or mismatched redactions.
Next: integrate PII category filters into your moderation console and add unit tests around redaction formatting.