Quick overview
This workflow watches a Google Drive folder for new PDF contracts, extracts their text, analyzes them with OpenAI, Anthropic Claude, or Google Gemini to produce a structured risk assessment, logs the results to Google Sheets, and sends a Gmail alert when the risk score crosses a threshold.
How it works
- Triggers when a new file is created in a specified Google Drive folder.
- Filters events to continue only when the uploaded file is a PDF.
- Downloads the PDF from Google Drive, extracts its text, and trims the content to a configurable maximum length.
- Sends the contract text to the selected AI provider (OpenAI, Anthropic Claude, or Google Gemini) to extract structured contract fields, risk flags, a summary, and a 0–100 risk score.
- Normalizes the AI output into a single flat record with a calculated risk level and an alert decision based on your threshold.
- Appends the normalized analysis as a new row in a Google Sheets tab.
- Sends a formatted Gmail alert email with the summary and risk flags when the contract meets or exceeds the risk threshold.
Setup
- Connect credentials for Google Drive, Google Sheets, and Gmail in n8n.
- Add credentials for one AI provider you plan to use: OpenAI, Anthropic, or Google Gemini.
- Select the Google Drive folder to watch and update the Configuration values (aiProvider, googleSheetId, sheetTabName, alertEmail, riskAlertThreshold, and maxCharacters).
- Create or choose a Google Sheets spreadsheet and ensure the target tab name (for example, “Contracts”) exists or matches the configured sheetTabName.