Automatic Invoice Detection & Task Creation via AI and Gmail - n8n Workflow

Use this powerful n8n workflow to automatically scan Gmail for invoices, extract due dates and amounts using AI (OpenAI), and create immediate reminders in Google Tasks.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?


  • Small business owners managing incoming vendor bills.

  • Freelancers or consultants who receive frequent expense and payment notifications.

  • Users looking for advanced, practical n8n templates integrating AI for structured data extraction.

  • Anyone who needs reliable financial reminders created automatically by an n8n workflow.

Overview

This robust n8n workflow addresses the common administrative headache of missed payments or delayed expense tracking by automating the entire invoice monitoring process. By utilizing a scheduled n8n trigger, the system regularly pulls unread emails from Gmail. The core of this automation is the AI Agent n8n node, powered by OpenAI, which intelligently analyzes the email body and subject line to determine if it contains critical invoice details.

If an invoice is confirmed, this powerful n8n template automatically extracts crucial metadata like the due date, amount, and sender. Finally, it uses the extracted data to create an actionable reminder in Google Tasks, labels the original email in Gmail with 'Invoice', and marks it as read. This strategic n8n workflow guarantees that financial obligations are immediately converted into trackable tasks, minimizing manual intervention and maximizing compliance.

How it Works

This comprehensive n8n workflow operates on a recurring schedule to monitor incoming financial documentation and convert it into actionable tasks.


  1. Scheduled Activation: The process begins with the Schedule n8n trigger, configured to run every hour, ensuring timely checking of new emails.

  2. Email Retrieval: The Gmail n8n node fetches all currently unread emails from the user's inbox.

  3. AI Analysis and Extraction: Each retrieved email is fed into the AI Agent n8n node. This node uses a specific, detailed prompt (linked to the OpenAI Chat Model) instructing it to analyze the email for invoice content. The goal is to output a structured JSON object containing the isinvoice status, duedate, and amountdue.

  4. Conditional Routing: The If n8n node checks the AI's output. If the isinvoice field is true, the process follows the success path; otherwise, it stops for that item using the 'No Operation' n8n node.

  5. Task Creation (True Path): The Google Tasks n8n node instantly creates a new reminder. The task title is dynamically generated using the extracted fields: Invoice from {{sender}} – ${{amountdue}} due {{duedate}}.

  6. Email Management: To maintain a clean inbox and record, subsequent Gmail n8n nodes perform two actions: they apply the 'Invoice' label to the recognized email and mark the email as read, completing the execution of this specific n8n workflow run.

Installation Guide

To set up and run this efficient n8n workflow template, follow these steps:


  1. Import: Copy the provided JSON data and paste it directly into your n8n canvas using the 'New' -> 'Import from JSON' function.

  2. Credentials Setup:

Gmail: Configure your Gmail credentials using OAuth2. This is necessary for the Get Unread Emails n8n node and the labeling/marking nodes.
OpenAI: Add your OpenAI API Key under API Credentials in n8n. This key powers the AI Agent n8n node.
* Google Tasks: Configure your Google Tasks credentials (OAuth2 is recommended) to allow the n8n node to create reminders.

  1. Gmail Label Preparation: Ensure you have a custom label named Invoice created in your Gmail account, as this n8n workflow relies on it for successful labeling.

  2. Activation: Ensure all connections are valid and then activate the n8n workflow. It is designed to run automatically based on the Schedule n8n trigger settings.

Node Details

Schedule Trigger n8n trigger: Initiates the n8n workflow every hour (configurable), ensuring continuous monitoring of your inbox.
Get Unread Emails (Gmail n8n node): Filters and retrieves only unread emails, minimizing processing time and scope for the subsequent AI step.
AI Agent (n8n node): Acts as the intelligent decision-maker. It is configured with a specific instruction prompt to classify emails as invoices and utilize the OpenAI Chat Model (gpt-4o) and a Structured Output Parser for reliable JSON data extraction of critical fields like duedate and amountdue.
If (n8n node): Controls the flow based on the AI's classification. It checks if is_invoice is true before proceeding to the task creation path.
Create a task (Google Tasks n8n node): Executes the primary action of the n8n workflow, creating a reminder using dynamic data expressions that pull the sender, amount, and due date directly from the AI output.
Add Label to Email (Gmail n8n node): Tags the processed email with the 'Invoice' label, facilitating quick identification in your Gmail archive.


  • Mark Email as read (Gmail n8n node): Completes the cleaning process by marking the email as read after the data has been successfully extracted and the task created.

Related n8n Workflows

Free

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

Automation nerd fueled by good coffee, deep curiosity, and clean flows.

Featured*