Automated Task Extraction from Email using GPT-4o and Supabase - n8n Workflow

Use this powerful n8n workflow to automatically extract structured tasks from Gmail using the ChatGPT-4o n8n node, ensuring data is deduplicated and saved efficiently into Supabase. Explore more n8n templates for productivity.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

Productivity experts who need to automate task creation directly from incoming emails.
Professionals managing a high volume of email who want actionable items prioritized.
Users looking for advanced n8n templates demonstrating AI and database integration (Supabase).
Developers seeking a robust, non-duplicate processing mechanism leveraging the schedule n8n trigger.

Overview

Managing actionable tasks hidden within lengthy emails can be time-consuming. This specific n8n workflow solves this productivity bottleneck by creating a smart, automated extraction system. It starts with a recurring n8n trigger, checks your Gmail inbox for new, unread messages, and prevents duplicate processing using a Supabase database check. If the email is new, it routes the content to the ChatGPT-4o n8n node, which uses sophisticated prompting to extract structured data—including task titles, due dates, estimated minutes, and whether the task requires deep work—in a clean JSON format. Finally, the processed data and the original email metadata are stored reliably in Supabase, ready for further action or analysis. This highly efficient n8n automation is a premium example of effective flow control using the powerful n8n node network.

How it Works

The entire process is initiated by the Trigger Workflow, a schedule n8n trigger, running at configured intervals (e.g., every few minutes).


  1. Email Acquisition: The flow immediately executes the Get Unread Emails from Inbox n8n node, fetching all messages marked as unread in the INBOX using the Gmail API.

  2. Batch Processing: The Loop Over Items n8n node ensures that each email is processed individually through the subsequent steps, which is crucial for handling per-item checks and API calls.

  3. Deduplication Check: For each email, the Get Email from Database Supabase n8n node checks if the email ID already exists in the Supabase emails table. This prevents wasting OpenAI credits and avoids re-processing old emails.

  4. Conditional Routing: The Check if Email in Database n8n node uses an IF condition to proceed only if the email ID was not found in Supabase (i.e., it's a new email).

  5. Prompt Generation: The Prepare ChatGPT Prompt code n8n node formats the email snippet into a structured prompt, instructing the AI to respond strictly in a required JSON task format or return null if no task is found.

  6. AI Extraction: The Extract Task Detail from Email OpenAI n8n node uses ChatGPT-4o's capability for JSON output to parse the email and return the structured task details.

  7. Data Persistence: The Insert Email Detail to Supabase HTTP Request n8n node handles the final action, inserting the original email metadata and the resulting GPT JSON summary into the Supabase table, utilizing upsert logic to ensure data integrity.

Installation Guide

To deploy this useful n8n workflow, follow these steps:


  1. Import: Copy the provided JSON data and import it into your n8n instance using the 'New' > 'Import from JSON' function.

  2. Credentials Setup:

Gmail: Configure your Gmail OAuth credential for the Get Unread Emails from Inbox n8n node.
OpenAI: Set up your OpenAI API key credential for the Extract Task Detail from Email n8n node.

  1. Supabase Configuration (HTTP Node): The workflow uses environment variables for Supabase access. You must define or replace these variables within the Insert Email Detail to Supabase HTTP Request n8n node:

SupabaseTaskManagementURI (Your Supabase project URL)
SupabaseTaskManagementANONKEY (Your Supabase public key)

  1. Database Prerequisite: Ensure your Supabase emails table exists and has a unique constraint on the emailid column to support the upsert functionality used in this n8n automation.

  2. Activation: Save the n8n workflow and toggle the 'Active' switch. The schedule n8n trigger will begin running at the specified intervals.

Node Details

This n8n workflow relies on several specialized n8n node types to achieve complex automation:

Trigger Workflow (Schedule n8n trigger)
Function: Initiates the n8n workflow execution on a time-based schedule.
Key Configuration: Set to run based on an interval, typically every few minutes, acting as the main n8n trigger.
Get Unread Emails from Inbox (Gmail n8n node)
Function: Fetches the raw source data for processing—all unread emails in the 'INBOX'.
Key Configuration: operation: getAll, filters: readStatus: unread, labelIds: [INBOX].
Loop Over Items (Split In Batches n8n node)
Function: Essential for flow control, ensuring the n8n workflow processes each email individually for subsequent database checks and API calls.
Get Email from Database (Supabase n8n node)
Function: Performs the critical deduplication step by querying the emails table using the current item's email ID.
Key Configuration: tableId: emails, conditions: emailid = current item's ID.
Check if Email in Database (IF n8n node)
Function: Determines if processing should continue to the AI step or if the email should be skipped.
Key Configuration: Passes if the previous Supabase n8n node output isEmpty() is true.
Extract Task Detail from Email (OpenAI n8n node)
Function: The core AI logic. Sends the email snippet to ChatGPT-4o for structured task extraction.
Key Configuration: modelId: chatgpt-4o-latest, jsonOutput: true.
Insert Email Detail to Supabase (HTTP Request n8n node)
Function: Stores the extracted task and email metadata into the Supabase database using the REST API with upsert logic.
Key Configuration: Method: POST, URL: uses URI variable with ?on
conflict=email_id, includes API Key in headers (Authorization and apikey).

Related n8n Workflows

Free

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

Senior product and solutions leader with deep technical expertise, commercial acumen, and proven leadership across VC- and PE-backed firms. I specialize in unifying product strategy, scaling cross-functional models, and incubating new opportunities. Skilled at crafting compelling narratives, driving GTM execution, and engaging externally with impact. I thrive on building teams and turning vision into value across the full product lifecycle.

Featured*