This workflow corresponds to n8n.io template #4053 — we link there as the canonical source.
This workflow follows the Gmail → OpenAI Chat recipe pattern — see all workflows that pair these two integrations.
The workflow JSON
Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →
{
"id": "72Ut8p2aSfFgiTEM",
"meta": {
"templateCredsSetupCompleted": true
},
"name": "Classify_Emails_by_Action_Required_Using_GPT-4o",
"tags": [],
"nodes": [
{
"id": "bbccdd88-4e46-408a-b41f-38671ff56cea",
"name": "Schedule Trigger",
"type": "n8n-nodes-base.scheduleTrigger",
"position": [
0,
0
],
"parameters": {
"rule": {
"interval": [
{}
]
}
},
"typeVersion": 1.2
},
{
"id": "1409b97b-fadd-43e7-a21a-20d1b3a26357",
"name": "OpenAI Chat Model",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"position": [
440,
240
],
"parameters": {
"model": {
"__rl": true,
"mode": "list",
"value": "gpt-4o-mini"
},
"options": {}
},
"credentials": {
"openAiApi": {
"name": "<your credential>"
}
},
"typeVersion": 1.2
},
{
"id": "f0398f84-c60b-4107-a9f6-20520abe65ab",
"name": "Get Emails",
"type": "n8n-nodes-base.gmail",
"position": [
220,
0
],
"parameters": {
"filters": {
"readStatus": "unread"
},
"operation": "getAll"
},
"credentials": {
"gmailOAuth2": {
"name": "<your credential>"
}
},
"typeVersion": 2.1
},
{
"id": "112e2574-192f-4717-8a73-157d1e24d8c9",
"name": "Add \"Action Required\" Label",
"type": "n8n-nodes-base.gmail",
"position": [
900,
-160
],
"parameters": {
"labelIds": [
"Label_5412178974275757474"
],
"messageId": "={{ $json.id }}",
"operation": "addLabels"
},
"credentials": {
"gmailOAuth2": {
"name": "<your credential>"
}
},
"typeVersion": 2.1
},
{
"id": "bf8e00cf-b09e-4181-960b-b92a47b323aa",
"name": "Email Classifier",
"type": "@n8n/n8n-nodes-langchain.textClassifier",
"position": [
440,
0
],
"parameters": {
"options": {},
"inputText": "={{ $json.snippet }}",
"categories": {
"categories": [
{
"category": "Action",
"description": "=The email requires the recipient to take a specific action. This could include replying, reviewing something, clicking a link, attending a meeting, completing a task, or making a decision. The sender expects a response or follow-up."
},
{
"category": "No Action",
"description": "The email is informational only and does not require any action from the recipient. Examples include newsletters, promotional emails, confirmations, or general updates where no response is needed."
}
]
}
},
"typeVersion": 1
},
{
"id": "8350d1b8-21f0-455e-9bfa-a4c7222f5242",
"name": "Remove \"Inbox\" Label",
"type": "n8n-nodes-base.gmail",
"position": [
1140,
-160
],
"parameters": {
"labelIds": [
"INBOX"
],
"messageId": "={{ $json.id }}",
"operation": "removeLabels"
},
"credentials": {
"gmailOAuth2": {
"name": "<your credential>"
}
},
"typeVersion": 2.1
},
{
"id": "704ed172-abf6-4203-b39e-d0f38ed4b41b",
"name": "Add \"No Action\" Label",
"type": "n8n-nodes-base.gmail",
"position": [
900,
140
],
"parameters": {
"labelIds": [
"Label_19062+1234567890"
],
"messageId": "={{ $json.id }}",
"operation": "addLabels"
},
"credentials": {
"gmailOAuth2": {
"name": "<your credential>"
}
},
"typeVersion": 2.1
},
{
"id": "d89eb342-9eae-4da9-a52a-211042fd59b0",
"name": "Remove \"Inbox\" Label",
"type": "n8n-nodes-base.gmail",
"position": [
1140,
140
],
"parameters": {
"labelIds": [
"INBOX"
],
"messageId": "={{ $json.id }}",
"operation": "removeLabels"
},
"credentials": {
"gmailOAuth2": {
"name": "<your credential>"
}
},
"typeVersion": 2.1
},
{
"id": "0681e342-f582-4d3a-826f-42848432e1b7",
"name": "Sticky Note",
"type": "n8n-nodes-base.stickyNote",
"position": [
-520,
-300
],
"parameters": {
"color": 4,
"width": 460,
"height": 400,
"content": "\ud83e\uddf1 NODE-BY-NODE BREAKDOWN\n\u23f0 1. Schedule Trigger\n\nRuns the workflow on a set interval.\n\ud83d\udce5 2. Get Emails\n\nFetches unread emails from your Gmail inbox.\n\ud83e\udde0 3. Email Classifier\n\nClassifies each email as Action or No Action using GPT-4o.\n\ud83c\udff7\ufe0f 4. Add \"Action Required\" Label\n\nAdds the Action Required label to emails that need your attention.\n\ud83e\uddf9 5. Remove \"Inbox\" Label (Action)\n\nRemoves the INBOX label from emails marked as Action.\n\ud83c\udff7\ufe0f 6. Add \"No Action\" Label\n\nAdds the No Action label to emails that require no response.\n\ud83e\uddf9 7. Remove \"Inbox\" Label (No Action)"
},
"typeVersion": 1
}
],
"active": false,
"settings": {
"executionOrder": "v1"
},
"versionId": "6ffdc307-d627-47d3-bd8b-d9ecc1a531df",
"connections": {
"Get Emails": {
"main": [
[
{
"node": "Email Classifier",
"type": "main",
"index": 0
}
]
]
},
"Email Classifier": {
"main": [
[
{
"node": "Add \"Action Required\" Label",
"type": "main",
"index": 0
}
],
[
{
"node": "Add \"No Action\" Label",
"type": "main",
"index": 0
}
]
]
},
"Schedule Trigger": {
"main": [
[
{
"node": "Get Emails",
"type": "main",
"index": 0
}
]
]
},
"OpenAI Chat Model": {
"ai_languageModel": [
[
{
"node": "Email Classifier",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Add \"No Action\" Label": {
"main": [
[
{
"node": "Remove \"Inbox\" Label",
"type": "main",
"index": 0
}
]
]
},
"Add \"Action Required\" Label": {
"main": [
[
{
"node": "Remove \"Inbox\" Label",
"type": "main",
"index": 0
}
]
]
}
}
}
Credentials you'll need
Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.
gmailOAuth2openAiApi
For the full experience including quality scoring and batch install features for each workflow upgrade to Pro
About this workflow
🧾 Description:
Source: https://n8n.io/workflows/4053/ — original creator credit. Request a take-down →
Related workflows
Workflows that share integrations, category, or trigger type with this one. All free to copy and import.
gmail label and notify. Uses lmChatOpenAi, textClassifier, gmail, openAi. Scheduled trigger; 16 nodes.
This workflow automatically organizes your Gmail inbox by fetching recent emails, analyzing their content with AI, and applying the appropriate Gmail labels based on the results.
Why settle for Gmail’s default tabs when AI can sort your inbox your way?
This n8n template demonstrates how to automate email classification, labeling, draft generation, and logging using Gmail, OpenAI, and Google Sheets. Use cases include customer support management, sale
This template can be used to automatically label your incoming Gmail messages with AI and to build a knowledge graph from the emails tagged with a specific label to brainstorm new ideas based on them.