Skip to main content

Route and validate emailed documents with Gmail and Google Gemini

Workflow preview

Workflow preview
100%
Route and validate emailed documents with Gmail and Google Gemini preview
Open on n8n.io

1. Workflow Overview

Quick Overview This workflow monitors Gmail for unread emails from a specific sender, classifies attached documents with Google Gemini, then extracts and validates structured data for bills of ladi...

Best for

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

Tools used

n8n-nodes-base.stickynote, n8n-nodes-base.gmailtrigger, @n8n/n8n-nodes-langchain.googlegemini, n8n-nodes-base.httprequest, n8n-nodes-base.gmailtool, @n8n/n8n-nodes-langchain.lmchatgooglegemini, @n8n/n8n-nodes-langchain.outputparserstructured, n8n-nodes-base.switch

Source and attribution

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

Original n8n.io source

1.1 Workflow description

Title
Route and validate emailed documents with Gmail and Google Gemini
Workflow name
Route and validate emailed documents with Gmail and Google Gemini

Quick Overview

This workflow monitors Gmail for unread emails from a specific sender, classifies attached documents with Google Gemini, then extracts and validates structured data for bills of lading, invoices, and warranty claims, posts the results to an HTTP webhook endpoint, and replies to the sender with an HTML confirmation email.

How it works

  1. Triggers when an unread Gmail message arrives from the configured sender and downloads the email attachment.
  2. Uses Google Gemini to classify the attachment as a bill of lading, invoice, warranty claim, or other, while preserving the original binary file for downstream processing.
  3. Routes the flow by document type and uses Google Gemini to extract the document into a structured markdown representation.
  4. Uses a dedicated Google Gemini agent per document type to convert the extracted content into JSON that matches a predefined schema.
  5. Runs Python validation checks on the structured data (for example, totals matching line items) and adds a validation result to the payload.
  6. Posts the structured output to a configured HTTP webhook endpoint and uses a Google Gemini messaging agent to draft an HTML reply.
  7. Sends the generated reply back to the original email sender via Gmail.

Setup

  1. Connect a Gmail OAuth2 credential and set the Gmail trigger filters (sender, unread status) and ensure attachments are enabled for download.
  2. Connect a Google Gemini (PaLM) API credential and confirm the configured Gemini models are available for both extraction and the analysis/messaging agents.
  3. Update the HTTP Request node URL (and any required headers/authentication) to point to your target webhook or API endpoint.
  4. Review and adjust the structured output schemas and the Python validation rules to match the fields and business rules required for your bill of lading, invoice, and warranty claim formats.

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 - Sticky Note

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

Block 2 - Sticky Note1

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

Block 3 - Sticky Note2

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

Block 4 - Sticky Note3

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

Block 5 - When Email Received

Type / Role
n8n-nodes-base.gmailTrigger - gmailTrigger
Config choices
Version 1.4

Block 6 - Analyze Document with Gemini

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

Block 7 - Post to Webhook API

Type / Role
n8n-nodes-base.httpRequest - httpRequest
Config choices
Version 4.4

Block 8 - Send Gmail Message

Type / Role
n8n-nodes-base.gmailTool - gmailTool
Config choices
Version 2.2

Block 9 - Gemini Main Analysis 1

Type / Role
@n8n/n8n-nodes-langchain.lmChatGoogleGemini - lmChatGoogleGemini
Config choices
Version 1.1

Block 10 - Gemini Fallback Analysis 1

Type / Role
@n8n/n8n-nodes-langchain.lmChatGoogleGemini - lmChatGoogleGemini
Config choices
Version 1.1

Block 11 - Gemini Main Analysis 2

Type / Role
@n8n/n8n-nodes-langchain.lmChatGoogleGemini - lmChatGoogleGemini
Config choices
Version 1.1

Block 12 - Gemini Fallback Analysis 2

Type / Role
@n8n/n8n-nodes-langchain.lmChatGoogleGemini - lmChatGoogleGemini
Config choices
Version 1.1

Block 13 - Parse Structured Output

Type / Role
@n8n/n8n-nodes-langchain.outputParserStructured - outputParserStructured
Config choices
Version 1.3

Block 14 - Sticky Note4

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

Block 15 - Switch

Type / Role
n8n-nodes-base.switch - switch
Config choices
Version 3.4

Block 16 - Post to Webhook API1

Type / Role
n8n-nodes-base.httpRequest - httpRequest
Config choices
Version 4.4

Block 17 - Gemini Main Analysis

Type / Role
@n8n/n8n-nodes-langchain.lmChatGoogleGemini - lmChatGoogleGemini
Config choices
Version 1.1

Block 18 - Gemini Fallback Analysis

Type / Role
@n8n/n8n-nodes-langchain.lmChatGoogleGemini - lmChatGoogleGemini
Config choices
Version 1.1

Block 19 - Parse Structured Output1

Type / Role
@n8n/n8n-nodes-langchain.outputParserStructured - outputParserStructured
Config choices
Version 1.3

Block 20 - Post to Webhook API2

Type / Role
n8n-nodes-base.httpRequest - httpRequest
Config choices
Version 4.4

Block 21 - Gemini Main Analysis 3

Type / Role
@n8n/n8n-nodes-langchain.lmChatGoogleGemini - lmChatGoogleGemini
Config choices
Version 1.1

Block 22 - Gemini Fallback Analysis 3

Type / Role
@n8n/n8n-nodes-langchain.lmChatGoogleGemini - lmChatGoogleGemini
Config choices
Version 1.1

Block 23 - Parse Structured Output2

Type / Role
@n8n/n8n-nodes-langchain.outputParserStructured - outputParserStructured
Config choices
Version 1.3

Block 24 - AI Bill Of Laden Analyzer Agent

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

Showing the first 24 of 43 workflow blocks. Download the JSON for the full node graph.

3. Summary Table

Workflow Route and validate emailed documents with Gmail and Google Gemini
Complexity advanced
Nodes 43
Categories Document Extraction, AI Summarization
Author David Grimm
Published 08 Jun 2026

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/16181/16181.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 Route and validate emailed documents with Gmail and Google Gemini do?

Quick Overview This workflow monitors Gmail for unread emails from a specific sender, classifies attached documents with Google Gemini, then extracts and validates structured data for bills of ladi...

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 Document Extraction, AI Summarization use case.