View the full code and setup instructions in our examples repository
Overview
The process involves three main components:- Setting up a Modal web endpoint for GitHub webhooks
- Handling PR label events
- Running an AI-powered code review agent
Step 1: Setting Up the Modal App
First, we set up a Modal application to handle GitHub webhooks:The Modal app provides a webhook endpoint that GitHub can call when PR events occur.
Make sure to configure your GitHub repository’s webhook settings to point to your Modal endpoint.
Step 2: Handling PR Events
Next, we set up event handlers for PR label events:Step 3: Implementing the Review Agent
Finally, we implement the AI-powered review agent:Setting Up the Environment
Before running the bot, you’ll need:- Create a
.envfile with your credentials:
- Deploy the Modal app:
- Configure GitHub webhook:
- Go to your repository settings
- Add webhook pointing to your Modal endpoint
- Select “Pull request” events
- Add a webhook secret (optional but recommended)
Example Usage
- Create or update a pull request in your repository
- Add the “Codegen” label to trigger a review
- The bot will:
- Post a temporary “starting review” comment
- Analyze the PR changes
- Post detailed review comments
- Remove the temporary comment when done
- Remove the “Codegen” label
- The bot will automatically clean up its comments
Extensions
While this example demonstrates a basic PR review bot, you can extend it to:- Customize the review criteria
- Add more sophisticated analysis tools
- Integrate with other services
- Add automatic fix suggestions
- … etc.