AI Privacy & Security · Daily SEO editorial series #008

How to Remove Sensitive Data Before Sending Text to an AI Assistant

A local-first redaction workflow using Microsoft Presidio, placeholders and human review, with clear limits for names, secrets and regulated data.

TJ Singh
5 min read
Sensitive customer message passing through detection, redaction and human review before an AI prompt
Sensitive customer message passing through detection, redaction and human review before an AI prompt

Quick answer

Customer tickets, logs and business documents can contain names, email addresses, phone numbers, account identifiers, credentials and health or financial details. Before sharing text with a hosted assistant, decide whether the task can be completed with synthetic or minimized data. Remove information that is not needed.

Redaction reduces exposure; it does not make data risk-free

Customer tickets, logs and business documents can contain names, email addresses, phone numbers, account identifiers, credentials and health or financial details. Before sharing text with a hosted assistant, decide whether the task can be completed with synthetic or minimized data. Remove information that is not needed.

Automated recognizers can miss values, misclassify ordinary text and overlook context. A successful redaction pass is not proof that every sensitive value is gone. Follow your organization's rules and applicable contracts or laws; use approved services for regulated workloads.

What Presidio can and cannot do

Presidio is an open-source data protection toolkit maintained by Data Privacy Stack. Its Analyzer detects entities with recognizers; its Anonymizer applies configured operations to those detections. Detection depends on language, recognizers, context and configuration. Custom identifiers and domain-specific secrets need explicit handling.

Presidio does not automatically determine your legal basis, classify every confidential field, or guarantee irreversible anonymization. Treat it as one part of a controlled workflow.

Run a local text pass

The Python packages provide an AnalyzerEngine and AnonymizerEngine. A basic flow analyzes a string for a chosen language and passes results to the anonymizer. Install dependencies from the official project instructions, verify the models and recognizers used, and test with synthetic examples before processing real material.

from presidio_analyzer import AnalyzerEngine
from presidio_anonymizer import AnonymizerEngine

text = "Contact Priya at priya@example.com"
analyzer = AnalyzerEngine()
findings = analyzer.analyze(text=text, language="en")
redactor = AnonymizerEngine()
result = redactor.anonymize(text=text, analyzer_results=findings)
print(result.text)

Add placeholders and a review gate

If the task needs relationships preserved, replace detected values with stable placeholders such as [CUSTOMER_1] and keep any mapping locally under access control. Do not send the mapping with the prompt. Scan the output for common secret formats, review flagged or high-impact material, and test for false negatives using representative synthetic data.

Never send raw passwords, API tokens, private keys or authentication cookies to an assistant simply because a PII detector did not flag them. Use secret scanners and explicit deny patterns for credentials.

A safer prompt workflow

Minimize the input, redact locally, verify the result, send only the necessary excerpt through an approved account, and review the answer before acting on it. Keep retention and logging behavior in mind: local preprocessing does not change what the AI provider may store after you submit the remaining text.

For highly sensitive material, use an approved private deployment or do not submit it. Maintain a record of the recognizer configuration and test cases so updates can be reviewed.

Pick a redaction method that fits the text

Manual removal can work for a short, low-risk excerpt. For repeat work, a local detector can find common patterns and replace them with placeholders. Presidio provides configurable analyzers and anonymizers that you can test and extend. None guarantees every identifier is removed: context, rare combinations and domain-specific fields can still identify someone.

Try a local email and phone redaction demo

This demonstration recognizes common email and phone patterns only. It does not detect every name, account number, credential or contextual identifier. It runs in this browser tab; use fictional text and review results manually.

A local Presidio workflow

  1. Create an isolated Python environment and follow the current official installation guide.
  2. Install Analyzer and Anonymizer components and the required language model.
  3. Test with fictional examples and inspect which recognizers match.
  4. Add custom recognizers for internal IDs, account formats or domain-specific secrets.
  5. Choose replacement behavior deliberately; stable placeholders preserve relationships but may be reversible.
  6. Review the output and run a second secret scan before sharing.

Keep any re-identification map separate, local and access-controlled. Do not send it with the prompt. Passwords, API tokens, private keys and session cookies need explicit secret-scanning rules; general PII recognition is not enough.

Preserve useful context without identities

After review, explain placeholders without restoring identities: “The text uses [CUSTOMER_1] and [ORDER_1] consistently. Analyze the sequence of events, avoid inferring identity, and ask if a missing detail is necessary.” Send only the minimum excerpt. Follow approved-service and retention rules; local preprocessing does not control what a provider stores after submission.

Sensitive customer message passing through detection, redaction and human review before an AI prompt: the article's step-by-step workflow and decision points
Workflow summary: use each measurement as a separate signal and keep its scope visible.

Frequently asked questions

Does Presidio guarantee that all personal data is removed?

No. Detection depends on recognizers, configuration, language and context. Review output and add controls for domain-specific values.

Is redacted text anonymous?

Not necessarily. Context and rare combinations can still identify someone. Treat redaction as risk reduction, not a blanket guarantee of anonymity.

Can I use redaction to send any data to a public AI service?

No. Follow your organization’s approved tools, contracts and data rules. For highly sensitive material, use an approved private system or do not submit it.

Sources and further reading

TJ Singh

Creative technologist and author at PromptStaging, focused on AI developer workflows and practical tools.