@pmcollab/coworkstream-notifications
v0.1.0
Published
Outbound notification adapters for @pmcollab/coworkstream — email, Slack, APNs/FCM. Configurable digest scheduling.
Readme
@pmcollab/coworkstream-notifications
Outbound notifier for @pmcollab/coworkstream-engine events. Slack, email, push, plus a digest buffer.
Install
npm install @pmcollab/coworkstream-notificationsUse
import {
createNotifier, slackChannel, emailChannel, pushChannel, createDigest,
} from '@pmcollab/coworkstream-notifications'
const notify = createNotifier({
channels: [
slackChannel({ webhook: process.env.SLACK_WEBHOOK_URL }),
emailChannel({
send: ({ to, subject, body }) => ses.sendEmail({ to, subject, body }),
}),
],
match: ({ item, event }) => event === 'item.escalate' && item.priority === 'high',
})
engine.on('escalate', (item) => notify({ event: 'item.escalate', item, recipients: ['[email protected]'] }))Channels
| Channel | Wire |
|---|---|
| slackChannel({ webhook }) | Slack incoming webhook URL |
| teamsChannel({ webhook }) | Microsoft Teams incoming webhook URL (Connector or "Workflows in Teams"). Posts an Adaptive Card by default; override with formatCard(args). |
| emailChannel({ send }) | Pass any send({ to, subject, body }) function — SES, SendGrid, Resend, Postmark |
| pushChannel({ dispatch }) | Pass any dispatch({ tokens, title, body }) — APNs, FCM, OneSignal |
Digests
const digest = createDigest({
intervalMs: 5 * 60 * 1000, // 5 min
channel: emailChannel({ send }),
recipients: ['[email protected]'],
})
engine.on('escalate', (item) => digest.add({ event: 'item.escalate', item }))License
Commercial. See LICENSE in the repository root.
