The PII Detector is an Elixir application that monitors Slack channels and Notion databases for messages or tickets containing Personally Identifiable Information (PII). When PII is detected, the application removes the content and notifies the author via Slack DM, asking them to recreate it without the sensitive information.
- Slack Integration: Monitors specified Slack channels for messages containing PII
- Notion Integration: Monitors specified Notion databases for tickets containing PII. Please note that the Notion alerts are instantaneous as Slack becuase Notion takes some time to send the webhook.
- PII Detection: Uses pattern matching and AI (OpenAI) to detect PII in text, images, and PDFs. There is no Notion API endpoint to delete a post in a database so auto deletion is not included.
- Automatic Content Removal: Deletes messages/tickets containing PII.
- User Notification: Sends DMs to users with their original content for easy recreation
- Monitoring: Includes telemetry for tracking detection events and performance
- Elixir 1.17.3-otp-27
- Erlang/OTP 27.3.3
- Slack workspace with admin privileges
- Notion workspace with admin privileges
- SLACK_CLIENT_SECRET
- SLACK_SIGNING_SECRET
- SLACK_VERIFICATION_TOKEN
- SLACK_API_TOKEN
- NOTION_API_TOKEN
- CLOUDFLARE_ACCOUNT_ID
- CLOUDFLARE_API_TOKEN
- Create a Slack app at https://api.slack.com/apps
- Add the following OAuth scopes:
channels:history
- To read messageschannels:read
- To identify channelschat:write
- To send DMschat:write.public
- To send messages in channelsfiles:read
- To read file contentusers:read
- To get user informationusers:read.email
- To find users by email
- Install the app to your workspace
- Copy the Bot User OAuth Token to
SLACK_API_TOKEN
- Copy the Signing Secret to
SLACK_SIGNING_SECRET
- Add the app to the channels you want to monitor
- Set up an Event Subscription with the URL:
https://your-app-url.com/slack/events
- Subscribe to the
message.channels
event
- Create an integration at https://www.notion.so/my-integrations
- Copy the Internal Integration Token to
NOTION_API_TOKEN
- Share the databases you want to monitor with the integration
- Copy the database IDs to
NOTION_DATABASE_IDS
I deployed this to Gigalixir because it just makes it very easy and I am used to the platform
- Send a message containing PII (e.g., "My SSN is 123-45-6789") in one of the watched channels
- The message should be deleted and you should receive a DM with your original message
- Send a message without PII - it should remain in the channel
- Create a page in a watched database containing PII
- The page should be deleted and you should receive a Slack DM with the original content
- Create a page without PII - it should remain in the database
The application is built with a modular architecture:
- Slack Integration: Handles Slack events, message processing, and API interactions
- Notion Integration: Handles Notion database monitoring, page processing, and API interactions
- PII Detection: Analyzes content for PII using pattern matching and AI
- Message Handler: Coordinates the flow of content through the system
- Slack messages not being processed: Verify the bot is in the channel and has the correct permissions
- Notion pages not being processed: Verify the integration has access to the database
- PII not being detected: Check the OpenAI API key and ensure the AI service is available
- Application not starting: Check the logs for errors and verify all environment variables are set correctly