How shawnsomething/slack-chat-blocker works
Project type and purpose
• This is a Slack‐integration service (Slack “app”) written in Node.js/TypeScript.
• Its core purpose is to intercept or respond to outgoing Slack messages and prevent (“block”) potentially offensive content.
File structure
• Top level
• package.json / package-lock.json: Node.js dependencies and scripts
• tsconfig.json: TypeScript compiler settings
• README.md: project description
• build/
• index.js: compiled entry point for the message‐processing server
• slackOauth.js: compiled OAuth handler
• src/
• index.ts: source entry point—registers Slack event handlers, starts HTTP server or listener
• slackOauth.ts: source handling of OAuth handshake, token storage
• No database directory: likely uses environment variables or in‐memory storage for tokens (can extend with a key‐value store)
README for additional insights
• Very concise: “a slack chat blocker that stops you from sending messages that would offend office Karens.”
• Implies core flow: user installs the app (OAuth) → user sends/slack event occurs → text is scanned → offensive messages are blocked or an alert is sent.
Main components and their interactions
a. Slack Workspace & Clients
– End users and their Slack clients
b. Slack API / Events API
– Delivers message events to your service
– OAuth endpoints for installation
c. OAuth Module (slackOauth.ts)
– Handles “Add to Slack” OAuth flow
– Stores access tokens (in memory or external store)
d. Message Processor (index.ts)
– HTTP listener or event‐pipe for incoming Slack events
– Invokes filter logic
e. Filter Logic
– Text scanning engine (could be a simple keyword list, regex, or external NLP service)
– Decides “safe” vs. “offensive”
f. Slack API Client
– Deletes or modifies offending messages, posts ephemeral warning messages
g. (Optional) Storage / Logging
– Persist blocked message metadata, user metrics, audit logs
Relationships & data flow
1. User installs app ⇒ Slack OAuth server ⇒ Your OAuth endpoint ⇒ Store tokens
2. User sends message in channel ⇒ Slack Events API ⇒ Your message‐handler endpoint
3. Message Processor parses JSON ⇒ passes text to Filter Logic
4. Filter Logic decision:
• Safe ⇒ do nothing
• Offensive ⇒ call Slack API (delete or warn)
5. (Optional) Log event to storage or console
Architectural patterns & design principles
• Integration (webhook/event driven)
• Single responsibility modules: OAuth vs. message processing vs. filtering
• Use environment variables or secrets manager for tokens
• Can evolve into microservices: e.g., extract filter engine into separate service
Technologies & frameworks
• Node.js runtime
• TypeScript for type safety
• Express (or built‐in HTTP) for endpoints
• @slack/web-api and @slack/events-api SDKs
• npm scripts for build (tsc → build/)
• Deployment target: AWS Lambda / Heroku / any HTTP‐accessible host