Notifications
Multi-channel HITL notification dispatch: Slack, Teams, Discord, Telegram, and webhooks.
Overview
@consensus-tools/notifications handles multi-channel human-in-the-loop notification dispatch. Send approval prompts, timeout warnings, and deadline expiry notices to Slack, Teams, Discord, Telegram, or a generic webhook. Automatically falls back to webhook when targeted delivery fails.
Installation
Quick start
Send an approval prompt
Prompt modes: "yes-no" | "approve-reject-revise" | "acknowledge" | "vote"
API reference
Timeout and deadline notifications
Direct channel adapters
Credentials are resolved from a CredentialProvider (e.g. CredentialManager from @consensus-tools/secrets) or environment variables (SLACK_BOT_TOKEN, CHAT_WEBHOOK_URL).
Format mentions
Exports reference
| Export | Kind | Description |
|---|---|---|
sendHumanApprovalPrompt | Function | (prompt, credentials, chatProvider?) => Promise<PromptResult> |
sendTimeoutWarning | Function | (prompt, remainingSec, credentials, chatProvider?) => Promise<PromptResult> |
sendDeadlineExpired | Function | (prompt, autoDecision, credentials, chatProvider?) => Promise<PromptResult> |
formatMention | Function | (adapter, handle) => string |
sendSlackDM | Function | Direct Slack DM via Bot API |
sendTeamsDM | Function | Direct Teams DM |
sendDiscordDM | Function | Direct Discord DM |
sendTelegramDM | Function | Direct Telegram DM |
sendViaWebhook | Function | Generic webhook POST |
nullCredentials | Object | No-op CredentialProvider for testing (stdout delivery) |
ChatTarget | Type | { subjectId, adapter, handle } |
ChatPrompt | Type | Full prompt config (boardId, runId, quorum, risk, targets, etc.) |
DeliveryResult | Type | Per-target delivery outcome |
PromptResult | Type | Aggregate result with all DeliveryResults |
CredentialProvider | Type | { get(provider, keyName) => string | null } |