Skip to content

Harshaan-Chugh/CornellHelpBot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CornellHelpBot

CornellHelpBot is a Spring Boot application that automates responses to prospective Cornell students on the Cornell subreddit. The bot monitors specific threads, fetches the latest top-level comment, and uses OpenAI's GPT-4 API to generate a context-aware reply tailored to admissions and life at Cornell University.

Features

  • Fetches the latest top-level comment from a specific Reddit submission.
  • Generates a context-aware response using OpenAI's GPT-4 API.
  • Automatically replies to the comment on Reddit.
  • Handles potential issues like deleted comments and network errors.
  • Sample Responses:
    • img.png

Technologies Used

  • Java 22
  • Spring Boot
  • Reddit API (via JRAW)
  • OpenAI GPT-4o API
  • OkHttp (for making HTTP requests)
  • Maven (for dependency management)

Prerequisites

Before running the application, ensure you have the following set up:

  1. Java
  2. Maven (for building the project)
  3. Reddit API
  4. OpenAI API

Getting Started

1. Set Up Environment Variables

Create a .env file in the root directory of your project and add the needed environment variables:

USERNAME=your_reddit_user
PASSWORD=your_reddit_pw
CLIENT_ID=your_reddit_client_id
CLIENT_SECRET=your_reddit_client_secret
OPENAI_API_KEY=your_openai_api_key

2. Build the Project & Run the Application

mvn clean install
mvn spring-boot:run

3. Interacting with the Bot

Once the application is running, you can get the bot to reply to a comment in Cornell's "Chance Me! and Prospective Student Q&A" thread or any post (you can choose) by running the CornellHelpBotApplication.

Or you can use a Client URL to trigger it using a REST API:

http://localhost:8080/reply-to-comments?submissionId={submission_id}

Project Structure and Classes

CornellHelpBotApplication: The entry point for the Spring Boot application.

CornellHelpBotService: Handles the core functionality of fetching comments and generating replies.

RedditService: Manages interaction with Reddit, fetching the latest top-level comments.

OpenAIService: Manages interaction with OpenAI's GPT-4 API to generate responses.

RedditConfig: Configures the Reddit client with necessary credentials.

RedditOpenAIController: Provides REST endpoints to trigger bot actions.

About

Automated responses to prospective Cornell students in r/Cornell.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages