DEV Community

Cover image for Automate GitHub Discussions with Rowy and OpenAI's GPT-3 API
Bhavya Verma for BuildShip

Posted on • Originally published at rowy.io

Automate GitHub Discussions with Rowy and OpenAI's GPT-3 API

Managing open-source communities can be daunting, especially tracking community questions and providing timely answers. That's why we created the GitHub Command Centre. It's a powerful tool that leverages OpenAI's GPT-3 API to help open-source organizations manage their GitHub Discussions with greater efficiency. πŸ’ͺ

The GitHub Command Centre streamlines the process of handling community questions, automating responses via the OpenAI GPT-3 API and providing first-level triaging. This is a game-changing feature that makes managing open-source communities easier than ever before. In this blog post, we'll explore how the Command Centre works and how it can benefit your organization.

GitHub Discussions - An Overview

GitHub Discussions is a built-in feature that allows open source project communities to have threaded conversations and Q&A sessions. Discussions are essential for open source projects, as they provide a platform for community members to ask questions, share ideas, and offer feedback to project maintainers.

GitHub Discussions - The home for developer communities

As open source projects grow and their communities expand, managing the discussions within them can become overwhelming for maintainers. That's where the GitHub Command Centre comes in, offering powerful tools to help streamline process of handling community questions and automating responses.

Pre-requisites βœ…

  • A Rowy Account with Rowy Run set up. If you don’t have one, you can easily create an account at www.rowy.app. If you need help setting up Rowy, check out our documentation here.

  • A GitHub repository with Discussions enabled. If you're not sure how to enable Discussions, you can follow GitHub's documentation at https://docs.github.com/en/discussions.

Once you have these prerequisites in place, you're ready to start using the GitHub Command Centre to manage your open-source community discussions with greater ease and efficiency! 🎯

Setting up the Command Centre ✨

Follow these easy steps to get your GitHub Command Centre set up:

1. Getting Started with Rowy!

The first step is to visit www.rowy.io and click on the "Sign In" button. Once you have created your Workspace and set up your Project, you need to select the GitHub Command Centre template from the "Create a Table" section located at the top of the page.

Rowy Dashboard Template Setup Wizard

The template setup wizard will guide you through the steps to set up your table, add your secret keys, and deploy your cloud functions – all in one go! This streamlined process will save you time and effort. πŸš€

2. Setting up your Secrets 🀫

As part of the template setup process, you'll be prompted to add two secrets: your OpenAI API Key and your GitHub Personal Access Token. Here's how to retrieve these secret keys for your project:

1. Retrieving the OpenAI API Key βœ…

  1. Go to the OpenAI Account Dashboard and create an account if you haven’t already.

  2. Click on Create a new secret key.

OpenAI API Keys Dashboard

  1. Add a name for your secret key, Let's use "Command Centre" as an example. Finally, click "Create" to save your new secret key.

  2. Great! You've generated your OpenAI API Key. πŸŽ‰ Make sure to copy and store it in a safe and accessible location, as you'll be needing it later.

Adding OpenAI API Keys on Rowy Template Setup

In the Template Setup Wizard, when prompted to add your OpenAI API Key, click on the Add a key in Secret Manager button. This will redirect you to the GCP Secret Manager. Add your OpenAI API Key as shown below and click Create a Secret.

Adding OpenAI API key on Google Cloud Secret Manager

Now, you can go back to the setup process. Simply click on the Secret dropdown and select your newly generated API Key. If you can't see it, try clicking Refresh.

2. Retrieving the GitHub Personal Access Token βœ…

Using a Personal Access Token allows the suggested answers generated by the GitHub Command Centre to be sent as comments on behalf of the token owner. This feature helps to streamline the process of managing GitHub Discussions for open-source projects.

NOTE! ✍️ Please note that we are currently using the beta version of the GitHub Discussions API, which has some limitations. Specifically, we can only use Personal Access Tokens to send suggested answers as comments on behalf of users. We hope that GitHub will introduce more versatile ways of using the API soon.

QUICK TIP! πŸ’‘ You have two options for using Personal Access Tokens to send suggested answers as comments. You can either use your own token or create a new account specifically for a bot that will answer questions about your organization.

How to retrieve your Personal Access Token? πŸ€”

To retrieve your Personal Access Token, follow these steps:

  1. Go to your GitHub Account and click on your profile picture in the upper-right corner of the homepage. Then, click on Settings.

Navigating GitHub Settings

  1. In the left sidebar, click on Developer Settings.

  2. In the left sidebar, under Personal access tokens, click on Tokens (classic).

  3. Click Generate new token.

  4. Set an expiration for the token and select the following scopes under the Select Scopes category:

  • public_repo
  • read:org
  • write:discussion
  • read:discussion

Selecting Scopes for GitHub Personal Access Tokens

Selecting Scopes for GitHub Personal Access Tokens

  1. Click Generate Token and store it somewhere temporarily. You have successfully generated your Personal Access Token! πŸ₯³

In the GCP Secret Manager, add your GitHub Personal Access Token as shown below and click Create a Secret.

Adding GitHub Personal access token on Google Cloud Secret Manager

Post which, you can go back to the setup process and click on the Secret dropdown to select your newly generated GitHub Token. If you can't see it, try clicking Refresh.

Setting up the Webhook πŸ•ΈοΈ

After setting up your GitHub Command Centre template, you can configure the GitHub Discussions Webhook to listen for any changes in the discussion section of a specific repository.

To set up the webhook, follow these steps:

  1. Go to the Webhooks section in the top-right menu of your Command Centre template.

GitHub Discussions Webhooks Parser on Rowy

  1. Copy the Endpoint URL provided for the GitHub Discussions Webhook.

  2. Navigate to the repository you want to set up the Command Centre for on GitHub (https://github.com/).

  3. Go to the repository settings β†’ Webhooks and click on "Add a Webhook".

  4. Authenticate if prompted, then add the Endpoint URL to the Payload URL field. Set the content type to application/json.

Setting up the Webhook endpoint on GitHub

  1. Under the "Which events would you like to trigger this Webhook?" section, select "Let me Select Individual Events" and check the Discussions checkbox. This ensures that the webhook listens to changes in the repository's discussion section.

GitHub Discussions - Setting Trigger events

  1. Save the webhook, and now it's ready to use! πŸš€

Managing your Discussions Better πŸ’―

The Command Centre allows you to easily manage your discussions through a well-organized Rowy Table. This provides all the necessary information such as:

Status of the Discussion

The Status column records the current state of the discussion, including whether it has been created, pinned, or answered. There are 13 different categories available to describe the status of GitHub Discussions.

Recorded status of incoming GitHub Discussions

Discussion Title and Description

Both the Title and Description fields are formatted in GitHub-Flavored Markdown, displaying the discussion's details in an easily readable format.

Category of the Discussion

Currently, GitHub Discussions are divided into six categories: General, Announcements, Polls, Show and Tell, Support/Q&A, and Idea/Feature Requests.

Recorded Category of incoming GitHub Discussions

URL of the Discussion

The table includes the URL of each incoming discussion, providing easy access to the discussion.

Question Type

The Question Type field is a Derivative field type that utilizes the power of the GPT-3 API to perform first-level triaging of the discussion. The API classifies the discussion into one of three categories: Technical, Theoretical, or Unsure.

This categorization helps to quickly identify the type of question and provide appropriate answers, streamlining the process of managing discussions.

Triaged type of question asked in the incoming GitHub Discussions

Updated At Timestamp

The Updated At field is a derived column that stores the updated timestamp, if available. If the value is not available, it stores the created timestamp of the discussion.

QUICK TIP! πŸ’‘ By clicking once on the arrow on the column name you can sort the table in descending order by the Updated At field so that the most frequent discussions are more easily accessible by staying on top.

Suggested Answer

The Suggested Answer column is a powerful feature of the GitHub Command Centre, leveraging the capabilities of OpenAI's GPT-3 API to generate potential solutions for the discussion at hand. This is accomplished through a generic prompt given to the Derivative script, which generates markdown answers in the form of a JavaScript function.

The Suggested Answer field can be highly customized, enabling open-source project maintainers to save time and streamline the process of managing discussions.

AI generated answer of incoming GitHub Discussions

Additionally, the Suggested Answer field can be highly customized to suit your specific needs. For instance, you can train your model on your product data to provide more accurate answers to discussions. This level of customization enhances the Command Centre's utility and makes it an even more powerful tool for managing open-source communities.

Sending the Suggested Answer

Finally, the Send Comment toggle, when turned on, sends the Suggested Answer as a comment on the Discussion. This toggle triggers an extension that uses the GitHub Discussions API to send the answer. The beauty of this triggered extension is that it allows you to modify the Suggested Answer column according to your expertise, resulting in a more accurate and personalized response to the discussion.

Sending the AI generated answer as a comment on the discussion

Conclusion

In conclusion, the GitHub Command Centre is a game-changing solution for open-source projects. Its innovative features and customizable options make it an essential tool for managing discussions and building a thriving community on GitHub.

By integrating the GPT-3 API and the GitHub Discussions API, the Command Centre can provide suggested answers to discussions and automate repetitive tasks. With its highly customizable features, the Command Centre can be tailored to the needs of each individual project. By using the GitHub Command Centre, project maintainers can save time and effort, and build a more engaged and productive community around their projects. πŸš€

If you enjoyed our content, please give us a follow on Twitter or join our Discord in case of any questions. We look forward to hearing from you! πŸ’œ

Top comments (0)