AI - Privacy - Python - Customer research
4 min lectura

Before AI sees a customer interview: mask contacts and review context

A locally tested Python filter for emails and phone numbers in customer interviews, followed by a manual review for names and indirect clues.

Before AI sees a customer interview: mask contacts and review context

You have ten customer interviews to summarize with an AI assistant. One transcript includes an interviewee's email address, phone number, and shop location. Uploading it unchanged would send those details outside your local workflow. A small Python script can make a reproducible first pass before a human reviews what may be shared. This guide uses fictional data and does not claim to make a transcript anonymous.

First decide what the analysis needs

To find purchase objections, you may only need the customer's industry, the problem, a short quote, and a label such as “Participant 1.” Keep the original in an authorized location and make a separate review copy. If the transcript contains health or financial details, trade secrets, or third-party information, follow your organization's handling rules and consider keeping the analysis local. OWASP lists personal and confidential data among the sensitive information that LLM applications may disclose.

A local first pass you can copy

Save this as redact_interview.py. It uses only Python 3's standard library. re.subn returns both the replaced text and the number of matches. The script refuses to overwrite the input or an existing output file and prints counts without echoing contact details to the terminal.

import argparse
import re
from pathlib import Path

EMAIL = re.compile(r"(?<![\w.+-])[\w.+-]+@[\w.-]+\.[A-Za-z]{2,}(?![\w.-])")
PHONE = re.compile(
    r"(?<!\w)(?:\+?\d{1,3}[\s.-]?)?(?:\(?\d{3}\)?[\s.-]?)\d{3}[\s.-]?\d{4}(?!\w)"
)

def mask(text: str) -> tuple[str, int, int]:
    text, emails = EMAIL.subn("[EMAIL]", text)
    text, phones = PHONE.subn("[PHONE]", text)
    return text, emails, phones

parser = argparse.ArgumentParser()
parser.add_argument("input", type=Path)
parser.add_argument("output", type=Path)
args = parser.parse_args()
if args.input.resolve() == args.output.resolve() or args.output.exists():
    parser.error("choose a new output path")
cleaned, emails, phones = mask(args.input.read_text(encoding="utf-8"))
with args.output.open("x", encoding="utf-8") as file:
    file.write(cleaned)
print(f"Masked {emails} email(s) and {phones} phone(s). Review manually.")

Run python3 redact_interview.py interview.txt interview-review.txt. Avoid calling the result “anonymized” at this stage. It still needs a human check. The working copy used for this story has the same mask function and overwrite guards.

What I actually tested

I ran the script locally against a fictional transcript containing ana@example.com, jo.smith+test@example.co.uk, +1 (787) 555-0199, and 415-555-0100. It reported two emails and two phone numbers. The review copy contained markers in their place, while the original remained intact. I intentionally left “Ana” and “Calle Sol 12” in the example: the script does not recognize them. This verifies those sample formats only. I did not upload the transcript to Gemini, Claude, or ChatGPT as a product test.

The human review you still need

  1. Open only interview-review.txt. Look for names, addresses, small businesses, private URLs, account numbers, amounts, diagnoses, unusual dates, and details that could identify someone indirectly.
  2. Replace each person with a stable label such as “Participant 1.” Generalize details that do not help answer the research question. Check filenames, metadata, and attachments too.
  3. Read it again as someone familiar with the interviewee. If the context still reveals who they are, remove or combine more details.
  4. Check the intended AI service's permissions and retention settings for your account. Turning off model training is not the same as immediate deletion.

The diagram below shows the decision flow: local original, filtered copy, human review, then AI analysis only if sharing is appropriate. If you cannot finish the review or the service's terms do not fit the data, work from aggregated notes instead of the full transcript.

Privacy flow: local original, filtered copy, human review, and sharing decision
Privacy flow: local original, filtered copy, human review, and sharing decision

A prompt that does not request identities

Analyze this customer interview for problems, purchase
objections, and representative quotes. Do not infer or
reconstruct identities. Separate textual evidence from
hypotheses. Return a table with: theme, short quote,
observed frequency, uncertainty, and one follow-up
question for the next interview.

The prompt guides the analysis; it is no substitute for minimizing the data before upload. It also cannot guarantee that a provider will not retain data. Review the service's terms and controls for your account and location. Gemini's help pages, for example, distinguish chat history from use of conversations to improve models.

Where this helps, and where it stops

This process is a first barrier for MVP discovery interviews when you are authorized to process them and need to compare patterns. If counts and aggregated notes answer the question, do not upload the transcript. A regular expression may miss international formats, extensions, numbers written as words, and malformed email addresses; it may also flag a number that is not a phone number. The markers do not remove names or indirect clues. Treat the output as a review draft, never as proof of anonymity.

Sources

Comentarios

Aún no hay comentarios. Sé el primero.

Deja un comentario