Skip to content

Varnan-Tech/hackernews-intel

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

hackernews-intel

hackernews-intel

Monitor Hacker News for keywords. Get a Slack alert every time a new post matches your topics, without duplicates. Run it manually, on a cron schedule, or via GitHub Actions.

What It Does

  • Fetches new posts from HN using the free Algolia search API (no API key needed)
  • Checks each match against a local SQLite cache and never alerts on the same post twice
  • Sends a Slack notification with title, URL, points, and comment count
  • Supports dry-run mode to preview matches without sending alerts
  • Configurable lookback window, minimum points threshold, and comment inclusion

Requirements

Requirement Purpose Where to Get It
HN_KEYWORDS Keywords to monitor Set in .env, comma-separated list
SLACK_WEBHOOK Slack alerts https://api.slack.com/apps, Incoming Webhooks
Node.js 20+ Running the script https://nodejs.org

No API key needed for Hacker News. The HN Algolia API is free and public.

Setup

1. Install dependencies

cd hackernews-intel
npm install

2. Configure environment variables

cp .env.example .env

Edit .env:

HN_KEYWORDS=claude code,LLM agents,deno runtime
SLACK_WEBHOOK=https://hooks.slack.com/services/your/webhook/url
HN_MIN_POINTS=0

3. Create a Slack webhook

  1. Go to https://api.slack.com/apps and create or select your app
  2. Enable "Incoming Webhooks" in the app settings
  3. Add a webhook to your workspace and select the target channel
  4. Copy the webhook URL (starts with https://hooks.slack.com/services/)
  5. Set it as SLACK_WEBHOOK in .env

How to Use

Preview the last 7 days without sending alerts:

npm run dry-run:week
# or
node scripts/monitor-hn.js --dry-run --days=7

Live run:

npm run monitor
# or
node scripts/monitor-hn.js

Schedule via cron (every 4 hours):

crontab -e
# Add:
0 */4 * * * cd /path/to/hackernews-intel && node scripts/monitor-hn.js >> /tmp/hn-intel.log 2>&1

Schedule via GitHub Actions:

name: HN Intel Monitor
on:
  schedule:
    - cron: '0 */4 * * *'
  workflow_dispatch:
jobs:
  monitor:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: '20'
      - run: npm install
      - run: node scripts/monitor-hn.js
        env:
          HN_KEYWORDS: ${{ secrets.HN_KEYWORDS }}
          SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}

Add HN_KEYWORDS and SLACK_WEBHOOK as repository secrets.

Slack Alert Format

Each alert looks like:

Story Title Here
47 points  23 comments  authorname
Keyword: claude code  |  HN discussion

Options

Variable Default Purpose
HN_KEYWORDS required Comma-separated keywords
SLACK_WEBHOOK required Slack Incoming Webhook URL
HN_MIN_POINTS 0 Minimum points to alert
HN_INCLUDE_COMMENTS false Also monitor HN comments
HN_DB_PATH ./hn-intel.db SQLite cache file path

CLI Flags

Flag Purpose
--dry-run Preview matches without sending Slack alerts
--days=N Lookback window for the first run (default: 1)
--reset Clear the cache and start fresh

GitHub Actions Note

GitHub Actions does not persist files between workflow runs. The SQLite cache resets on each run, and the script re-fetches the last 1 day of posts every time. Posts from the previous run will be alerted again.

To fix this, either:

  • Store hn-intel.db in an S3 bucket and download/upload it around the script run
  • Use a self-hosted runner with persistent storage
  • Use a cron job on your own machine instead

Project Structure

hackernews-intel/
├── SKILL.md
├── README.md
├── .env.example
├── package.json
├── evals/
│   └── evals.json
└── scripts/
    └── monitor-hn.js

License

MIT

About

Monitors Hacker News for posts and comments matching your keywords. Surfaces relevant threads, scores them by relevance, and summarizes key discussion points.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors