Slack Admin Notifications

The most satisfying way to track signups and payments from your first users.

This module sends real-time notifications to Slack for important admin events.

Example Notifications

Slack Integration Code

Configuration

Add the following environment variables to your .env file:

# Enable/disable Slack notifications
SLACK_ENABLED=true
 
# Slack webhook URL (get this from Slack app settings)
SLACK_WEBHOOK_URL=https://hooks.slack.com/services/YOUR/WEBHOOK/URL
 
# Comma-separated list of events to notify (use "*" for all events)
SLACK_EVENTS=user.signup,workspace.member.invited,workspace.member.added,workspace.member.removed,payment.success,payment.failed
# Or enable all events:
# SLACK_EVENTS=*

Available Events

  • user.signup - New user registration via OAuth
  • workspace.member.invited - Member invited to a workspace
  • workspace.member.added - Member accepted invitation and joined workspace
  • workspace.member.removed - Member removed from workspace
  • payment.success - Successful payment (subscription or credit topup)
  • payment.failed - Failed payment attempt

How to Get a Slack Webhook URL

  1. Go to https://api.slack.com/apps
  2. Create a new app or select an existing one
  3. Navigate to "Incoming Webhooks"
  4. Activate Incoming Webhooks
  5. Click "Add New Webhook to Workspace"
  6. Select the channel where notifications should be sent
  7. Copy the webhook URL and add it to your .env file

Example Configuration

For production use (all events enabled):

SLACK_ENABLED=true
SLACK_WEBHOOK_URL=https://hooks.slack.com/services/xxx
SLACK_EVENTS=*

For development (only critical events):

SLACK_ENABLED=true
SLACK_WEBHOOK_URL=https://hooks.slack.com/services/xxx
SLACK_EVENTS=user.signup,payment.success,payment.failed

To disable Slack notifications:

SLACK_ENABLED=false

Architecture

The module consists of:

  • SlackService: Handles HTTP requests to Slack webhook and message formatting
  • SlackNotificationListener: Listens to internal application events using NestJS EventEmitter
  • Event Emitters: Various services emit events that trigger Slack notifications