Looking for a Halp replacement?
See how we compare ➜

Building GitHub AI code review assistant with Actioner

Build your own GitHub Al assistant for pull request code reviews. Interact with the Al copilot, request to make changes to the PR according to its suggestions.

When you're knee-deep in code, navigating pull requests and meetings, streamlining the review process becomes essential. What if an AI assistant could handle the initial code review, reducing the back-and-forth with reviewers? Now it can, thanks to Actioner's latest AI Copilot feature.

Let me briefly introduce the AI assistant we've recently added to the platform and share my own experience of integrating it into our GitHub PR review workflow.

About GitHub AI code review assistant:

The GitHub AI code review assistant utilizes Actioner’s AI assistant feature powered by OpenAI's GPT-4 to offer smart suggestions for pull requests in Slack, automating reviews to boost code quality and efficiency.

Features

Here are the main features of the GitHub AI code review assistant I’ve built to use in Slack;

  • AI-powered code review: Have your code analyzed and reviewed by an intelligent AI system.
  • Interactive dialogue: Engage in conversation with the AI assistant; simply begin your message with "Hey assistant," and it will actively participate in PR channel discussions.
  • Code modification assistance: Request the AI assistant to implement its suggested changes and directly push updates to your branch.

Building GitHub AI code review assistant

1. Downloading the GitHub PR app:

I started the process by creating an AI assistant inside the GitHub PR app I downloaded from the Actioner app directory.

2. Configuring the AI assistant:

The first step involves giving instructions to the Assistant. I directed the assistant to conduct concise code reviews, specifying that it should highlight suggested code changes for the PR owner without commending the positive aspects to maintain brevity in the review.

Configuring AI assistant for GitHub PR app
Configuring AI assistant for GitHub PR app

Secondly, I added the Get file contents workflow under the Workflows section. This specific workflow is intended to be invoked by the assistant in cases where the code diff alone is insufficient for a comprehensive review and the assistant requires access to the full content of a file.

3. Creating an AI code review workflow:

My next step was creating a workflow to be triggered in Slack for the AI assistant to review the PR. By default, the GitHub PR app creates a dedicated Slack channel for every new pull request. So, I added a new workflow to send a message to this channel containing a button to initiate an AI code review.

This workflow will be activated when a user clicks the Review button. This process will involve several key steps:

  • PR retrieval and integration: Initially, it will retrieve the pull request from GitHub, integrating PR-specific details into the Assistant's conversational context.
  • Commit analysis and integration: Subsequently, it will gather all commits within the pull request, iterating through each file modified in these commits. The workflow will then incorporate the code differences into the Assistant's conversational context for a comprehensive review.
  • Automated code review execution: Finally, it will prompt the AI Assistant to conduct a code review, leveraging the detailed information provided to ensure thorough and insightful feedback.
Review button in Slack channel to trigger PR review
Review button in Slack channel to trigger PR review

The AI assistant generates a response message asynchronously. A workflow is needed to subscribe to these messages and send them back to the dedicated Slack PR channel.

Reviewing code with GitHub AI assistant

Upon clicking the Review button in the PR channel, the GitHub AI code review Assistant fetched the pull request and its detailed commit history from GitHub, synthesizing this information into a conversational context for an insightful, automated code review within Slack.

The example screenshot from Slack illustrates the assistant in action. It provides feedback on PR-specific issues such as logging for exceptions, code duplication, and resource management, demonstrating the AI's capability to offer concrete, actionable advice.

GitHub AI code review assistant
GitHub AI code review assistant

Interacting with GitHub AI code review assistant

AI assistant’s capabilities are not restricted by the review. You can interact further with the AI assistant verbally. Here, I asked the assistant to make the changes for me. 

It offers detailed coding suggestions, guides me in integrating changes, emphasizes best practices and resource management, and ensures adherence to project standards.

Interacting with GitHub AI code review assistant
Interacting with GitHub AI code review assistant

AI code reviews have been a valuable asset to our internal processes, and we see exciting potential for further enhancements as Actioner Developer team.

Actioner as an AI platform

In a landscape dominated by SaaS products incorporating AI, Actioner distinguishes itself by offering a seamless integration of AI assistants into end-user workflows. While I've demonstrated one method for embedding AI assistants, the true power of Actioner lies in its versatility, enabling customization to fit your specific needs. 

Actioner's Workflow Designer enables you to create workflows consisting of nodes that are arranged and executed sequentially from top to bottom. These workflows can be initiated by any event, such as webhook or integration events, manually through Slack or based on a specific or recurring schedule. Additionally, you can enhance your workflows by adding nodes for executing actions, running JavaScript functions, or incorporating conditions, branches, loops, or delay logic.

Incorporating an AI assistant into apps, the Actioner platform introduces 2 events to its Workflow Designer to enhance functionality and user interaction:

  • Assistant run status: This event is triggered when the status of a previous assistant invocation changes. The status can be completed, requires action, failed, or expired.
  • New assistant message: This event is triggered when the assistant produces a response message to a previous invocation.
Actioner Workflows AI events
Actioner Workflows AI events

Integrating the AI assistant into the Actioner platform also introduces an AI node, complementing existing actions, conditions, branches, loops, and delay nodes for enhanced workflow automation.

Actioner Workflow AI nodes
Actioner Workflow AI nodes

How to build an AI assistant that is different from this one

You can make your own AI assistant using Actioner by choosing an app from the App directory tailored to your existing tool or building one from scratch. 

After that, when you’re on your App’s page, you will encounter three configuration fields under the AI assistant tab:

  • The first is Instructions, where you can specify how you want the AI assistant to behave.
  • The second field is Documents. Importing your documents into Actioner and linking them to the AI assistant will respond to related queries by referencing these documents. For instance, you can import documents from Confluence or Google Drive and integrate the assistant into a Slack channel. (I haven't used this one while building the GitHub AI code review Assistant.)
  • The last field is Workflows. You can incorporate your custom Actioner workflows into the AI assistant's toolset. The assistant will invoke your workflows as necessary. You can choose to automatically execute the called workflows or send buttons within Slack messages by creating a workflow and subscribing to the Assistant run status event mentioned earlier.
Configurations for building AI assistant 
Configurations for building AI assistant 

Wrapping Up

Incorporating the GitHub AI code review assistant into our workflows represents just one of the myriad ways to harness the power of this innovative feature. You should explore its capabilities by installing the GitHub PR app and integrating it into your development processes, witnessing firsthand how it can enhance efficiency and code quality. 

Additionally, I invite you to join our Slack community, where we're always open to collaboration and sharing insights.

Similar posts

DevOps

The One-click deployment within GitHub PRs on Slack

Deploy code with one-click from Slack while collaborating on Pull request channels. Read the blog to learn more 👉

Alper Saglam
DevOps

Top 3 Planning poker Slack apps for 2024

Here we've listed and compared Planning poker Slack bots. Let's find the best Slack app that fulfills your team's needs.

Aysegul Yavuz Gokcuoglu
News
DevOps

New GitHub PR app features to boost your productivity in Slack

Collaborate on code, approve and merge pull requests, and run workflows directly within Slack – Read to learn enhancements on GitHub PR app now 👉

Murat Catal