Real-time Deployment Notifications with n8n and Slack
Introduction
Knowing when deployments happen - and whether they succeed or fail - is critical for any team. This tutorial shows you how to send rich, informative deployment notifications to Slack using n8n.
Prerequisites
- An n8n instance with public webhook URL
- Slack workspace with incoming webhooks enabled
- CI/CD pipeline that can send webhooks (GitHub Actions, GitLab CI, Jenkins, etc.)
Workflow Overview
CI/CD Webhook → n8n → Format Message → SlackStep-by-Step Setup
Step 1: Create the Webhook Endpoint
- Add a Webhook node
- Set HTTP Method to
POST - Set path to
deployment-notify - Response Mode:
On Received(immediate acknowledgment)
Your CI/CD will send payloads like:
{
"status": "success",
"environment": "production",
"version": "v1.2.3",
"commit": "abc123",
"deployer": "john",
"timestamp": "2025-01-15T10:30:00Z",
"url": "https://myapp.com"
}Step 2: Format the Message
Add a Set node to prepare Slack formatting:
const status = $json.status;
const emoji = status === 'success' ? '✅' : '❌';
const color = status === 'success' ? 'good' : 'danger';
return {
emoji: emoji,
color: color,
status: status,
environment: $json.environment,
version: $json.version,
commit: $json.commit,
deployer: $json.deployer,
url: $json.url
};Step 3: Send to Slack
Add a Slack node with a rich attachment:
Channel: #deployments
Attachments:
[
{
"color": "{{ $json.color }}",
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": "{{ $json.emoji }} Deployment {{ $json.status | capitalize }}"
}
},
{
"type": "section",
"fields": [
{
"type": "mrkdwn",
"text": "*Environment:*\n{{ $json.environment }}"
},
{
"type": "mrkdwn",
"text": "*Version:*\n{{ $json.version }}"
},
{
"type": "mrkdwn",
"text": "*Commit:*\n`{{ $json.commit }}`"
},
{
"type": "mrkdwn",
"text": "*Deployed by:*\n{{ $json.deployer }}"
}
]
},
{
"type": "actions",
"elements": [
{
"type": "button",
"text": {
"type": "plain_text",
"text": "View Deployment"
},
"url": "{{ $json.url }}"
}
]
}
]
}
]Integrating with CI/CD
GitHub Actions
Add to your workflow:
- name: Notify Deployment
if: always()
run: |
curl -X POST ${{ secrets.N8N_WEBHOOK_URL }} \
-H "Content-Type: application/json" \
-d '{
"status": "${{ job.status }}",
"environment": "production",
"version": "${{ github.ref_name }}",
"commit": "${{ github.sha }}",
"deployer": "${{ github.actor }}",
"url": "https://myapp.com"
}'GitLab CI
notify:
stage: notify
script:
- |
curl -X POST $N8N_WEBHOOK_URL \
-H "Content-Type: application/json" \
-d "{
\"status\": \"$CI_JOB_STATUS\",
\"environment\": \"$CI_ENVIRONMENT_NAME\",
\"version\": \"$CI_COMMIT_TAG\",
\"commit\": \"$CI_COMMIT_SHA\",
\"deployer\": \"$GITLAB_USER_LOGIN\"
}"
when: alwaysJenkins
post {
always {
script {
def payload = [
status: currentBuild.result,
environment: 'production',
version: env.BUILD_TAG,
commit: env.GIT_COMMIT,
deployer: env.BUILD_USER
]
httpRequest(
url: env.N8N_WEBHOOK_URL,
httpMode: 'POST',
contentType: 'APPLICATION_JSON',
requestBody: groovy.json.JsonOutput.toJson(payload)
)
}
}
}Enhanced Features
Route by Environment
Send production deployments to #production-alerts, staging to #dev:
const channel = $json.environment === 'production'
? '#production-alerts'
: '#dev';Add Rollback Button
Include a rollback action for failed deployments:
{
"type": "button",
"text": { "type": "plain_text", "text": "🔄 Rollback" },
"style": "danger",
"url": "https://your-rollback-endpoint"
}Thread Replies
Update the same thread with deployment progress:
- Store the message
tsfrom the first notification - Use
thread_tsparameter in subsequent messages
Troubleshooting
Message Not Appearing
- Check Slack webhook URL is correct
- Verify channel exists and bot has access
Formatting Issues
- Test JSON in Slack’s Block Kit Builder
- Check for unescaped characters
Missing Data
- Log the incoming webhook payload
- Ensure CI/CD sends all required fields
Conclusion
Rich deployment notifications keep your team informed without requiring them to check dashboards. With n8n, you can customize notifications to include exactly the information your team needs.
Download the complete workflow from our n8n Workflow Gallery.