Slack
Requirements
- A Slack workspace where you have permissions to install apps
- Create a Slack app in your workspace
- Install the app to your workspace
Please refer to Dashboard -> Settings -> Slack Integration
for the step-by-step instructions.
You can use different Slack apps for different environments (development, staging, production) to keep your notifications organized.
Important Features
- Direct messages to users
- Channel messages
- Rich message formatting with blocks and attachments
- Interactive components (buttons, dropdowns)
- Thread replies
- Message updates and deletions
- User mention support
- Custom message formatting using Slack's Block Kit
Slack App Setup
To send notifications through Slack, you'll need to:
- Create a Slack app in your workspace
- Add the following OAuth scopes to your app:
chat:write
im:write
users:read
users:read.email
- Install the app to your workspace
- Copy the Bot User OAuth Token from your Slack app settings
- Configure the token in NotificationAPI dashboard
Detailed Setup Instructions
1. Create a Slack App
- Go to Slack API and sign in with your Slack account
- Click "Create New App"
- You'll be prompted to select a workspace.
- After selecting a workspace, you'll see the app manifest editor. Use this basic manifest:
{
"display_information": {
"name": "NotificationAPI"
},
"settings": {
"org_deploy_enabled": false,
"socket_mode_enabled": false,
"is_hosted": false,
"token_rotation_enabled": false
}
} - Review the app summary and click "Create" to finalize your app creation
2. Configure OAuth Scopes
- In your app settings, navigate to "OAuth & Permissions" in the sidebar
- Scroll to "Scopes" section
- Under "Bot Token Scopes", add the following scopes:
chat:write
- Send messages as your appim:write
- Send direct messages to usersusers:read
- View basic user informationusers:read.email
- Look up users by email
3. Install the App
- After adding scopes, scroll to the top of "OAuth & Permissions" page
- Click "Install to Workspace"
- Review the permissions and click "Allow"
- After installation, you'll see a "Bot User OAuth Token" - save this token securely
4. Configure in NotificationAPI Dashboard
- Log in to your NotificationAPI dashboard
- Go to "Settings" → "Slack Integration"
- Enter the Bot User OAuth Token you saved earlier
- Click "Save"
5. Testing the Integration
- Create a test notification template in NotificationAPI dashboard
- Configure it to use the Slack channel
- Send a test notification to verify the setup
Common Issues and Solutions
- App Not in Channel: If sending to channels, use
/invite @YourAppName
in the channel - Invalid Token: Double-check the Bot User OAuth Token in dashboard settings
- Missing Permissions: Verify all required scopes are added in Slack app settings
- User Not Found: Ensure user email in NotificationAPI matches their Slack email
Security Best Practices
-
Token Security:
- Never share your Bot User OAuth Token
- Rotate tokens if compromised
- Use different apps/tokens for different environments
-
Access Control:
- Regularly audit app installations
- Remove unused installations
- Review channel memberships periodically
Message Formatting
NotificationAPI supports Slack's Block Kit for rich message formatting. You can use:
- Text blocks with markdown
- Sections with fields
- Buttons and interactive elements
- Images and other media
- Dividers and context blocks
Example template:
{
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Hello {{userName}}! You have a new notification"
}
},
{
"type": "divider"
},
{
"type": "section",
"fields": [
{
"type": "mrkdwn",
"text": "*Type:*\n{{notificationType}}"
},
{
"type": "mrkdwn",
"text": "*When:*\n{{timestamp}}"
}
]
}
]
}
User Identification
To send direct messages to users, you need to identify them using one of these methods:
- Slack User ID
- Email address (must match the user's Slack email)
When using email addresses, NotificationAPI automatically resolves them to Slack User IDs.
Channel Messages
To send messages to channels:
- Invite your Slack app to the target channel using
/invite @YourAppName
- Use the channel ID or channel name in your notification settings
Make sure your Slack app is invited to channels before attempting to send messages.
Tracking Options
The following events are tracked and reported in our logs and insights features:
- Message delivery
- Message failures
- User resolution status
- Channel availability
Best Practices
-
Rate Limiting: Slack has rate limits for sending messages. NotificationAPI handles these automatically with smart retries.
-
User Experience:
- Use clear and concise messages
- Leverage formatting for better readability
- Include relevant links and context
- Use interactive elements when appropriate
-
Error Handling:
- NotificationAPI automatically handles common errors
- Failed deliveries are retried with exponential backoff
- Invalid user/channel errors are reported in logs