Skip to main content

πŸŽ“ How to transform unstructured email data into structured format with AI agent

Workflow preview

Workflow preview
100%
πŸŽ“ How to transform unstructured email data into structured format with AI agent preview
Open on n8n.io

Important notice

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

1. Workflow Overview

This workflow automates the process of extracting structured, usable information from unstructured email messages across multiple platforms. It connects directly to Gmail , Outlook , and IMAP accou...

Best for

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

Tools used

n8n-nodes-base.gmailtrigger, @n8n/n8n-nodes-langchain.lmchatopenai, @n8n/n8n-nodes-langchain.outputparserstructured, n8n-nodes-base.datatable, n8n-nodes-base.emailreadimap, n8n-nodes-base.microsoftoutlooktrigger, @n8n/n8n-nodes-langchain.agent, n8n-nodes-base.stickynote

Source and attribution

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

Original n8n.io source

1.1 Workflow description

Title
πŸŽ“ How to transform unstructured email data into structured format with AI agent
Workflow name
πŸŽ“ How to transform unstructured email data into structured format with AI agent

This workflow automates the process of extracting structured, usable information from unstructured email messages across multiple platforms.

It connects directly to Gmail, Outlook, and IMAP accounts, retrieves incoming emails, and sends their content to an AI-powered parsing agent built on OpenAI GPT models.

The AI agent analyzes each email, identifies relevant details, and returns a clean JSON structure containing key fields:

  • From – sender’s email address
  • To – recipient’s email address
  • Subject – email subject line
  • Summary – short AI-generated summary of the email body

The extracted information is then automatically inserted into an n8n Data Table, creating a structured database of email metadata and summaries ready for indexing, reporting, or integration with other tools.


Key Benefits

  • βœ… Full Automation: Eliminates manual reading and data entry from incoming emails.
  • βœ… Multi-Source Integration: Handles data from different email providers seamlessly.
  • βœ… AI-Driven Accuracy: Uses advanced language models to interpret complex or unformatted content.
  • βœ… Structured Storage: Creates a standardized, query-ready dataset from previously unstructured text.
  • βœ… Time Efficiency: Processes emails in real time, improving productivity and response speed. *βœ… Scalability: Easily extendable to handle additional sources or extract more data fields.

How it works

This workflow automates the transformation of unstructured email data into a structured, queryable format. It operates through a series of connected steps:

  1. Email Triggering: The workflow is initiated by one of three different email triggers (Gmail, Microsoft Outlook, or a generic IMAP account), which constantly monitor for new incoming emails.
  2. AI-Powered Parsing & Structuring: When a new email is detected, its raw, unstructured content is passed to a central "Parsing Agent." This agent uses a specified OpenAI language model to intelligently analyze the email text.
  3. Data Extraction & Standardization: Following a predefined system prompt, the AI agent extracts key information from the email, such as the sender, recipient, subject, and a generated summary. It then forces the output into a strict JSON structure using a "Structured Output Parser" node, ensuring data consistency.
  4. Data Storage: Finally, the clean, structured data (the from, to, subject, and summarize fields) is inserted as a new row into a specified n8n Data Table, creating a searchable and reportable database of email information.

Set up steps

To implement this workflow, follow these configuration steps:

  1. Prepare the Data Table:

    • Create a new Data Table within n8n.
    • Define the columns with the following names and string type: From, To, Subject, and Summary.
  2. Configure Email Credentials:

    • Set up the credential connections for the email services you wish to use (Gmail OAuth2, Microsoft Outlook OAuth2, and/or IMAP). Ensure the accounts have the necessary permissions to read emails.
  3. Configure AI Model Credentials:

    • Set up the OpenAI API credential with a valid API key. The workflow is configured to use the model, but this can be changed in the respective nodes if needed.
  4. Connect the Nodes:

    • The workflow canvas is already correctly wired. Visually confirm that the email triggers are connected to the "Parsing Agent," which is connected to the "Insert row" (Data Table) node. Also, ensure the "OpenAI Chat Model" and "Structured Output Parser" are connected to the "Parsing Agent" as its AI model and output parser, respectively.
  5. Activate the Workflow:

    • Save the workflow and toggle the "Active" switch to ON. The triggers will begin polling for new emails according to their schedule (e.g., every minute), and the automation will start processing incoming messages.

Need help customizing?

Contact me for consulting and support or add me on Linkedin.

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 - OpenAI Chat Model

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

Block 3 - Structured Output Parser

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

Block 4 - OpenAI Chat Model1

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

Block 5 - Insert row

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

Block 6 - Email Trigger (IMAP)

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

Block 7 - Microsoft Outlook Trigger

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

Block 8 - Parsing Agent

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

Block 9 - Sticky Note

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

Block 10 - Sticky Note1

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

Block 11 - Sticky Note2

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

Block 12 - Sticky Note3

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

Block 13 - When chat message received

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

Block 14 - Email Agent

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

Block 15 - Emails

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

Block 16 - Google Gemini Chat Model

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

3. Summary Table

Workflow πŸŽ“ How to transform unstructured email data into structured format with AI agent
Complexity advanced
Nodes 16
Categories Document Extraction, AI Summarization
Author Davide
Published 23 Oct 2025

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/10086/10086.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 πŸŽ“ How to transform unstructured email data into structured format with AI agent do?

This workflow automates the process of extracting structured, usable information from unstructured email messages across multiple platforms. It connects directly to Gmail , Outlook , and IMAP accou...

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.