Skip to main content

Validate bills of lading, send Gmail replies, and post JSON with Google Gemini

Workflow preview

Workflow preview
100%
Validate bills of lading, send Gmail replies, and post JSON with Google Gemini preview
Open on n8n.io

1. Workflow Overview

Quick overview This workflow triggers on a Gmail message from a specific sender, extracts bill of lading data from an email attachment using Google Gemini, validates the extracted values with Pytho...

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/n8n-nodes-langchain.agent, n8n-nodes-base.httprequest, n8n-nodes-base.gmailtool, @n8n/n8n-nodes-langchain.lmchatgooglegemini, @n8n/n8n-nodes-langchain.outputparserstructured

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
Validate bills of lading, send Gmail replies, and post JSON with Google Gemini
Workflow name
Validate bills of lading, send Gmail replies, and post JSON with Google Gemini

Quick overview

This workflow triggers on a Gmail message from a specific sender, extracts bill of lading data from an email attachment using Google Gemini, validates the extracted values with Python, posts the structured JSON to a webhook URL, and replies to the sender with an HTML acceptance email.

How it works

  1. Triggers when a new Gmail email arrives from the configured sender and downloads the attached document.
  2. Uses Google Gemini to analyze the attachment and rewrite the bill of lading content into a structured Markdown format.
  3. Uses a second Google Gemini agent with a structured output schema to convert the Markdown into validated JSON fields for shipper, consignee, shipment details, and line items.
  4. Runs a Python validation that compares customer order package/weight values against the carrier line items and appends a validation result to the JSON.
  5. Sends the resulting JSON payload to an external HTTP webhook endpoint.
  6. Uses Google Gemini to draft an HTML acceptance reply email based on the validated data and sends it back to the original sender via Gmail.

Setup

  1. Connect your Gmail OAuth2 credentials and set the sender filter (and any other Gmail Trigger options) to match the emails you want to process.
  2. Add Google Gemini (PaLM) API credentials and confirm the selected Gemini models are available in your account.
  3. Ensure the incoming emails include a compatible bill of lading attachment and update the binary attachment property name if it differs from attachment_0.
  4. Replace the HTTP Request URL with your own endpoint that should receive the structured JSON payload.
  5. Review the structured JSON schema and the Python validation logic to match your required fields and matching rules before enabling the workflow.

Customization

  • Any LLM provider can do the task, change Gemini with any AI you can use

Additional info

This is an example of prompt chaining. It is an AI agent workflow that shows the benefit of chaining several LLMs together.

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 - AI Document Analyzer Agent

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

Block 8 - Post to Webhook API

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

Block 9 - AI Validation Agent

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

Block 10 - Send Gmail Message

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

Block 11 - Gemini Main Analysis 1

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

Block 12 - Gemini Fallback Analysis 1

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

Block 13 - Gemini Main Analysis 2

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

Block 14 - Gemini Fallback Analysis 2

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

Block 15 - Parse Structured Output

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

Block 16 - Validate Data with Code

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

Block 17 - Sticky Note4

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

3. Summary Table

Workflow Validate bills of lading, send Gmail replies, and post JSON with Google Gemini
Complexity advanced
Nodes 17
Categories Document Extraction, AI Summarization
Author David Grimm
Published 01 Jun 2026

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/16049/16049.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 Validate bills of lading, send Gmail replies, and post JSON with Google Gemini do?

Quick overview This workflow triggers on a Gmail message from a specific sender, extracts bill of lading data from an email attachment using Google Gemini, validates the extracted values with Pytho...

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.