A Slack bot that integrates with PagerDuty to trigger incidents/escalations from Slack channels. This bot is designed to run in shared Slack channels with customers, allowing them to trigger alerts to on-call personnel.
- Trigger PagerDuty alerts directly from Slack using a slash command (
/escalate
) - Trigger alerts by mentioning keywords like "alert", "trigger", "escalate", or "page" in a message
- Interactive UI for providing incident details
- Secure deployment on Kubernetes with secrets management
- Socket Mode integration (no need for public webhooks)
- Python 3.9+
- Slack workspace with admin permissions to create apps
- PagerDuty account with API access
- Kubernetes cluster (for production deployment)
-
Create a new Slack app at https://api.slack.com/apps
-
Add the following Bot Token Scopes under "OAuth & Permissions":
chat:write
chat:write.public
commands
users:read
users:read.email
channels:read
(for channel name resolution)
-
Enable Socket Mode under "Socket Mode" section
-
Create a slash command
/escalate
with the description "Trigger a PagerDuty incident" -
Install the app to your workspace
This bot uses PagerDuty's Events API v2
- Create a service in PagerDuty or use an existing one
- Add an "Events API v2" integration to the service
- Get the "Integration Key" provided by PagerDuty
- Use this Integration Key as your
PAGERDUTY_SERVICE_ID
in your configuration
- Clone this repository
- Create a
.env
file based on the providedsample-env
- Install dependencies:
pip install -r requirements.txt
- Run the bot:
python app.py
docker build -t slack-pagerduty-bot .
docker run -p 3000:3000 --env-file .env slack-pagerduty-bot
Deploy using Helm:
helm upgrade --install slack-pagerduty-bot ./helm-chart -f values.yaml
See the helm-chart
directory for Helm chart details and configuration options.
Use the /escalate
command followed by a description of the issue:
/escalate Database servers are not responding
Mention one of the trigger keywords in a message:
We need to alert the on-call team that the API is down
This will prompt an interactive dialog to confirm and provide more details.
Configuration is done through environment variables or Kubernetes secrets:
Variable | Description | Required | Default |
---|---|---|---|
SLACK_BOT_TOKEN | Slack Bot Token (xoxb-) | Yes | - |
SLACK_APP_TOKEN | Slack App-Level Token (xapp-) | Yes | - |
PAGERDUTY_INTEGRATION_KEY | PagerDuty Integration Key | Yes | - |
DEBUG | Enable debug logging | No | False |
ALLOWED_CHANNELS | Comma-separated list of allowed channel IDs or names | No | All channels |
The ALLOWED_CHANNELS
setting supports both channel IDs (starting with 'C') and human-readable channel names (like 'general'). Channel names will be automatically resolved to IDs at startup.
This project is licensed under the MIT License - see the LICENSE file for details.