A Slack bot that automatically fetches and posts on-call engineer information from Datadog to Slack channels.
- Fetches current on-call information from Datadog On-Call schedules
- Posts formatted messages to Slack channels
- Optional automatic message pinning
- Configurable scheduling (cron-based)
- Support for multiple on-call schedules
- Beautiful formatted messages with engineer details and shift times
- Node.js (v14 or higher)
- A Datadog account with API access
- A Slack workspace with bot creation permissions
-
Clone or download this project
-
Install dependencies:
npm install
-
Run the setup wizard:
npm run setup
The setup wizard will guide you through:
- Validating your Datadog credentials
- Discovering available on-call schedules
- Configuring your Slack bot
- Testing the connection
- Setting up the posting schedule
That's it! The wizard does everything for you.
If you prefer to configure manually instead of using the setup wizard:
Get your credentials from: https://app.datadoghq.eu/organization-settings/api-keys
You'll need:
- API Key
- Application Key
- Site (e.g., datadoghq.eu, datadoghq.com)
To find your Schedule ID:
- Go to your Datadog On-Call dashboard: https://app.datadoghq.eu/on-call/schedules
- Click on the schedule you want to monitor
- The Schedule ID is in the URL
Create or configure your Slack app at: https://api.slack.com/apps
Required OAuth Scopes (Bot Token Scopes):
chat:write- Post messages to channelschat:write.public- Post messages to public channels without joiningpins:write- Pin messages (optional)
Get your Bot Token:
- Go to "OAuth & Permissions" in your Slack app settings
- Click "Install to Workspace"
- Copy the "Bot User OAuth Token" (starts with
xoxb-)
Get your Channel ID:
- Right-click on the channel in Slack β "View channel details"
- Copy the Channel ID at the bottom
Edit the .env file manually:
# Datadog Configuration
DATADOG_API_KEY=your_api_key
DATADOG_APP_KEY=your_app_key
DATADOG_SITE=datadoghq.eu
DATADOG_SCHEDULE_ID=optional_schedule_id
# Slack Configuration
SLACK_BOT_TOKEN=xoxb-your-token
SLACK_CHANNEL_ID=C1234567890
# Schedule Configuration (cron format)
CRON_SCHEDULE=0 9 * * *
# Pin message to channel (true/false)
PIN_MESSAGE=true0 9 * * *- Every day at 9:00 AM0 9 * * 1-5- Every weekday at 9:00 AM0 9,17 * * *- Every day at 9:00 AM and 5:00 PM0 */6 * * *- Every 6 hours0 8 * * 1- Every Monday at 8:00 AM
npm testor
node index.js nownpm startor
node index.js startThe bot will:
- Validate your configuration
- Start running and wait for the scheduled time
- Post on-call information automatically at the configured intervals
- Optionally pin the messages to the channel
The bot posts beautifully formatted messages like:
π¨ Today's On-Call Engineers
ββββββββββββββββββββββββββββ
π Platform Team Schedule
π€ Engineer: John Doe (john.doe@company.com)
β° Shift: Jan 23, 09:00 AM - Jan 24, 09:00 AM
ββββββββββββββββββββββββββββ
Updated: January 23, 2025, 9:00 AM
- Make sure all required fields in
.envare filled out - Ensure your
.envfile is in the same directory asindex.js
- Verify your Datadog API keys are correct
- Check that your Schedule ID is valid
- Ensure your Datadog account has access to On-Call schedules
- Verify your Slack bot token is correct
- Ensure the bot has the required OAuth scopes
- Check that the channel ID is correct
- Make sure the bot is installed in your workspace
- Ensure the bot has the
pins:writescope - The bot must be a member of private channels to pin messages
npm install -g pm2
pm2 start index.js --name oncall-bot
pm2 save
pm2 startupCreate a Dockerfile:
FROM node:18-alpine
WORKDIR /app
COPY package*.json ./
RUN npm install --production
COPY . .
CMD ["node", "index.js", "start"]Build and run:
docker build -t oncall-bot .
docker run -d --env-file .env oncall-botIf you want to monitor multiple schedules, you can:
- Remove or leave blank the
DATADOG_SCHEDULE_IDto fetch all on-call schedules - Or create multiple bot instances with different configurations
Edit the formatOnCallMessage() function in index.js to customize the message appearance.
ISC