Skip to content
FlowHubFluxonLab
A
AI Automationfree

Basic Automatic Gmail Email Labelling with OpenAI and Gmail API

by Martijn Kerveradapted from n8n official workflow galleryUpdated Aug 2026
RequiresAAI AgentOpenAI Chat ModelOpenAI Chat ModelSSimple Memory
Share Post Share
Gmail TriggerOpenAI Chat Model1OpenAI Chat Mod…Gmail - read labelsGmail - read la…Gmail - get messageGmail - get mes…Gmail - add label to messageGmail - add lab…Gmail - create labelGmail - create …AgGmail labelling agentGmail labelling…MBWindow Buffer MemoryWindow Buffer M…WaWait12345678
1/5
STEPS · 8
Starts on a Gmail event

Description This workflow automates email categorization in Gmail using the Gmail API and OpenAI's language model. It periodically checks for new emails, reads their content, and categorizes them based on existing Gmail labels. If no matching label is found, the workflow creates a new label and assigns it to the email. Key Features Polling for Emails**: The workflow triggers every 5 minutes to check for new emails using the Gmail Trigger node. Reading Labels**: Existing Gmail labels are fetched to determine the most relevant match for email categorization. Dynamic Labeling**: If no existing label matches, a new label is created dynamically based on the email's content. OpenAI Integration**: The workflow uses OpenAI's Chat model to analyze email content and suggest or create appropriate labels. Email Categorization**: Labels are applied to emails, ensuring they are organized in Gmail's structure. The workflow also removes less relevant emails (e.g., ads) from the inbox. Nodes in Use Gmail Trigger: Polls Gmail every 5 minutes for new emails. Gmail - Read Labels: Fetches all existing Gmail labels. Gmail - Get Message: Retrieves the full content of a specific email.

Tags

n8nreference-onlyagentlm-chat-open-aimemory-buffer-window
Connects
AAI AgentopenaichatmodelOpenAI Chat ModelSSimple Memory
CategoryAI Automation
Triggermanual
Complexitycomplex
Nodes9
AddedJan 17, 2025

Related workflows

See all AI Automation
AopenaichatmodelserpapigooglesearchS
free

Slack chatbot powered by AI

This workflow offers an effective way to handle a chatbot's functionality, making use of multiple tools for information retrieval, conversation context storage, and message sending. It's a setup tailored for a Slack environment, aiming to offer an interactive, AI-driven chatbot experience. Note that to use this template, you need to be on n8n version 1.19.4 or later.

by n8n Team
AopenaichatmodelserpapigooglesearchS
free

AI agent chat

This workflow employs OpenAI's language models and SerpAPI to create a responsive, intelligent conversational agent. It comes equipped with manual chat triggers and memory buffer capabilities to ensure seamless interactions. To use this template, you need to be on n8n version 1.50.0 or later.

by n8n Team
AopenaichatmodelserpapigooglesearchS
free

AI chatbot that can search the web

This workflow is designed for dynamic and intelligent conversational capabilities. It incorporates OpenAI's GPT-4o model for natural language understanding and generation. Additional tools include SerpAPI and Wikipedia for enriched, data-driven responses. The workflow is triggered manually, and utilizes a 'Window Buffer Memory' to maintain the context of the last 20 interactions for better conversational continuity. All these components are orchestrated through n8n nodes, ensuring seamless interconnectivity. To use this template, you need to be on n8n version 1.50.0 or later.

by n8n Team