Automate GitHub Discussions with Rowy and OpenAI's GPT-3 API
Tags: lowcode, opensource, github, chatgpt
Published: 2023-05-18 13:27:20

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2cy4niwm4om786pdg8w7.png)

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](https://docs.rowy.io/setup/install) set up. If you don’t have one, you can easily create an account at [www.rowy.app](www.rowy.app). If you need help setting up Rowy, check out our documentation [here](https://docs.rowy.io/category/how-to-guide).

- 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](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](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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sbpfbw55clordp2lfgg9.png)

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](https://platform.openai.com/account/api-keys) and create an account if you haven’t already.

2. Click on **Create a new secret key**.

![OpenAI API Keys Dashboard](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p2ibdecyq528pfljudte.png)

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

4. 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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hpb5s4l4zq9yqpotg73p.png)

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](https://console.cloud.google.com/security/secret-manager). Add your OpenAI API Key as shown below and click **Create a Secret**.

![Adding OpenAI API key on Google Cloud Secret Manager](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8kat50rq2fyjrq0bu67c.png)

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](https://github.com/) and click on your **profile picture** in the upper-right corner of the homepage. Then, click on **Settings**.

![Navigating GitHub Settings](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7hqg5vwbztx8mwvinl9b.png)

2. In the left sidebar, click on **Developer Settings**.

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

4. Click **Generate new token**.

5. 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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cdedsebauum0798x1rgm.png)

![Selecting Scopes for GitHub Personal Access Tokens](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ij2n21gnvlvphw9drqvg.png)

6. Click **Generate Token** and store it somewhere temporarily. You have successfully generated your Personal Access Token! 🥳

In the [GCP Secret Manager](https://console.cloud.google.com/security/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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tenqejgwwo3vucehpiel.png)

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qy4bhpvbiq8ih6c9ai5w.png)

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

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

4. Go to the repository settings → Webhooks and click on "Add a Webhook".

5. 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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yvcsqlvkl3xniprj4se6.png)

6. 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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gmohbynfldksfeutarni.png)

7. 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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d8hyy07nuwaj3xbf2xbr.png)

### 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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v5reb56ocm1v2ra0rvzf.png)

### 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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zm85rqxq407of2ehkj4h.png)

### 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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cabdvy2tdyetgbqemw14.png)

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/grs4bdbn8z8lyvuzldyl.png)

## 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](https://twitter.com/rowyio) or [join our Discord](https://rowy.io/discord) in case of any questions. We look forward to hearing from you! 💜