Automatic email categorization & labeling in Zoho Mail with GPT-4o-mini
📧 AI-Powered Email Categorization & Labeling in Zoho Mail
This n8n template demonstrates how to use AI text classification to automatically categorize incoming emails in Zoho Mail and apply the correct label (e.g., Support, Billing, HR). It saves time by keeping your inbox structured and ensures emails are routed to the right category.
Use cases include:
- Routing customer support requests to the correct team.
- Organizing billing and finance communications separately.
- Streamlining HR and recruitment email handling.
- Reducing inbox clutter and ensuring no important message is missed.
ℹ️ Good to know
- You’ll need to configure Zoho OAuth credentials — see Self Client Overview, Authorization Code Flow, and Zoho Mail OAuth Guide.
- The labels must already exist in Zoho Mail (e.g., Support, Billing, HR). The workflow fetches these labels and applies them automatically.
- The Zoho Mail API domain changes depending on your account region:
.com→ Global accounts (https://mail.zoho.com/api/...).eu→ EU accounts (https://mail.zoho.eu/api/...).in→ India accounts (https://mail.zoho.in/api/...)
Example: For an EU account, the endpoint would be:
https://mail.zoho.eu/api/accounts/<accountID>/updatemessage
- The AI model used for text classification may incur costs depending on your provider (e.g., OpenRouter).
- Start by testing with a small set of emails before enabling for your full inbox.
🔄 How it works
- A new email in Zoho Mail triggers the workflow.
- OAuth authentication retrieves access to Zoho Mail’s API.
- All available labels are fetched, and a label map (display name → ID) is created.
- The AI model analyzes the subject and body to predict the correct category.
- The workflow routes the email to the right category branch.
- The matching Zoho Mail label is applied (final node is deactivated by default).
🛠️ How to use
- Create the required labels (e.g., Support, Billing, HR, etc.) in your Zoho Mail account before running the workflow.
- Replace the Zoho Mail Account ID in the Set Account ID node.
- Configure your Zoho OAuth credentials in the Get Access Token node.
- Update the API base URL to match your Zoho account’s region (
.com,.eu,.in, etc.). - Activate the Apply Label to Email node once ready for production.
- Optionally, adjust categories in the AI classifier prompt to fit your organization’s needs.
📋 Requirements
- Zoho Mail account with API access enabled.
- Labels created in Zoho Mail for each category you want to classify.
- OAuth credentials set up in n8n.
- Correct Zoho Mail API domain (
.com,.eu,.in) based on your account region. - An AI model (via OpenRouter or other provider) for text classification.
🎨 Customising this workflow
This workflow can be adapted to many inbox management scenarios. Examples include:
- Auto-routing customer inquiries to specific departments.
- Prioritizing VIP client emails with special labels.
- Filtering job applications directly into an HR-managed folder.
Automatic Email Categorization & Labeling in Zoho Mail with GPT-4o Mini
This n8n workflow automates the process of categorizing and labeling incoming emails in Zoho Mail using the power of a large language model (LLM) like GPT-4o Mini via OpenRouter. It listens for new emails, analyzes their content, and then suggests appropriate labels based on the email's context.
What it does
This workflow streamlines your email management by:
- Monitoring New Emails: It continuously checks a specified IMAP inbox for new emails.
- Extracting Email Content: For each new email, it extracts the sender, subject, and body content.
- Generating Classification Prompt: It constructs a prompt for an AI model, asking it to classify the email into categories like "Sales," "Support," "Marketing," or "General," and suggest relevant labels.
- AI-Powered Categorization: It sends the email content and prompt to an OpenRouter Chat Model (configured to use an LLM like GPT-4o Mini) to get a classification and suggested labels.
- Processing AI Response: It parses the AI's response to extract the suggested category and labels.
- Applying Labels (Placeholder): The workflow currently includes a "No Operation" node as a placeholder for applying the derived labels to the email in Zoho Mail. This step needs to be implemented with a Zoho Mail node or similar action to fully integrate the labeling.
Prerequisites/Requirements
To use this workflow, you will need:
- n8n Instance: A running instance of n8n.
- IMAP Email Account: Access to an IMAP-enabled email account (e.g., Zoho Mail, Gmail, Outlook). You'll need the IMAP credentials.
- OpenRouter Account: An OpenRouter API key to access various large language models, such as GPT-4o Mini.
- Zoho Mail Account (for full integration): While the current workflow identifies labels, applying them to Zoho Mail would require a Zoho Mail node and credentials, which are not explicitly included but are the intended next step.
Setup/Usage
-
Import the Workflow:
- Download the provided JSON file.
- In your n8n instance, click "Workflows" in the left sidebar.
- Click "New" and then "Import from JSON".
- Paste the JSON content or upload the file.
-
Configure Credentials:
- Email Trigger (IMAP):
- Click on the "Email Trigger (IMAP)" node.
- Under "Credentials", select an existing IMAP credential or create a new one. Provide your IMAP server, port, username, and password.
- Specify the "Folder" to monitor (e.g., "INBOX").
- OpenRouter Chat Model:
- Click on the "OpenRouter Chat Model" node.
- Under "Credentials", select an existing OpenRouter credential or create a new one. Provide your OpenRouter API key.
- Ensure the "Model" is set to your preferred LLM (e.g.,
openai/gpt-4o-mini).
- Email Trigger (IMAP):
-
Review and Customize Code Nodes:
- Code Node (Prepare Prompt): This node constructs the prompt for the AI. You can modify the prompt to refine the categorization instructions or add more context.
- Code Node (Process AI Response): This node parses the JSON output from the AI. If your AI model's output format changes, you might need to adjust the parsing logic here.
-
Implement Email Labeling in Zoho Mail:
- The "No Operation, do nothing" node (ID 26) is a placeholder. To fully automate labeling in Zoho Mail, you would replace this node with a "Zoho Mail" node (or a generic HTTP Request node if Zoho Mail has an API for labeling) configured to apply the
categoryandlabelsderived from the AI. - You would typically use expressions to pass the
categoryandlabelsdata from the previous nodes to the Zoho Mail action.
- The "No Operation, do nothing" node (ID 26) is a placeholder. To fully automate labeling in Zoho Mail, you would replace this node with a "Zoho Mail" node (or a generic HTTP Request node if Zoho Mail has an API for labeling) configured to apply the
-
Activate the Workflow:
- Once all credentials and configurations are set, click the "Activate" toggle in the top right corner of the n8n editor to start the workflow.
This workflow provides a robust foundation for intelligent email management. By integrating with Zoho Mail's labeling features, you can significantly reduce manual effort and improve email organization.
Related Templates
Generate song lyrics and music from text prompts using OpenAI and Fal.ai Minimax
Spark your creativity instantly in any chat—turn a simple prompt like "heartbreak ballad" into original, full-length lyrics and a professional AI-generated music track, all without leaving your conversation. 📋 What This Template Does This chat-triggered workflow harnesses AI to generate detailed, genre-matched song lyrics (at least 600 characters) from user messages, then queues them for music synthesis via Fal.ai's minimax-music model. It polls asynchronously until the track is ready, delivering lyrics and audio URL back in chat. Crafts original, structured lyrics with verses, choruses, and bridges using OpenAI Submits to Fal.ai for melody, instrumentation, and vocals aligned to the style Handles long-running generations with smart looping and status checks Returns complete song package (lyrics + audio link) for seamless sharing 🔧 Prerequisites n8n account (self-hosted or cloud with chat integration enabled) OpenAI account with API access for GPT models Fal.ai account for AI music generation 🔑 Required Credentials OpenAI API Setup Go to platform.openai.com → API keys (sidebar) Click "Create new secret key" → Name it (e.g., "n8n Songwriter") Copy the key and add to n8n as "OpenAI API" credential type Test by sending a simple chat completion request Fal.ai HTTP Header Auth Setup Sign up at fal.ai → Dashboard → API Keys Generate a new API key → Copy it In n8n, create "HTTP Header Auth" credential: Name="Fal.ai", Header Name="Authorization", Header Value="Key [Your API Key]" Test with a simple GET to their queue endpoint (e.g., /status) ⚙️ Configuration Steps Import the workflow JSON into your n8n instance Assign OpenAI API credentials to the "OpenAI Chat Model" node Assign Fal.ai HTTP Header Auth to the "Generate Music Track", "Check Generation Status", and "Fetch Final Result" nodes Activate the workflow—chat trigger will appear in your n8n chat interface Test by messaging: "Create an upbeat pop song about road trips" 🎯 Use Cases Content Creators: YouTubers generating custom jingles for videos on the fly, streamlining production from idea to audio export Educators: Music teachers using chat prompts to create era-specific folk tunes for classroom discussions, fostering interactive learning Gift Personalization: Friends crafting anniversary R&B tracks from shared memories via quick chats, delivering emotional audio surprises Artist Brainstorming: Songwriters prototyping hip-hop beats in real-time during sessions, accelerating collaboration and iteration ⚠️ Troubleshooting Invalid JSON from AI Agent: Ensure the system prompt stresses valid JSON; test the agent standalone with a sample query Music Generation Fails (401/403): Verify Fal.ai API key has minimax-music access; check usage quotas in dashboard Status Polling Loops Indefinitely: Bump wait time to 45-60s for complex tracks; inspect fal.ai queue logs for bottlenecks Lyrics Under 600 Characters: Tweak agent prompt to enforce fuller structures like [V1][C][V2][B][C]; verify output length in executions
Auto-reply & create Linear tickets from Gmail with GPT-5, gotoHuman & human review
This workflow automatically classifies every new email from your linked mailbox, drafts a personalized reply, and creates Linear tickets for bugs or feature requests. It uses a human-in-the-loop with gotoHuman and continuously improves itself by learning from approved examples. How it works The workflow triggers on every new email from your linked mailbox. Self-learning Email Classifier: an AI model categorizes the email into defined categories (e.g., Bug Report, Feature Request, Sales Opportunity, etc.). It fetches previously approved classification examples from gotoHuman to refine decisions. Self-learning Email Writer: the AI drafts a reply to the email. It learns over time by using previously approved replies from gotoHuman, with per-classification context to tailor tone and style (e.g., different style for sales vs. bug reports). Human Review in gotoHuman: review the classification and the drafted reply. Drafts can be edited or retried. Approved values are used to train the self-learning agents. Send approved Reply: the approved response is sent as a reply to the email thread. Create ticket: if the classification is Bug or Feature Request, a ticket is created by another AI agent in Linear. Human Review in gotoHuman: How to set up Most importantly, install the gotoHuman node before importing this template! (Just add the node to a blank canvas before importing) Set up credentials for gotoHuman, OpenAI, your email provider (e.g. Gmail), and Linear. In gotoHuman, select and create the pre-built review template "Support email agent" or import the ID: 6fzuCJlFYJtlu9mGYcVT. Select this template in the gotoHuman node. In the "gotoHuman: Fetch approved examples" http nodes you need to add your formId. It is the ID of the review template that you just created/imported in gotoHuman. Requirements gotoHuman (human supervision, memory for self-learning) OpenAI (classification, drafting) Gmail or your preferred email provider (for email trigger+replies) Linear (ticketing) How to customize Expand or refine the categories used by the classifier. Update the prompt to reflect your own taxonomy. Filter fetched training data from gotoHuman by reviewer so the writer adapts to their personalized tone and preferences. Add more context to the AI email writer (calendar events, FAQs, product docs) to improve reply quality.
Synchronizing WooCommerce inventory and creating products with Google Gemini AI and BrowserAct
Synchronize WooCommerce Inventory & Create Products with Gemini AI & BrowserAct This sophisticated n8n template automates WooCommerce inventory management by scraping supplier data, updating existing products, and intelligently creating new ones with AI-formatted descriptions. This workflow is essential for e-commerce operators, dropshippers, and inventory managers who need to ensure their product pricing and stock levels are synchronized with multiple third-party suppliers, minimizing overselling and maximizing profit. --- Self-Hosted Only This Workflow uses a community contribution and is designed and tested for self-hosted n8n instances only. --- How it works The workflow is typically run by a Schedule Trigger (though a Manual Trigger is also shown) to check stock automatically. It reads a list of suppliers and their inventory page URLs from a central Google Sheet. The workflow loops through each supplier: A BrowserAct node scrapes the current stock and price data from the supplier's inventory page. A Code node parses this bulk data into individual product items. It then loops through each individual product found. The workflow checks WooCommerce to see if the product already exists based on its name. If the product exists: It proceeds to update the existing product's price and stock quantity. If the product DOES NOT exist: An If node checks if the missing product's category matches a predefined type (optional filtering). If it passes the filter, a second BrowserAct workflow scrapes detailed product attributes from a dedicated product page (e.g., DigiKey). An AI Agent (Gemini) transforms these attributes into a specific, styled HTML table for the product description. Finally, the product is created in WooCommerce with all scraped details and the AI-generated description. Error Handling: Multiple Slack nodes are configured to alert your team immediately if any scraping task fails or if the product update/creation process encounters an issue. Note: This workflow does not support image uploads for new products. To enable this functionality, you must modify both the n8n and BrowserAct workflows. --- Requirements BrowserAct API account for web scraping BrowserAct n8n Community Node -> (n8n Nodes BrowserAct) BrowserAct templates named “WooCommerce Inventory & Stock Synchronization” and “WooCommerce Product Data Reconciliation” Google Sheets credentials for the supplier list WooCommerce credentials for product management Google Gemini account for the AI Agent Slack credentials for error alerts --- Need Help? How to Find Your BrowseAct API Key & Workflow ID How to Connect n8n to Browseract How to Use & Customize BrowserAct Templates How to Use the BrowserAct N8N Community Node --- Workflow Guidance and Showcase STOP Overselling! Auto-Sync WooCommerce Inventory from ANY Supplier