Slack and Telegram alerts
Send SubHero alerts to Slack or Telegram when a rule you set up reaches its threshold.
Owners/admins can add rules under Webhooks & integrations → Alert channels. Members can read rules and delivery status. Each rule belongs to one project and has a name, kind, threshold, channel and encrypted credentials.
Supported kinds are refund, billing_issue_spike, import_finished and comparison_red. Refunds emit once per matching production event/rule. Billing issues emit per qualifying production event after the preceding hour reaches the configured threshold. Import completion emits once per import-run transition to complete. Comparison digests count the previous UTC day’s red cells, run at 04:30 UTC and emit at most once per rule/day. Enabling a rule does not backfill historical events.
Create a Slack incoming webhook for the intended channel and supply { "webhook_url": "https://hooks.slack.com/services/…/…/…" }. Only Slack’s exact HTTPS webhook host/path is accepted. For Telegram, create a bot through BotFather, add it to the target chat, and supply { "bot_token": "12345:…", "chat_id": "-1001234567890" }; a valid public @channel name is also accepted.
Use PUT /console/projects/:id/alert-rules/new with { "name": "Refund alerts", "kind": "refund", "channel": "slack", "threshold": 1, "enabled": true, "credentials": { … } }. Subsequent PUTs use the returned rule ID. Omit credentials to keep them; supply the complete object when rotating. DELETE removes the rule and its delivery history. GET /console/projects/:id/alert-rules/:id/deliveries returns safe outcomes, never channel credentials.
Slack acknowledgement must be the exact successful ok body; Telegram must return ok: true with a message ID. Failed acknowledgements retry after 1 minute, 10 minutes, 1 hour and 6 hours. Five claimed attempts exhaust the budget even if a worker crashes. Neither API offers a documented receiver idempotency key for these sends: an ambiguous timeout after acceptance may duplicate a message. Messages contain only the rule kind and opaque event/run ID or aggregate red-cell count, not subscriber identities or store proofs.
Create a disposable channel/chat, trigger a synthetic verified production fixture or completed test import, inspect the message and delivery history, then disable the test rule. No real Slack/Telegram credentials were available during implementation; live acceptance is an owner release check.