Email Categorization and Tracking using OpenRouter AI and Google Sheets - n8n Workflow

Use this powerful n8n workflow to automatically monitor incoming emails, categorize their content using an OpenRouter AI agent, and track key metrics in Google Sheets. Ideal n8n templates for ops.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

Business Operations teams needing to automatically categorize inbound support or sales emails.
Automation Specialists looking for advanced n8n templates involving AI parsing and conditional database logic.
Users aiming to leverage low-cost AI models via OpenRouter within an n8n workflow.
Anyone seeking a robust email processing n8n node solution.

Overview

Manually sorting and categorizing incoming business emails can be time-consuming and prone to human error. This sophisticated n8n workflow solves this by instantly analyzing new emails using a powerful AI agent, determining the email's category (e.g., 'Support Request', 'Billing Inquiry', 'Sales Lead'), and automatically updating a master Google Sheet.

This setup provides immediate insights into request volume distribution without requiring human intervention. By using the AI Agent n8n node with OpenRouter, you gain highly accurate classification, ensuring that your data tracking in Google Sheets is always up-to-date. This specific n8n workflow demonstrates a best-practice approach for merging communications, artificial intelligence, and data logging in one seamless system.

How it Works

This automation starts immediately when the initial n8n trigger fires upon receiving a new email, beginning the data processing pipeline:


  1. Email Ingestion: The Email Trigger (IMAP) n8n trigger monitors a specified email inbox for new messages and passes the raw content forward.

  2. Initial Data Check: The email data first flows to the Get row(s) in sheet Google Sheets n8n node, typically used here to load configuration details or existing category lists needed for the AI context.

  3. AI Analysis: The data is passed to the AI Agent n8n node. This agent is configured to use the oAI OSS (OpenRouter) language model and the Category & Request structured output parser. It processes the email body and determines a standardized category and a summary of the request.

  4. Category Lookup: The workflow then uses the Find Category Google Sheets n8n node to check if the category identified by the AI already exists in the tracking sheet.

  5. Conditional Routing: An If n8n node evaluates the lookup result:

TRUE Path (Category Found): If the category exists, the data is prepared using the Edit Fields n8n node, and the Update Request Count Google Sheets n8n node increments the counter associated with that category.
FALSE Path (New Category): If the category is new, the Append row in sheet Google Sheets n8n node creates a new entry, initializing its count to one. This entire process forms a highly efficient n8n workflow for intelligent email management.

Installation Guide

To deploy this expert n8n workflow, follow these setup steps:


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

  2. IMAP Trigger Setup: Configure the Email Trigger (IMAP) n8n node with your email server credentials (hostname, port, username, password) and specify the folder to monitor.

  3. Google Sheets Credentials: Create and link your Google Sheets credential to all Google Sheets n8n node instances. Ensure the sheet has columns suitable for Category Name and Count.

  4. OpenRouter/AI Configuration: Set up the credentials for the oAI OSS n8n node, which requires an OpenRouter API key. Ensure the AI Agent is correctly configured with a system prompt guiding it to categorize the incoming email content.

  5. Activate: Save the n8n workflow and click 'Activate'. The n8n trigger will now begin monitoring for new emails.

Node Details

Email Trigger (IMAP): The initial n8n trigger. It monitors a specified email account via the IMAP protocol, starting the workflow execution whenever a new email is detected in the monitored folder.
Google Sheets (Get row(s) in sheet / Find Category / Update Request Count / Append row in sheet): These multiple Google Sheets n8n node instances handle all data persistence and lookup logic. They are responsible for reading existing categories, checking if a new category needs creation, and updating the request count.
AI Agent: The orchestration n8n node that manages the AI process. It takes the email data, uses the language model to generate structured output, and passes the result to the subsequent steps.
oAI OSS (OpenRouter Chat): The core Language Model provider. This n8n node connects to OpenRouter to utilize various OSS models for cost-effective, high-quality categorization and summarization based on the prompt.
Category & Request (Structured Output Parser): This n8n node ensures that the AI's output is strictly formatted (e.g., as JSON with defined fields for 'category' and 'request_summary'), making it reliable for the downstream Google Sheets n8n node operations.
If: A critical flow control n8n node. It directs the workflow based on whether the AI-identified category already exists in the Google Sheet, enabling correct conditional logic for updating vs. appending data.

Related n8n Workflows

Paid

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

Featured*