This workflow corresponds to n8n.io template #7952 — we link there as the canonical source.
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": "a8uDplux0EO8uSsG",
"meta": {
"templateId": "4285"
},
"name": "Automatically Delete Unwanted Emails in Gmail on Schedule",
"tags": [],
"nodes": [
{
"id": "cc3c9d36-a26e-47cb-bb74-3a1027b996cd",
"name": "Sticky Note",
"type": "n8n-nodes-base.stickyNote",
"position": [
-512,
0
],
"parameters": {
"color": 5,
"width": 932,
"height": 440,
"content": "## Scheduled Gmail Cleanup - Auto-Delete Spam, Promotions, Social & Trash\n\nManaging Gmail manually can be tedious and time-consuming. Spam, Promotions, Social, and Trash folders quickly fill up with unwanted emails, taking up valuable storage and creating clutter. This workflow provides a simple yet powerful Gmail automation for efficient email management, helping you maintain a cleaner inbox with zero daily effort.\n\nThis workflow is triggered by a Schedule node that runs once per day (customizable). It then uses multiple Gmail nodes to:\n\nFetch Spam Emails \u2013 Identify all emails in the Spam folder.\nFetch Promotions Emails \u2013 Collect promotional messages from Gmail\u2019s Promotions category.\nFetch Social Emails \u2013 Pull emails from the Social tab.\nFetch Trash Emails \u2013 Find all items already marked as trash.\nDelete Fetched Emails \u2013 Automatically delete the emails retrieved from these categories.\nBy default, the workflow deletes the selected emails permanently. Once removed, they are not recoverable.\n\n## Customising this workflow\n**Schedule**: Adjust the Schedule Trigger to run hourly, daily, or weekly.\n**Categories**: Remove nodes for folders you want to keep, or add filters to only delete emails older than a certain number of days.\n**Deletion Settings**: Modify the Gmail Delete node to move emails to Trash instead of permanent deletion if you prefer a safer cleanup.\n\n"
},
"typeVersion": 1
},
{
"id": "86749abf-16c8-4406-9394-b22a384b4e89",
"name": "Sticky Note1",
"type": "n8n-nodes-base.stickyNote",
"position": [
160,
656
],
"parameters": {
"color": 4,
"width": 262,
"height": 232,
"content": "## Schedule Trigger :point_up:\n\nThis starts the workflow automatically at a set time. Default is every day at midnight.\n\nHow to edit: Double-click this node and set the time you want (e.g., every day at midnight, weekly, or custom)."
},
"typeVersion": 1
},
{
"id": "3a241677-1600-41fe-9877-b0cf82a9e817",
"name": "Get all Social Mails",
"type": "n8n-nodes-base.gmail",
"position": [
912,
-208
],
"parameters": {
"filters": {
"labelIds": [
"CATEGORY_SOCIAL"
],
"receivedAfter": "={{ $today.minus({ days: 5 }) }}"
},
"operation": "getAll",
"returnAll": true
},
"credentials": {
"gmailOAuth2": {
"name": "<your credential>"
}
},
"typeVersion": 2.1
},
{
"id": "a9fdc8c5-bf2d-497d-91b5-695e4c9a63e1",
"name": "Get all Trash Mails",
"type": "n8n-nodes-base.gmail",
"position": [
928,
656
],
"parameters": {
"filters": {
"labelIds": [
"TRASH"
],
"receivedAfter": "={{ $today.minus({ days: 5 }) }}"
},
"operation": "getAll",
"returnAll": true
},
"credentials": {
"gmailOAuth2": {
"name": "<your credential>"
}
},
"typeVersion": 2.1
},
{
"id": "24bb4ae1-374c-4634-8f49-1da0aab9f784",
"name": "Get all Promotional Mails",
"type": "n8n-nodes-base.gmail",
"position": [
928,
1168
],
"parameters": {
"filters": {
"labelIds": [
"CATEGORY_PROMOTIONS"
],
"receivedAfter": "={{ $today.minus({ days: 5 }) }}"
},
"operation": "getAll",
"returnAll": true
},
"credentials": {
"gmailOAuth2": {
"name": "<your credential>"
}
},
"typeVersion": 2.1
},
{
"id": "b755451e-7fc3-4c3b-b669-69d700c38fa4",
"name": "Get all SPAM Mails",
"type": "n8n-nodes-base.gmail",
"position": [
912,
208
],
"parameters": {
"filters": {
"labelIds": [
"SPAM"
]
},
"operation": "getAll",
"returnAll": true
},
"credentials": {
"gmailOAuth2": {
"name": "<your credential>"
}
},
"typeVersion": 2.1
},
{
"id": "5f9b92e6-6e9a-4c0c-b627-1c8adaba6f8c",
"name": "Sticky Note2",
"type": "n8n-nodes-base.stickyNote",
"position": [
832,
-256
],
"parameters": {
"width": 294,
"height": 376,
"content": "## :point_down: Fetch Social Emails\n\n\n\n\n\n\n\n\n\n\n\nCollects emails from the Social tab. These are notifications from platforms like Facebook, Twitter, LinkedIn, and other social networks.\n\nHow to edit: Open the node \u2192 choose your Gmail credential \u2192 change filters to keep certain types of promotional emails if needed."
},
"typeVersion": 1
},
{
"id": "b6fc6613-556c-469e-b1d2-786378bf953c",
"name": "Sticky Note3",
"type": "n8n-nodes-base.stickyNote",
"position": [
832,
160
],
"parameters": {
"width": 294,
"height": 360,
"content": "## :point_down: Fetch Spam Emails\n\n\n\n\n\n\n\n\n\n\n\nCollects all emails that Gmail has already marked as Spam. These are typically phishing, scams, or unwanted bulk messages.\n\nHow to edit: Open the node \u2192 select your Gmail credential \u2192 adjust filters if you only want to delete older emails."
},
"typeVersion": 1
},
{
"id": "693846dc-8189-4c0f-a5de-06af38353dec",
"name": "Sticky Note4",
"type": "n8n-nodes-base.stickyNote",
"position": [
832,
576
],
"parameters": {
"width": 294,
"height": 392,
"content": "## :point_down: Fetch Trash Emails\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nCollects all emails already in the Trash folder. Deleting them here helps free up Gmail storage permanently.\n\nHow to edit: Open the node \u2192 connect Gmail \u2192 optionally filter by date (e.g., only delete emails older than 30 days)."
},
"typeVersion": 1
},
{
"id": "3cd715b1-4f81-4ee3-acaa-a4a6fd9a0107",
"name": "Sticky Note5",
"type": "n8n-nodes-base.stickyNote",
"position": [
832,
1088
],
"parameters": {
"width": 294,
"height": 360,
"content": "## :point_down: Fetch Promotions Emails\n\n\n\n\n\n\n\n\n\nThis node fetches all emails from the Promotions tab (e.g., marketing and offers).\n\nHow to edit: Open the node \u2192 choose your Gmail credential \u2192 change filters to keep certain types of promotional emails if needed."
},
"typeVersion": 1
},
{
"id": "ec22e530-41ca-4a0f-a2b9-ac0ff3434409",
"name": "Sticky Note6",
"type": "n8n-nodes-base.stickyNote",
"position": [
1600,
656
],
"parameters": {
"color": 3,
"width": 294,
"height": 168,
"content": "## :point_up: Delete Emails\n\nThis node permanently deletes the fetched emails. You can change it to move them to Trash instead if you prefer safer cleanup."
},
"typeVersion": 1
},
{
"id": "286e5c34-18ab-46da-b184-cfabf796b21d",
"name": "Delete Mails",
"type": "n8n-nodes-base.gmail",
"position": [
1600,
480
],
"parameters": {
"messageId": "={{ $json.id }}",
"operation": "delete"
},
"credentials": {
"gmailOAuth2": {
"name": "<your credential>"
}
},
"typeVersion": 2.1
},
{
"id": "13990a10-1f51-423c-a42e-683d77bb269e",
"name": "Trigger every day at midnight",
"type": "n8n-nodes-base.scheduleTrigger",
"position": [
320,
480
],
"parameters": {
"rule": {
"interval": [
{}
]
}
},
"typeVersion": 1.2
}
],
"active": true,
"settings": {},
"versionId": "fffe5482-0503-41fb-b9f2-d868e1072556",
"connections": {
"Get all SPAM Mails": {
"main": [
[
{
"node": "Delete Mails",
"type": "main",
"index": 0
}
]
]
},
"Get all Trash Mails": {
"main": [
[
{
"node": "Delete Mails",
"type": "main",
"index": 0
}
]
]
},
"Get all Social Mails": {
"main": [
[
{
"node": "Delete Mails",
"type": "main",
"index": 0
}
]
]
},
"Get all Promotional Mails": {
"main": [
[
{
"node": "Delete Mails",
"type": "main",
"index": 0
}
]
]
},
"Trigger every day at midnight": {
"main": [
[
{
"node": "Get all SPAM Mails",
"type": "main",
"index": 0
},
{
"node": "Get all Social Mails",
"type": "main",
"index": 0
},
{
"node": "Get all Trash Mails",
"type": "main",
"index": 0
},
{
"node": "Get all Promotional Mails",
"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.
gmailOAuth2
For the full experience including quality scoring and batch install features for each workflow upgrade to Pro
About this workflow
Managing Gmail manually can be tedious and time-consuming. Spam, Promotions, Social, and Trash folders quickly fill up with unwanted emails, taking up valuable storage and creating clutter. This workflow provides a simple yet powerful Gmail automation for efficient email…
Source: https://n8n.io/workflows/7952/ — 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.
This workflow automates the backup of all your n8n workflows to a specified Google Drive folder. It operates in two main phases: Orchestration (Scheduled Task): The workflow is initiated by a Schedule
This n8n template allows you to automatically monitor your company's budget by comparing live Bexio accounting data against targets defined in Google Sheets, sending automated weekly email reports. It
Klaviyo List Decay Detection
This workflow automatically generates and emails a comprehensive security audit report for your N8N instance every week. It identifies potential security risks related to: Credentials 🔑 : Exposed or i
Automatically identify clients who haven’t been contacted in 14+ days and re-engage them with personalized Gmail follow-up emails, Google Sheets tracking, and Slack notifications for account managers.