What You’ll Build
A privacy-preserving AI chatbot that:- Accepts user input with sensitive data
- Detects and tokenizes PII automatically
- Sends protected text to OpenAI
- Restores original data in the response
- Handles errors gracefully
Prerequisites
- Python 3.8+, Node.js 16+, or Java 11+ installed
- OpenAI API key (get one here)
- Blindfold API key (sign up)
Local mode is free forever. All SDKs include local mode with 86 regex-based entity types and all 8 operations — no API key, no signup, no network calls, no data leaves your infrastructure. Just install the SDK and use
Blindfold() with no arguments. You only need the Cloud API below if you want NLP-powered detection (names, addresses, organizations) and compliance policies.Step 1: Install Dependencies
- Python
- JavaScript
- Java
Step 2: Set Up Environment Variables
Create a.env file in your project root:
Step 3: Create the Privacy-Preserving Chatbot
- Python
- JavaScript
Create Run it:
privacy_chatbot.py:Step 4: Understanding the Output
When you run the chatbot, you’ll see:- ✅ PII detected and tokenized
- ✅ OpenAI never saw real names or emails
- ✅ User receives personalized response
- ✅ GDPR compliance maintained
Step 5: Add Different Privacy Methods
Masking (Show Last 4 Digits)
Redaction (Permanent Removal)
Step 6: Production Best Practices
Store Mappings Securely
- Python (Redis)
- JavaScript (Redis)
Handle Errors Gracefully
Use Async for Better Performance
Next Steps
Supported Entities
See all 60+ entity types
Policies
Learn about GDPR, HIPAA, PCI DSS policies
Best Practices
Production deployment tips
Examples
More integration examples
Troubleshooting
”Invalid API key” error
- Check your
.envfile has the correct API key - Verify the API key in your dashboard
- Ensure
load_dotenv()(Python) ordotenv.config()(JavaScript) is called
Entities not detected
- Try lowering the threshold:
score_threshold=0.25 - Use
policy="strict"for maximum detection - Check if text is in a supported language
Performance is slow
- Use async methods for concurrent requests
- Batch multiple tokenize calls together
- Consider caching results for duplicate text
Get Help
Support
Questions? Contact hello@blindfold.dev