Quick overview
This workflow scans a Google Drive folder of contract PDFs on a weekly schedule, extracts key renewal terms from new documents using the Gemini API, stores and updates a contract registry in Google Sheets, and sends renewal alerts via Gmail and Slack plus a weekly digest email.
How it works
- Runs weekly (or manually for testing) and loads configuration values like Drive folder ID, Google Sheet ID, alert email, and Slack channel.
- Searches Google Drive for PDFs in the target folder and reads the current contract registry from Google Sheets.
- Compares Drive files to the registry to identify new contracts, then downloads each new PDF, extracts its text, and calls the Gemini API to extract structured contract terms.
- Appends extracted contract records to the Google Sheets Registry and combines new and existing contracts into a single list.
- Calculates days-to-renewal and assigns urgency tiers (90/60/30/notice_passed) with risk flags for short-notice auto-renewals, then filters contracts that have entered a new alert tier since the last run.
- For each alert due, builds a one-page renewal briefing, emails it via Gmail, posts a Slack notification, and updates the registry to record the last alerted tier.
- Builds a portfolio summary of tracked contracts, new contracts, alerts sent, and items needing review, emails the weekly digest via Gmail, and logs the run to a RunLog sheet in Google Sheets.
Setup
- Create a Google Sheet with a Registry tab containing columns: file_id, vendor_name, contract_title, start_date, end_date, auto_renewal, notice_period_days, annual_value, currency, termination_penalty, key_contact, last_alert_tier, status, added_date, and a RunLog tab with date, contracts_scanned, new_contracts, alerts_sent.
- Add Google Drive, Google Sheets, Gmail, and Slack credentials in n8n, and set a Slack channel to receive renewal notifications.
- Get a Gemini API key (Google AI Studio) and fill in the Workflow Configuration values for geminiApiKey, driveFolderId, registrySheetId, alertEmail, slackChannelId, and maxCharsPerContract.
- Put your contract PDFs into the configured Google Drive folder and run the workflow once manually to populate the registry and validate alerts and digest emails.