⚙️ Review GitHub pull requests with GPT-4o and send feedback and Slack alerts

⚡ 131 views · ⚙️ DevOps & CI/CD

💡 Pro Tip — If you need GitHub data beyond what the REST API gives you, ScraperNode has a repository scraper that extracts metadata at scale without token rate limits.

View All Scrapers

Description

Automatically review pull requests with AI and post feedback as GitHub comments


Who is this for

Engineering teams, code reviewers, and tech leads who want to automate code review feedback. Ideal for repositories with high PR volume where consistent first-pass review is valuable.

What this workflow does

This workflow automates pull request code review using GPT-4o and routes findings to GitHub and Slack. When a pull request is opened, it fetches the raw diff, sends it to GPT-4o for analysis, and posts a formatted Markdown comment with severity rating, categorized issues, suggestions, and an overall score. Critical findings trigger immediate Slack alerts.

How to set up

  1. Add your GitHub OAuth2 credential to the trigger and comment nodes
  2. Add your OpenAI API credential to the GPT-4o node
  3. Add your Slack OAuth2 credential to both Slack notification nodes
  4. Configure n8n Variables: GITHUB_OWNER, GITHUB_REPO, and GITHUB_TOKEN
  5. Activate the workflow - the GitHub webhook registers automatically
  6. Open a test pull request to verify end-to-end execution

Requirements

How to customize

Adjust the diff truncation limit (default 12,000 chars) in the Format PR Diff node. Modify the GPT-4o system prompt to focus on specific code quality concerns like security or performance. Update Slack channel routing based on your team’s notification policy.


Node List

#Node NameTypePurpose
1When PR OpenedGitHub TriggerReceives pull_request webhook events
2Check PR OpenIfPasses only action = opened to avoid duplicates
3Fetch PR DiffHTTP RequestFetches the raw unified diff from GitHub
4Format PR DiffCodeExtracts PR metadata; truncates diff to 12,000 chars
5AI Code Review with GPT-4OpenAISends diff to GPT-4o; returns structured JSON review
6Build Comment for GitHubCodeParses JSON; assembles Markdown comment
7Post Comment to GitHubGitHubPosts the AI review comment on the pull request
8Check Critical SeverityIfRoutes based on CRITICAL vs non-critical severity
9Alert Critical Issues to SlackSlackSends urgent alert to #incident
10Share Review Summary on SlackSlackSends summary notification to #code-reviews

Total: 10 nodes (+ 5 Sticky Notes)


Sticky Note Compliance

#Sticky Note TitleColorRole
1Main Sticky Note (Overview)YellowWorkflow overview, How it works, Setup steps, Customization
2Trigger and filter PRWhiteCovers GitHub trigger and PR filter
3Fetch and format diffWhiteCovers diff retrieval and formatting
4AI review and commentWhiteCovers AI review and comment building
5Severity check and alertsWhiteCovers severity routing and Slack notifications

All sticky notes use H2 headings (## ) and follow n8n public guidelines.


Tags

ai gpt-4 openai github slack code-review devops automation

🔗 Nodes Used

GitHub, Github Trigger, HTTP Request, Slack, OpenAI

📥 Import

Download workflow.json and import into n8n: Workflow menu → Import from File

📖 Importing guide · 🔑 Credential setup