A bash script that fetches posts from Reddit subreddits and uses OpenAI's GPT-4.1-mini to analyze business opportunities, pain points, and user sentiment with enhanced comment analysis.
This tool automates the process of:
- Fetching top posts from specified subreddits using Reddit's OAuth API
- Filtering posts by age and content criteria
- Fetching and analyzing top comments for each post to identify solutions and community validation
- Analyzing each post with OpenAI to extract pain points and business opportunities
- Performing enhanced sentiment analysis (unsolved problems, feature requests, pain validation, etc.)
- Scoring business opportunities (1-5 scale) based on problem severity and solution status
- Generating timestamped JSON summaries with detailed metadata
- Creating markdown analysis reports with business insights by community
- Tracking API usage and costs
- Multi-subreddit support: Analyze posts from multiple subreddits in a single run
- Flexible ordering: Supports hot, new, top, rising, and controversial post ordering
- Time-based filtering: Filter posts by age and timeframe (hour/day/week/month/year)
- Comment analysis: Fetches top 10 comments per post to identify existing solutions
- Business opportunity scoring: Rates each post's potential (1-5 scale)
- Enhanced sentiment classification:
unsolved_problem
: Problems with no working solutionspartial_solution
: Has workarounds but they're complex/incompleteseeking_tool
: Actively looking for a tool that doesn't existfeature_request
: Wants functionality not in current toolspain_validated
: Multiple people have the same problemwell_solved
: Has good solutions (less interesting)sharing
: Sharing a solution/tool they builtdiscussion
: General discussion/opinion
- Solution quality tracking: Identifies if solutions exist (none/workaround/partial/complete)
- Key pain points extraction: Lists up to 3 specific problems per post
- Markdown reports: Auto-generated business analysis with insights by community
- Cost tracking: Logs OpenAI API token usage and estimated costs
- Robust error handling: Validates API responses and handles missing fields
- Pretty JSON output: Well-formatted summary files with timestamps
- Clone this repository:
git clone https://github.com/shayonpal/check-reddit-posts.git
cd check-reddit-posts
- Copy the example environment file and edit it with your credentials:
cp .env.example .env
-
Edit the
.env
file with your API credentials:- Reddit API:
- Go to https://www.reddit.com/prefs/apps
- Click "Create App" or "Create Another App"
- Fill in the form:
- Name: Choose any name (e.g., "Reddit Post Analyzer")
- App type: Select script
- Description: Optional
- About URL: Leave blank
- Redirect URI: Use
http://localhost:8080
(required but not used)
- Click "Create app"
- Your credentials will be displayed:
REDDIT_CLIENT_ID
: The string under "personal use script"REDDIT_CLIENT_SECRET
: The "secret" string
- OpenAI API: Get your key from https://platform.openai.com/api-keys
- Customize the subreddits and other settings as needed
- Reddit API:
-
Ensure you have the required dependencies:
- bash or zsh
- curl
- jq
Create a .env
file in the project root with the following variables:
# Reddit OAuth API credentials
REDDIT_CLIENT_ID=your_client_id
REDDIT_CLIENT_SECRET=your_client_secret
REDDIT_USERNAME=your_username
REDDIT_PASSWORD=your_password
REDDIT_USER_AGENT="PostAnalyzer/0.1 by your_username"
# OpenAI API key
OPENAI_API_KEY=your_openai_api_key
# Number of posts to analyze per subreddit
NUM_POSTS=10
# Reddit post ordering logic: hot, new, top, rising, controversial
ORDER_LOGIC=top
# Timeframe for top/controversial: hour, day, week, month, year, all
TIMEFRAME=week
# Maximum number of days ago to fetch posts
MIN_DAYS_AGO=90
# Comma-separated list of subreddits
SUBREDDITS=shortcuts,automation,applescript
Run the script:
./script.sh
The script will:
- Authenticate with Reddit and fetch posts from configured subreddits
- Filter posts based on your criteria
- Send each post to OpenAI for analysis
- Save results to a timestamped JSON file
- Log the run details including API usage and costs
- Located in
summaries/YYYY-MM-DD/
directories - Named:
summary-YYYY-MM-DD_HH-mm-ss.json
- Contains array of analyzed posts with:
- Post metadata (id, title, URL, author, subreddit, timestamp, comments count)
- Full post content
- AI-generated analysis
- Sentiment classification (enhanced categories)
- Solution quality assessment
- Business opportunity score (1-5)
- Key pain points array
- Top comments analyzed
- Analysis timestamp
- Located in
summaries/YYYY-MM-DD/
directories - Named:
analysis-YYYY-MM-DD_HH-mm-ss.md
- Contains:
- High-opportunity posts table (score 4-5)
- Validated pain points by subreddit
- Sentiment distribution statistics
- Key insights by community (ClaudeAI, OpenAI/ChatGPT, Perplexity)
- Cross-platform opportunities
log.txt
: Tracks each run with:- Timestamp
- Summary filename
- API call counts (Reddit + OpenAI)
- Posts analyzed
- Ordering logic and subreddits
- Token usage and costs
{
"id": "1abcdef",
"title": "Help with automation shortcut",
"url": "https://www.reddit.com/r/shortcuts/comments/...",
"author": "username",
"subreddit": "shortcuts",
"created_utc": 1716168000,
"description": "I'm trying to create a shortcut that...",
"comments": 15,
"analysis": "The user is attempting to automate...",
"sentiment": "unsolved_problem",
"solution_quality": "none",
"opportunity_score": 4,
"key_pain_points": [
"Cannot trigger shortcuts based on app notifications",
"No way to automate clipboard management",
"Limited integration with third-party apps"
],
"comments_analyzed": [
{
"author": "helper123",
"body": "I've been looking for this too...",
"score": 25
}
],
"analysis_timestamp": "2025-05-20T00:14:30-0400"
}
- Enhanced comment analysis: Now fetches and analyzes top 10 comments per post to identify existing solutions and community validation
- Business opportunity scoring: Added 1-5 scale rating for each post's business potential
- Improved sentiment analysis: Expanded from basic categories to business-focused classifications
- Markdown analysis reports: Automatically generates business insights grouped by AI community
- Solution quality tracking: Identifies whether solutions exist and their completeness
- Key pain points extraction: Extracts up to 3 specific problems from each post
- Modified output structure to organize summaries by date in
summaries/YYYY-MM-DD/
directories - Updated to use GPT-4.1-mini model for cost efficiency
- No current known issues
- This is a local-only project with no GitHub issues tracked
This is a personal utility script for analyzing Reddit posts to identify business opportunities and pain points across AI communities. The project is functional and being used for product research and opportunity analysis.
This project is licensed under the GNU General Public License v3.0 (GPL-3.0). See LICENSE.md for details.
This means you are free to:
- Use, modify, and distribute this software
- Any derivative work must also be licensed under GPL-3.0
- You must include the source code when distributing
- You must state any changes made to the code
Please also respect Reddit's API terms of service and rate limits when using this tool.
Keep your .env
file private as it contains sensitive API credentials. The .gitignore
file is configured to exclude it from version control.