Profesor Rafał Wilczur - Architecture
Slack bot using @slack/bolt with Socket Mode. Entry point: src/index.ts
Modular Architecture
1. Mention Features (src/mentionFeatures/)
Triggered by @Profesor Rafał Wilczur mentions. Each feature exports:
question: (optional if use matcher) string[] - trigger keywordsmiddleware: async handlermatcher: (optional) custom pattern matching
Flow: app_mention event → pattern matchers → keyword lookup → default to help
2. Message Features (src/messageFeatures/)
Pattern-based responses using app.message(pattern, middleware)
3. Member Events (src/membersEvents/)
React to member_joined_channel and member_left_channel events
4. Cron Features (src/cronFeatures/)
Scheduled jobs using node-cron. Each feature exports:
schedule: string - cron expression (e.g., '0 9 * * 1-5')handler: async function with app an channel parameters
Flow: App starts → cron jobs scheduled → handlers execute on schedule
Structure
src/
├── index.ts # App init
├── mentionFeatures/ # @mention features
├── messageFeatures/ # Pattern-based features
├── membersEvents/ # User activity handlers
├── cronFeatures/ # Scheduled jobs
└── utils/ # Shared utilities
Adding Features
- Mention: Create in
mentionFeatures/, add to array in index, then updatesrc/mentionFeatures/help.tsto document the new feature - Message: Create in
messageFeatures/, useapp.message() - Event: Create in
membersEvents/, useapp.event() - Cron: Create in
cronFeatures/, add to features array in index
Config (.env)
SLACK_BOT_TOKEN, SLACK_SIGNING_SECRET, SLACK_APP_TOKEN, GROQ_API_KEY, PORT, MAIN_CHANNEL, WEATHER_API_KEY