Notifications Domain
Technical architecture of Slack, Matrix, and Web Push integrations
Overview
The notifications domain manages multi-channel alerts and team communication. It leverages @repo/slack for operational summaries, @repo/matrix for real-time chat and AI interaction, and @repo/notifications for browser-level Web Push.
Slack Integration (@repo/slack)
Slack is the primary channel for operational visibility. We use the Slack Chat SDK (@slack/web-api) with bot tokens stored in the slack_installations table. Bot messages are delivered via chat.postMessage with Block Kit formatting.
Dynamic Routing
Routing is handled by notification-router.ts, which resolves bot tokens from the slack_configs and slack_installations tables based on:
teamId(Required)formType(e.g.,shift_report,incident,preshift)locationId(Optional location-specific override)
Template System
Slack message templates live in packages/slack/templates/ and include:
- Shift reports — summary with location, ratings, and hero mention
- Manager reports — daily operational summary
- Incidents — severity-tagged alerts with status
- Pre-shift briefings — staff goals with roles and POS targets
- Labor variance alerts — multi-location threshold breaches
- Schedule summaries — weekly roster overview
- Anonymous feedback — category-tagged feedback with truncation
All templates enforce Slack's 2900-character section limit and 50-block message limit via truncate() helpers. Long fields are rendered in two-column section.fields blocks for compactness.