A Slack slash command that fetches GitHub PR info and posts a formatted message.
/pr <github-pr-url> [@reviewer] [message]
Examples:
/pr https://github.com/owner/repo/pull/123
/pr https://github.com/owner/repo/pull/123 @luna
/pr https://github.com/owner/repo/pull/123 @luna please review when you have time
Output:
NEW PR by @author - PR title
Commits: 1
Files Changed: 3
Insertions: +42 Deletions: -10
@luna please review when you have time
- Go to https://api.slack.com/apps and create a new app
- Add the slash command
/prunder Slash Commands - Add the
chat:writeOAuth scope under OAuth & Permissions - Install the app to your workspace
- Copy the Signing Secret (Basic Information) and Bot Token (OAuth & Permissions)
- Go to https://github.com/settings/tokens
- Create a token with
reposcope (orpublic_repofor public repos only)
Add these secrets to your repository (Settings → Secrets and variables → Actions):
| Secret | Description |
|---|---|
AWS_ACCESS_KEY_ID |
AWS IAM access key |
AWS_SECRET_ACCESS_KEY |
AWS IAM secret key |
SLACK_SIGNING_SECRET |
From Slack app Basic Information |
SLACK_BOT_TOKEN |
Bot User OAuth Token (xoxb-...) |
GH_PAT |
GitHub personal access token |
Push to main branch to trigger automatic deployment via GitHub Actions.
Or deploy manually:
export AWS_ACCESS_KEY_ID=your_key
export AWS_SECRET_ACCESS_KEY=your_secret
export SLACK_SIGNING_SECRET=your_signing_secret
export SLACK_BOT_TOKEN=xoxb-your-token
export GITHUB_TOKEN=ghp_your_token
npm install
npm run deployAfter deployment, copy the API Gateway URL from the serverless output and set it as the Request URL for your slash command:
https://xxxxxxxxxx.execute-api.us-east-1.amazonaws.com/dev/slack/pr
npm install # Install dependencies
npm run build # Compile TypeScript