Skip to main content

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

Workflow preview

Workflow preview
100%
Analyze Legal Documents with GPT & o4-mini plus Gmail & Google Sheets preview
Open on n8n.io

Important notice

This workflow is provided as-is. Please review and test before using in production.

1. Workflow Overview

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 result...

Best for

  • AI Summarization automation workflows
  • Multimodal AI automation workflows
  • advanced n8n builders looking for reusable templates

Tools used

n8n-nodes-base.extractfromfile, n8n-nodes-base.webhook, @n8n/n8n-nodes-langchain.agent, @n8n/n8n-nodes-langchain.lmchatopenai, n8n-nodes-base.gmail, n8n-nodes-base.code, @n8n/n8n-nodes-langchain.chainllm, n8n-nodes-base.respondtowebhook

Source and attribution

This workflow is cataloged by N8N Workflows and links back to its original n8n.io source page by Swot.AI.

Original n8n.io source

1.1 Workflow description

Title
Analyze Legal Documents with GPT & o4-mini plus Gmail & Google Sheets
Workflow name
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 Needed

  • OpenAI API key (for Chat Model + Agent)

  • Gmail account (OAuth2)

  • Google Sheets account (OAuth2)

🔹 Example Use Case

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

1.2 Logical Blocks

This catalog entry is organized from the workflow JSON. The node-level section below shows the executable blocks available for review before importing the template.

2. Block-by-Block Analysis

Block 1 - Extract from File

Type / Role
n8n-nodes-base.extractFromFile - extractFromFile
Config choices
Version 1

Block 2 - Webhook

Type / Role
n8n-nodes-base.webhook - webhook
Config choices
Version 2

Block 3 - AI Agent

Type / Role
@n8n/n8n-nodes-langchain.agent - agent
Config choices
Version 2

Block 4 - OpenAI Chat Model

Type / Role
@n8n/n8n-nodes-langchain.lmChatOpenAi - lmChatOpenAi
Config choices
Version 1.2

Block 5 - Gmail1

Type / Role
n8n-nodes-base.gmail - gmail
Config choices
Version 2.1

Block 6 - Code

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 7 - OpenAI Chat Model1

Type / Role
@n8n/n8n-nodes-langchain.lmChatOpenAi - lmChatOpenAi
Config choices
Version 1.2

Block 8 - Basic LLM Chain

Type / Role
@n8n/n8n-nodes-langchain.chainLlm - chainLlm
Config choices
Version 1.7

Block 9 - Code1

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 10 - Respond to Webhook

Type / Role
n8n-nodes-base.respondToWebhook - respondToWebhook
Config choices
Version 1.3

Block 11 - Google Sheets

Type / Role
n8n-nodes-base.googleSheets - googleSheets
Config choices
Version 4.6

Block 12 - Sticky Note1

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 13 - Sticky Note2

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 14 - Sticky Note

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 15 - Sticky Note3

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 16 - Sticky Note4

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 17 - Sticky Note5

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 18 - Sticky Note6

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

3. Summary Table

Workflow Analyze Legal Documents with GPT & o4-mini plus Gmail & Google Sheets
Complexity advanced
Nodes 18
Categories AI Summarization, Multimodal AI
Author Swot.AI
Published 19 Aug 2025

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/7610/7610.json as the source template for this automation.

  2. 2. Import the template into n8n

    Open n8n, import the downloaded JSON, and review each node before activating the workflow.

  3. 3. Configure credentials and variables

    Replace placeholder credentials, API keys, webhook URLs, account IDs, and environment-specific values with your own settings.

  4. 4. Test with sample data

    Run the workflow manually or in a staging workspace, inspect node output, and confirm downstream systems receive the expected data.

  5. 5. Activate and monitor

    Enable the workflow only after testing, then monitor executions, errors, and rate limits during the first production runs.

5. General Notes & Resources

Review imported nodes carefully before activation. This catalog entry is intended to help you inspect the workflow structure, understand required services, and find related templates faster.

Node names, credentials, schedules, webhook paths, and external service limits may need adjustment for your workspace.

Frequently asked questions

What does Analyze Legal Documents with GPT & o4-mini plus Gmail & Google Sheets do?

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 result...

What do I need before importing this workflow?

Review the workflow JSON, configure any required credentials in n8n, and test the automation in a safe workspace before using it in production.

Can I customize this workflow?

Yes. Use the block-by-block analysis and the downloadable JSON to inspect each node, then adjust credentials, prompts, schedules, filters, or destinations for your AI Summarization, Multimodal AI use case.