Skip to main content

Parse & track orders from email with Gemini/GPT & Notion database sync

Workflow preview

Workflow preview
100%
Parse & track orders from email with Gemini/GPT & Notion database sync preview
Open on n8n.io

Important notice

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

1. Workflow Overview

Automated Email Order Tracking System with AI Classification and Notion Sync Overview ️ Self Hosted Solution Required This workflow requires a self hosted n8n instance with active integrations for...

Best for

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

Tools used

n8n-nodes-base.gmailtrigger, @n8n/n8n-nodes-langchain.lmchatgooglegemini, @n8n/n8n-nodes-langchain.lmchatopenai, @n8n/n8n-nodes-langchain.outputparserstructured, n8n-nodes-base.notiontool, n8n-nodes-base.gmail, @n8n/n8n-nodes-langchain.agent, n8n-nodes-base.code

Source and attribution

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

Original n8n.io source

1.1 Workflow description

Title
Parse & track orders from email with Gemini/GPT & Notion database sync
Workflow name
Parse & track orders from email with Gemini/GPT & Notion database sync

Automated Email Order Tracking System with AI Classification and Notion Sync

Overview

⚠️ Self-Hosted Solution Required
This workflow requires a self-hosted n8n instance with active integrations for Gmail, Google Gemini AI, OpenAI, and Notion. API credentials and database IDs must be configured before use.


Template Image

Description

This intelligent automation system monitors your Gmail inbox for order-related emails, extracts key order information using AI, and automatically syncs the data to a Notion database for centralized order tracking. Perfect for individuals managing multiple e-commerce accounts or small businesses tracking customer orders across various platforms (Amazon, Noon, Namshi, etc.).

What This Workflow Does

  1. Email Monitoring: Continuously monitors Gmail inbox for new incoming emails
  2. Smart Classification: Uses AI to identify order-related emails (confirmations, shipping notifications, delivery updates)
  3. Intelligent Extraction: Parses email content to extract order details (order number, items, prices, status, delivery info)
  4. Database Synchronization: Automatically creates or updates Notion database records with order information
  5. Status Tracking: Monitors order progression through stages (Ordered → Shipped → Out for Delivery → Delivered)

Key Features

  • Multi-vendor support: Works with any e-commerce platform (Amazon, Noon, Carrefour, Namshi, etc.)
  • Duplicate prevention: Searches existing records before creating new entries
  • Smart updates: Only modifies records when order status actually changes
  • Status validation: Detects backward status changes (potential returns/reshipments)
  • Graceful error handling: Handles missing data and optional fields intelligently
  • Timestamped history: Maintains audit trail of all status changes

Technologies Used

  • Gmail Trigger: Email monitoring
  • JavaScript Code: Email content classification with pattern matching
  • Google Gemini AI / OpenAI: Natural language processing for order extraction
  • Structured Output Parser: JSON formatting and validation
  • Notion API: Database search, create, and update operations

Prerequisites

Before setting up this workflow, ensure you have:

  1. Self-hosted n8n instance (version 1.0.0 or higher)
  2. Gmail account with IMAP access enabled
  3. Google Gemini API key OR OpenAI API key
  4. Notion workspace with:
    • Integration access configured
    • Database created with the required schema (see below)
    • Integration token/API key

Notion Database Schema

Create a Notion database with the following properties:

Required Properties

Property Name Type Description
Name of the Item Title Product/item name
Order Number Text Unique order identifier
Quantity Number Number of items
Expected Date Date or Text Expected delivery date
Order Status Select Options: Ordered, Shipped, Out for Delivery, Delivered

Optional Properties (Recommended)

Property Name Type Description
Vendor Select E-commerce platform (Amazon, Noon, etc.)
Customer Name Rich Text Order recipient name
Price Number or Rich Text Item price
Order Total Number Total order amount
Currency Select Currency code (AED, USD, SAR, etc.)
Delivery Location Rich Text Delivery city/address
Notes Rich Text Status change history
Created Date Created Time Auto-populated by Notion
Last Updated Last Edited Time Auto-populated by Notion

Setup Instructions

Step 1: Import the Workflow

  1. Copy the workflow JSON from this template
  2. In your n8n instance, go to WorkflowsAdd WorkflowImport from File/URL
  3. Paste the JSON and click Import

Step 2: Configure Gmail Trigger

  1. Click on the Gmail Trigger node
  2. Click Create New Credential
  3. Follow the OAuth authentication flow to connect your Gmail account
  4. Configure trigger settings:
    • Trigger On: Message Received
    • Filters: (Optional) Add label filters to monitor specific folders

Step 3: Configure AI Model (Choose One)

Option A: Google Gemini AI
  1. Click on the Google Gemini AI Model node
  2. Click Create New Credential
  3. Enter your Gemini API key (obtain from Google AI Studio)
  4. Select model: gemini-1.5-pro or gemini-1.5-flash
Option B: OpenAI
  1. Click on the OpenAI Chat Model node
  2. Click Create New Credential
  3. Enter your OpenAI API key (obtain from OpenAI Platform)
  4. Select model: gpt-4o or gpt-4-turbo

Step 4: Update Email Classification Node

  1. Click on the Check Email Type node (JavaScript code)
  2. Review the classification patterns (pre-configured for common e-commerce emails)
  3. (Optional) Add custom keywords specific to your vendors

Step 5: Configure Notion Integration

5.1: Create Notion Integration
  1. Go to Notion Integrations
  2. Click New Integration
  3. Name it (e.g., "n8n Order Tracker")
  4. Select your workspace
  5. Copy the Internal Integration Token
5.2: Share Database with Integration
  1. Open your Notion order database
  2. Click ShareInvite
  3. Search for your integration name and select it
  4. Grant Edit permissions
5.3: Get Database ID
  1. Open your Notion database in browser
  2. Copy the database ID from the URL:
    https://notion.so/workspace/DATABASE_ID?v=...
                               ^^^^^^^^^^^^
    
5.4: Configure Notion Nodes
  1. Click on Search a database in Notion node

  2. Click Create New Credential

  3. Paste your Integration Token

  4. In the node parameters:

    • Database ID: Paste your database ID
    • Filter: Set to search by Order Number property
  5. Repeat credential setup for Create a database page in Notion and Update a database page in Notion nodes


Step 6: Update Agent Prompts

  1. Click on the Email Classification and Extraction Agent node

  2. Review the system prompt (pre-configured for common order emails)

  3. Update the {{$now}} variable if using a different timezone

  4. (Optional) Customize extraction rules for specific vendors

  5. Click on the Order Database Sync Agent node

  6. Replace {{notion_database_id}} with your actual database ID in the prompt

  7. Review status handling logic


Step 7: Test the Workflow

  1. Click Execute Workflow to activate it
  2. Send yourself a test order confirmation email
  3. Monitor the execution:
    • Check if email was classified correctly
    • Verify extraction output in the AI agent node
    • Confirm Notion database was updated
  4. Review your Notion database for the new/updated record

Step 8: Activate for Production

  1. Click Active toggle in the top-right corner
  2. The workflow will now run automatically for new emails
  3. Monitor executions in the Executions tab

Workflow Node Descriptions

Email Trigger

Monitors Gmail inbox for new incoming emails and triggers the workflow when a message is received.

Check Email Type

JavaScript code node that analyzes email content using pattern matching to identify order-related emails based on keywords, order numbers, and shipping terminology.

Email Router (IF Node)

Routes emails based on classification results:

  • TRUE branch: Order-related emails proceed to extraction
  • FALSE branch: Non-order emails are filtered out (no action)

Email Classification and Extraction Agent

AI-powered parser using Google Gemini or OpenAI to extract structured order information:

  • Order number, items, prices, quantities
  • Order status (Ordered/Shipped/Out for Delivery/Delivered)
  • Customer name, delivery location, expected dates
  • Vendor identification

Structured Output Parser

Validates and formats AI extraction output into clean JSON for downstream processing.

Search a database in Notion

Queries the Notion database by order number to check if a record already exists, preventing duplicates.

Order Database Sync Agent

Intelligent database manager that decides whether to create new records or update existing ones based on search results and status comparison.

Create a database page in Notion

Adds new order records to Notion when no existing record is found.

Update a database page in Notion

Modifies existing records when order status changes, appending timestamped notes for audit history.

No Action Taken

Terminates workflow branch for non-order emails with no further processing.


Customization Options

Add More Vendors

Edit the Check Email Type node to add vendor-specific keywords:

const customVendors = [
  'your-vendor-name',
  'vendor-domain.com'
];

Modify Status Values

Update the Email Classification and Extraction Agent prompt to add custom status values or change status progression logic.

Add Email Notifications

Insert a Send Email node after database sync to receive notifications for status changes.

Filter by Labels

Configure Gmail Trigger to monitor only specific labels (e.g., "Orders", "Shopping").

Multi-Database Support

Duplicate the Notion sync section to route different vendors to separate databases.


Troubleshooting

Email not being classified as order

  • Check the Check Email Type node output
  • Add vendor-specific keywords to the classification patterns
  • Review email content for order indicators

AI extraction returning empty data

  • Verify AI model credentials are valid
  • Check if email content is being passed correctly
  • Review the extraction prompt for compatibility with email format

Notion database not updating

  • Confirm integration has edit permissions on the database
  • Verify database ID is correct in all Notion nodes
  • Check that property names in the workflow match your Notion schema exactly

Duplicate records being created

  • Ensure Search a database in Notion node is filtering by Order Number
  • Verify the search results are being evaluated correctly in the sync agent

Status not updating

  • Check if the Order Database Sync Agent is comparing current vs new status
  • Review the status comparison logic in the agent prompt

Performance Considerations

  • Email Volume: This workflow processes each email individually. For high-volume inboxes, consider adding filters or label-based routing.
  • AI Costs: Each email classification uses AI tokens. Monitor your API usage and costs.
  • Rate Limits: Notion API has rate limits (3 requests/second). The workflow handles this gracefully with built-in error handling.

Privacy & Security

  • All email content is processed through AI APIs (Google/OpenAI) - review their privacy policies
  • Notion data is stored in your workspace with your configured permissions
  • No data is stored or logged outside your n8n instance, AI provider, and Notion workspace
  • Consider using self-hosted AI models for sensitive order information

Support & Contributions

Found a bug or have a suggestion? Please open an issue or contribute improvements to this template!


License

This template is provided as-is under the MIT License. Feel free to modify and distribute as needed.


Credits

Created for the n8n community to streamline e-commerce order tracking across multiple platforms.

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 - Gmail Trigger

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

Block 2 - Google Gemini Chat Model

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

Block 3 - OpenAI Chat Model

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

Block 4 - Structured Output Parser

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

Block 5 - Create a database page in Notion

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

Block 6 - Update a database page in Notion

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

Block 7 - Send a message

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

Block 8 - Email Classification and Extraction Agent

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

Block 9 - Order Database Sync Agent

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

Block 10 - Check Email Type

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

Block 11 - Sticky Note

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

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 Note3

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

Block 15 - Sticky Note4

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

Block 16 - Sticky Note5

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

Block 17 - Sticky Note6

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

Block 18 - No action taken

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

Block 19 - Sticky Note7

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

Block 20 - Email Router

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

Block 21 - Search a page in Notion

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

3. Summary Table

Workflow Parse & track orders from email with Gemini/GPT & Notion database sync
Complexity advanced
Nodes 21
Categories Document Extraction, AI RAG
Author Jameson Kanakulya
Published 15 Oct 2025

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/9689/9689.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 Parse & track orders from email with Gemini/GPT & Notion database sync do?

Automated Email Order Tracking System with AI Classification and Notion Sync Overview ️ Self Hosted Solution Required This workflow requires a self hosted n8n instance with active integrations for...

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 RAG use case.