Quick Overview
This workflow runs daily to fetch npm package download trends via an Apify actor, scores each package with rules plus OpenAI, stores results in Google Sheets, and sends hot alerts to Slack for approval and warm digests by Gmail, with a weekly Gmail report and Slack error alerts.
How it works
- Runs on a daily schedule (or manual trigger), and on Mondays it switches to a weekly reporting path.
- For daily runs, starts an Apify actor run for npm download trends, then waits and polls the Apify API until the run succeeds or fails.
- Fetches the Apify dataset items, validates required fields, and deduplicates records against prior runs to avoid repeat alerts.
- Scores each package’s momentum using download trend thresholds and other signals, then uses OpenAI to generate a structured fit score, summary, verdict, and red flags and blends the AI and rule scores into a final tier.
- Upserts all scored rows into Google Sheets and routes results by tier.
- Sends hot-tier packages to Slack as a single approval message and writes the approve/dismiss decision back to Google Sheets, while warm-tier packages are emailed as an HTML digest via Gmail and cold-tier packages remain in the sheet only.
- For weekly runs, reads the last 7 days of rows from Google Sheets and emails a weekly HTML summary via Gmail.
Setup
- Create an Apify token and add an HTTP Header Auth credential (Authorization: Bearer <token>) for the Apify HTTP requests.
- Connect Google Sheets, create a tab matching the workflow’s columns, and set the Google Sheet ID and tab name in the Config node.
- Add an OpenAI credential (or replace the chat model) and ensure the workflow can call the selected model.
- Connect Slack and set the target channel ID in Config (and in the error-alert Slack node if you use a separate alerts channel).
- Connect Gmail and set the digest recipient email address in Config for both the daily warm digest and the weekly report.
- Update the watched package list, Apify actor input, and scoring thresholds in Config, then run once manually before activating the schedules.