Smart Shipping Prioritization Engine with Gemini - n8n Workflow

Automate shipping priority determination using Google Gemini within an n8n workflow. Analyze Google Sheets data and mark the highest priority order.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

Logistics and Warehouse Managers needing optimized shipment queues.
Businesses using n8n templates to implement intelligent operational decisions.
Users looking to build complex AI agents within an n8n workflow.
Developers seeking advanced examples of Google Sheets integration with AI.

Overview

This powerful n8n workflow solves the logistical challenge of manually prioritizing shipments. By leveraging the analytical capabilities of Google Gemini through the n8n agent framework, the system automatically reads a high-volume shipment sheet, applies complex, defined business logic (prioritizing based on age unless a cancellation risk is noted), and identifies the single most critical order. This specific n8n node configuration ensures quick decision-making, updating the sheet immediately, and providing instant feedback. Utilizing an n8n trigger to initiate this process allows for on-demand optimization, making this one of the most useful n8n templates for logistics operations.

How it Works

This n8n workflow is initiated by a manual Button n8n trigger. Once triggered, the flow immediately activates the core logic held within the AI Agent n8n node. This agent, configured with system instructions to prioritize both oldest orders and high-risk orders (based on the detalle column), interacts with two key tools: the Date & Time utility and the Shipping Google Sheets Tool, which provides real-time access to the order database. The AI Agent utilizes the Gemini Flash 2.5 model for interpretation and decision-making. The Structured Output Parser ensures the chosen shipment data is returned in a predictable JSON format. Finally, the n8n workflow performs two crucial actions: it uses a Google Sheets n8n node to Update the selected row, marking it as 'X' in the enviado column, and simultaneously uses a Respond to Webhook n8n node to instantly display the prioritized order details to the user or external screen that initiated the n8n trigger.

Installation Guide

To utilize this expert n8n workflow, follow these steps:


  1. Import: Copy the provided JSON and import it directly into your n8n instance using the 'New' -> 'Import from JSON' option. This immediately provides a foundational n8n template.

  2. Credentials: Set up credentials for Google Sheets (for the 'Shipping' tool and the 'Update' node) and connect a Google Gemini service account to the workflow. Ensure your credentials are valid before executing the n8n templates.

  3. Sheet Setup: Replace REPLACEWITHSHEETNAME and REPLACEWITHDOCID placeholders in both the 'Shipping' and 'Update' n8n node configurations. Your spreadsheet must contain columns like idEnvio, fechaOrden, nombre, direccion, detalle, and enviado for the n8n workflow to function correctly.

  4. Webhooks: Note the webhook ID and path generated by the 'Button' n8n trigger node for manual or external triggering.

Node Details

This n8n workflow relies on several specialized n8n nodes:

Button (n8n trigger): The starting point for the automation. It serves as a manual webhook trigger, allowing the n8n workflow to be executed on demand.
AI Agent: The core decision-making n8n node.
Function: Analyzes data from the Shipping sheet based on complex logic (age vs. cancellation risk), requiring a specific JSON output.
Key Configuration: Uses Gemini Flash 2.5 and relies on a specific systemMessage defining the priority rules.
Shipping (Google Sheets Tool):
Function: Provides the AI Agent with read access to the shipment order data within Google Sheets, acting as a functional tool within the n8n node ecosystem.
Key Configuration: Set to the target Document ID and Sheet Name.
Structured Output Parser:
Function: Ensures the AI Agent's output is strictly formatted into a consumable JSON structure, guaranteeing data integrity for subsequent n8n node operations.
Update (Google Sheets):
Function: Marks the single priority shipment selected by the AI as processed in the Google Sheet.
Key Configuration: Matches rows using idEnvio and sets the enviado column to 'X', dynamically referencing the output of the AI Agent n8n node.
Screen (Respond to Webhook):
Function: Provides immediate feedback, returning the identified priority shipment details via the originating n8n trigger webhook response.

Related n8n Workflows

Free

Nodes: 9 Nodes
Updated: December 26 2025
View all
Created by

Exploring the intersection of technology, subversion, and creative resistance. My work focuses on TinyML prototypes and LLM projects, pushing the boundaries of AI and embedded systems.

Featured*