Quick overview
This workflow runs every weekday morning (JST) to check a Google Sheets stock watchlist, fetch recent TDnet disclosure PDFs via a TDnet web API, summarize and classify them with Google Gemini, then post a digest (and high-impact alerts) to Slack while logging results and errors back to Google Sheets.
How it works
- Runs on a weekday cron schedule at 08:30 JST, computes a lookback window that expands over weekends/holidays, and skips the run entirely if today is configured as a market holiday.
- Reads the stock watchlist from Google Sheets, normalizes and de-duplicates securities codes, and stops with an error if no valid active codes are found.
- Queries the TDnet endpoint once per code, flattens results, and keeps only disclosures published within the computed JST time window.
- Reads the disclosure log from Google Sheets and filters out disclosures that were already logged so reruns don’t repost the same items.
- Downloads each new disclosure PDF, extracts text (falling back to title-only when extraction fails), and sends the content to Google Gemini to return a structured category, impact, direction, and 3-line Japanese/English summaries.
- Appends the enriched disclosure entries to the Google Sheets disclosure log, posts a grouped digest message to the configured Slack channel, and sends an additional Slack alert for any high-impact disclosure.
- Logs TDnet fetch or Gemini summarization errors to a Google Sheets error log and posts a single aggregated error alert to Slack.
Setup
- Create a Google Sheets spreadsheet with three tabs for a watchlist (with at least code/name/active columns), a disclosure log, and an error log.
- Add Google Sheets credentials, a Google Gemini API credential (Google Gemini/Vertex connection used by the Gemini chat model), and Slack credentials.
- In the configuration step, set the watchlist/log/error sheet URLs, the Slack channel name, the TDnet list endpoint template, and optionally holidays (YYYY-MM-DD) plus limits like lookback hours and max disclosures per run.