Slack Webhook Integration
Slack provides multiple webhook types for different use cases: Incoming Webhooks for posting messages, Event Subscriptions for receiving events, and Interactive Components for handling user interactions. Build powerful Slack integrations with real-time event handling.Quick Start
- Get your Unhook URL:
https://unhook.sh/wh_YOUR_ID - Configure in Slack App Settings: api.slack.com/apps
- Start receiving events locally:
unhook listen
Webhook Types
1. Event Subscriptions (Recommended)
Real-time events from Slack workspace:- Message events
- User activity
- Channel changes
- App mentions
- File uploads
2. Interactive Components
User interactions with your app:- Button clicks
- Menu selections
- Dialog submissions
- Shortcuts
3. Slash Commands
Custom commands triggered by users:/commandstyle triggers- Custom parameters
- Direct responses
Configuration Steps
Setting Up Event Subscriptions
1. Create or Configure Slack App
- Go to api.slack.com/apps
- Create a new app or select existing
- Navigate to Event Subscriptions
2. Enable Events
- Toggle Enable Events to On
- Enter Request URL:
- Slack will send a verification challenge
- Once verified, the URL will show as Verified ✓
3. Subscribe to Events
Select workspace events: Message Eventsmessage.channels- Messages in public channelsmessage.groups- Messages in private channelsmessage.im- Direct messagesmessage.mpim- Group direct messagesapp_mention- When your app is @mentionedmessage.reactions- Reactions added/removed
team_join- New team member joineduser_change- User profile updateduser_status_changed- Status updatemember_joined_channel- User joined channelmember_left_channel- User left channel
channel_created- New channel createdchannel_deleted- Channel deletedchannel_rename- Channel renamedchannel_archive- Channel archivedchannel_unarchive- Channel unarchived
file_created- File uploadedfile_shared- File sharedfile_deleted- File deletedfile_comment_added- Comment on file
4. Save Changes
Click Save Changes to activate subscriptionsSetting Up Interactive Components
- Navigate to Interactivity & Shortcuts
- Toggle Interactivity to On
- Enter Request URL:
- Optionally configure:
- Select Menus Options Load URL
- Shortcuts
Setting Up Slash Commands
- Navigate to Slash Commands
- Click Create New Command
- Configure:
- Command:
/yourcommand - Request URL:
https://unhook.sh/wh_YOUR_ID - Short Description
- Usage Hint
- Command:
- Click Save
Event Payload Examples
Message Event
App Mention Event
Interactive Component (Button Click)
Slash Command
Webhook Verification
URL Verification Challenge
Slack sends this when first setting up:Request Signature Verification
Verify requests are from Slack:Response Formats
Event Acknowledgment
Always respond quickly (within 3 seconds):Interactive Response
For interactive components, you can update the message:Slash Command Response
Best Practices
1. Handle Rate Limits
Respect Slack’s rate limits:2. Use Slack SDK
3. Handle Retries
Slack may retry failed webhooks:4. Error Handling
Implement robust error handling:Common Use Cases
Auto-respond to Keywords
Approval Workflows
Testing Webhooks
Using Slack’s Event Tester
- Go to Event Subscriptions page
- Find “Send Test Event” button
- Select event type and send
Manual Testing
Environment Variables
Common Issues
URL Verification Failing
- Ensure webhook responds with challenge value
- Check response is plain text, not JSON
- Verify URL is publicly accessible
Missing Events
- Check bot has required scopes
- Ensure bot is in the channel
- Verify event subscriptions are saved
Rate Limit Errors
- Implement exponential backoff
- Use batching where possible
- Cache frequently accessed data
Useful Links
- Slack API: api.slack.com
- App Management: api.slack.com/apps
- Event Types Reference: api.slack.com/events
- Interactive Components: api.slack.com/interactivity
- Block Kit Builder: app.slack.com/block-kit-builder
- Slack SDK: slack.dev/node-slack-sdk
Support
Need help with Slack webhooks?- Join our Discord community
- Visit Slack Community
- Check Slack API Docs
- Email us at support@unhook.sh