Loading...
Loading...
Learn how to integrate with Slack using webhooks. Send notifications to channels with incoming webhooks and respond to events with the Events API.
Slack provides two main webhook mechanisms: Incoming Webhooks for posting messages to Slack, and the Events API (replacing legacy outgoing webhooks) for receiving notifications when things happen in Slack.
Send messages from your app to Slack channels. Perfect for notifications, alerts, and automated updates.
Receive webhooks from Slack when events occur - messages posted, reactions added, users joining channels, and more.
Go to api.slack.com/apps and click Create New App. Choose "From scratch", name your app, and select your workspace.
In your app settings, go to Incoming Webhooks in the sidebar. Toggle the switch to On.
Click Add New Webhook to Workspace. Select the channel where messages should be posted and click Allow.
You'll get a URL like https://hooks.slack.com/services/T00/B00/XXX. Keep this secret - anyone with this URL can post to your channel.
Send a POST request with a JSON payload to your webhook URL:
curl -X POST "https://hooks.slack.com/services/T00/B00/XXX" \
-H "Content-Type: application/json" \
-d '{"text": "Hello from Webhook.it!"}'Use Slack's Block Kit for beautifully formatted messages:
{
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": "Deployment Notification"
}
},
{
"type": "section",
"fields": [
{
"type": "mrkdwn",
"text": "*Environment:*\nProduction"
},
{
"type": "mrkdwn",
"text": "*Status:*\n✅ Success"
}
]
},
{
"type": "divider"
},
{
"type": "context",
"elements": [
{
"type": "mrkdwn",
"text": "Deployed by *CI/CD Pipeline* at <!date^1705312200^{date_short} {time}|2025-01-15>"
}
]
}
]
}header - Large bold text at the topsection - Text with optional fields and accessoriesdivider - Horizontal line separatorcontext - Small muted text and imagesactions - Interactive buttons and menusimage - Full-width imagesTo receive webhooks from Slack when events occur, use Webhook.it to test your endpoint:
Get a Webhook.it URL to receive events. In your Slack app settings, go to Event Subscriptions and enter your URL.
Slack sends a challenge request to verify your endpoint. Respond with the challenge value in the response body.
Select the events you want to receive: message.channels, reaction_added, member_joined_channel, etc.
Here's what a message event looks like:
{
"token": "XXYYZZ",
"team_id": "T123ABC456",
"event": {
"type": "message",
"channel": "C123ABC456",
"user": "U123ABC456",
"text": "Hello everyone!",
"ts": "1705312200.000100"
},
"type": "event_callback",
"event_id": "Ev123ABC456",
"event_time": 1705312200
} x-slack-signature header to ensure requests come from Slack.Incoming webhooks let external apps send messages TO Slack channels. Outgoing webhooks (now replaced by Events API) send data FROM Slack to your app when certain triggers occur, like messages containing specific keywords.
Go to api.slack.com/apps, create or select an app, enable Incoming Webhooks, and click 'Add New Webhook to Workspace'. Select a channel and you'll get a unique URL to POST messages to.
The username and icon are set when you create the webhook and cannot be overridden in individual messages. To use different identities, create separate webhook URLs or use the chat.postMessage API instead.
Slack uses Block Kit for rich message formatting. You can include text blocks, images, buttons, and dividers. For simple messages, use the 'text' field with mrkdwn formatting (*bold*, _italic_, `code`).
Outgoing webhooks are legacy and limited to public channels with keyword triggers. The Events API is more powerful: it works in all channels, supports many event types, and is the recommended approach for new integrations.