# Classify and label new Gmail emails with OpenAI GPT-4.1 mini

> Quick Overview This workflow polls Gmail for new messages, uses OpenAI to classify each email into a category and priority with a short summary, and then applies matching Gmail labels (for example, AI/Urgent or AI/Sales Lead) when the labels exist in your account. How it works 1. Checks Gmail for new emails every minute. 2. Normalizes each email (sender, subject, truncated body, message ID) and prepares it for classification. 3. Sends the email content to OpenAI and receives a strict JSON result with category, priority, summary, whether a reply is needed, and a short reason. 4. Validates and parses the OpenAI output, falling back to the “other” category if the response is invalid. 5. Fetches all existing Gmail labels and maps each classified category (and optional priority) to a label ID using your configured prefix. 6. Adds the resolved label(s) to the Gmail message when the target label exists, and skips emails where the expected label is missing. Setup 1. Add a Gmail OAuth2 credenti

- **Domain**: `n8n-workflow-20988.n8n.io`
- **Provider**: n8n.io (https://n8n.io)
- **Kind**: workflow
- **Live-responds (last probe)**: None
- **Signed card**: False
- **Streaming**: False
- **Quality score**: 40%

## URLs
- Agent card: https://n8n.io/workflows/20988
- Page (HTML): https://agenstry.com/agents/n8n-workflow-20988.n8n.io
- Documentation: https://n8n.io/workflows/20988
