Analyze Legal Documents with GPT & o4-mini plus Gmail & Google Sheets

Description

This workflow lets you upload a PDF document and automatically analyze it with AI. It extracts the text, summarizes the content, flags key clauses or risks, and then delivers the results via Gmail while also storing them in Google Sheets for tracking.

It's designed for legal, compliance, or contract review use cases, but can be adapted for any document analysis scenario.
Test it here: PDF Document Assistant

🔹 Instructions / Setup

  1. Webhook Input
  • Upload a PDF document by sending it to the webhook URL.
  1. Extract from File
  • The workflow extracts text from the uploaded PDF.
  1. Pre-processing (Code Node)
  • Cleans and formats extracted text to remove unwanted line breaks or artifacts.
  1. Basic LLM Chain (OpenAI)
  • Summarizes or restructures document content using OpenAI.

  • Adjust the prompt inside to fit your analysis needs (summary, risk flags, clause extraction).

  1. Post-processing (Code Node)
  • Further structures the AI ​​output into a clean format (JSON, HTML, or plain text).
  1. AI Agent (OpenAI)
  • Runs deeper analysis, answers questions, and extracts insights.
  1. Gmail
  • Sends the results to a recipient.

  • Configure Gmail credentials and set your recipient address.

  1. Google Sheets
  • Appends results to a Google Sheet for record-keeping or audits.
  1. Respond to Webhook
  • Sends a quick acknowledgment back to confirm the document was received.

🔹 Credentials Required

  • OpenAI API key (for Chat Model + Agent)

  • Gmail account (OAuth2)

  • Google Sheets accounts (OAuth2)

🔹 Example Use Case

Upload a contract PDF → workflow extracts clauses → AI flags risky terms → Gmail sends formatted summary → results stored in Google Sheets.

Do you want to automate your business?

Let's talk about your project