Automatically Label Gmail Messages with AI
detail.loadingPreview
This n8n workflow automatically categorizes incoming Gmail messages using AI and assigns relevant labels. It leverages Gmail triggers, content retrieval, and LLM processing to streamline email management.
🚀Ready to Deploy This Workflow?
About This Workflow
Overview
This n8n workflow is designed to automate the labeling of your Gmail messages. It begins by triggering on new incoming emails via the Gmail trigger node. Then, it fetches the full message content using the Get message content node. The core logic resides in the Assign labels for message node, which utilizes an AI (specifically, an OpenAI Chat model) to analyze the email's text and determine appropriate labels based on a pre-defined prompt. The AI's output is parsed by the JSON Parser node to extract the suggested labels. Subsequently, the Get all labels node retrieves existing labels from your Gmail account, and the Split out assigned labels and Merge corresponding labels nodes process these alongside the AI-generated labels. Finally, the Aggregate label IDs and Add labels to message nodes are used to add the determined labels to the original email. This workflow solves the problem of manually sorting and categorizing emails, saving time and improving organization by intelligently assigning labels.
Key Features
- Automatically triggers on new incoming Gmail messages.
- Uses AI (OpenAI Chat) to analyze email content for categorization.
- Supports custom labeling rules through an editable system prompt.
- Retrieves and merges existing Gmail labels with AI-suggested labels.
- Applies determined labels back to the original Gmail message.
How To Use
- Configure the
Gmail triggernode with your Gmail credentials and set the desired polling interval. - In the
Assign labels for messagenode (using theOpenAI Chatmodel), update the system prompt to define your desired labels and the criteria for assigning them. Ensure the label names in the prompt match those in theJSON Parsernode's schema. - Update the
JSON Parsernode'sjsonSchemato reflect the labels you defined in the system prompt. - Configure the
Gmailnodes (Get message content,Get all labels,Add labels to message) with your Gmail credentials. - Ensure all necessary credentials (Gmail OAuth2 and OpenAI API) are set up in your n8n instance.
- Activate the workflow to start automatically labeling your incoming emails.
Apps Used
Workflow JSON
{
"id": "47f95763-4dd3-4b5b-a216-f6dbd17e0418",
"name": "Automatically Label Gmail Messages with AI",
"nodes": 0,
"category": "Gmail and Email Automation",
"status": "active",
"version": "1.0.0"
}Note: This is a sample preview. The full workflow JSON contains node configurations, credentials placeholders, and execution logic.
Get This Workflow
ID: 47f95763-4dd3...
About the Author
DevOps_Master_X
Infrastructure Expert
Specializing in CI/CD pipelines, Docker, and Kubernetes automations.
Statistics
Verification Info
Related Workflows
Discover more workflows you might like
AI-Powered Gmail Auto-Labeler for Email Organization
Automate Gmail email categorization using an AI agent. This workflow triggers on new emails, uses OpenAI to analyze content, and leverages Gmail tools to read, create, and assign labels.
Automate Gmail Replies with OpenAI Assistant
Automatically processes incoming Gmail threads, generates replies using OpenAI Assistant, and adds them as drafts. It then removes the trigger label from the processed thread.
Automate Outlook Email Categorization with AI
This workflow automatically categorizes Outlook emails using an AI model. It leverages the Microsoft Outlook node to read emails and the Ollama Chat Model node for AI-driven classification, then moves emails to relevant folders.