Keyflow

Search Keyflow

Find a shortcut, workflow, MCP server or skill

Basic Automatic Gmail Email Labelling with OpenAI and Gmail API

n8n template #2740
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 work

How to set it up

  1. Open template #2740 on n8n.io and click Use for free, or copy the template JSON and paste it onto an empty canvas in n8n.
  2. Create a credential under Credentials → Add credential: OpenAI Chat Model. Then open each of those nodes and pick the credential.
  3. Check the model in the AI Agent node. The template may point at a model your account can't use; swap it for one you have access to.
  4. Click Execute workflow and step through each node's output to confirm the data looks right.
  5. Toggle the workflow to Active so its trigger runs on its own.

Hand off to your agent

Prompt

Help me set up the n8n workflow "Basic Automatic Gmail Email Labelling with OpenAI and Gmail API" (https://n8n.io/workflows/2740). It uses: AI Agent, OpenAI Chat Model, Simple Memory. Import the template JSON into my n8n instance, list every credential I need to create, and walk me through testing it.

Paste into Claude Code and it will do the rest.

Apps and nodes

Questions

Yes. Martijn Kerver published it free on n8n.io, and it has 14K views. It runs on n8n Cloud or a self-hosted n8n instance.

OpenAI Chat Model. The other 2 nodes are built into n8n.

Similar workflows

NameViews
  1. AI agent chat780K
  2. Building Your First WhatsApp Chatbot332K
  3. Angie, personal AI assistant with Telegram voice and text326K
  4. Build Your First AI Data Analyst Chatbot134K
  5. Create a Branded AI-Powered Website Chatbot88K
  6. Conversational Telegram Bot with GPT-5/GPT-4o for Text and Voice Messages82K
  7. Chat with Postgresql Database74K
  8. AI chatbot that can search the web72K