This workflow corresponds to n8n.io template #7585 — we link there as the canonical source.
This workflow follows the Agent → Gmail 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 →
{
"name": "AI-Renamed Gmail Attachments to Drive",
"tags": [],
"nodes": [
{
"name": "Schedule Trigger",
"type": "n8n-nodes-base.scheduleTrigger",
"position": [
0,
0
],
"parameters": {
"rule": {
"interval": [
{
"field": "hours"
}
]
}
},
"typeVersion": 1.2
},
{
"name": "AI Agent",
"type": "@n8n/n8n-nodes-langchain.agent",
"position": [
1120,
124
],
"parameters": {
"text": "=You are an expert content analyser and file naming assistant...\ntext: {{ $json.text }}\ndate: {{ $json.info.CreationDate }}",
"options": {},
"promptType": "define"
},
"typeVersion": 2.2
},
{
"name": "OpenAI Chat Model",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"position": [
1192,
348
],
"parameters": {
"model": {
"__rl": true,
"mode": "list",
"value": "gpt-4o-mini",
"cachedResultName": "gpt-4o-mini"
},
"options": {}
},
"typeVersion": 1.2
},
{
"name": "Upload file",
"type": "n8n-nodes-base.googleDrive",
"position": [
1696,
0
],
"parameters": {
"name": "={{ $json.output }}",
"driveId": {
"__rl": true,
"mode": "list",
"value": "My Drive"
},
"options": {},
"folderId": {
"__rl": true,
"mode": "url",
"value": ""
},
"inputDataFieldName": "attachment_1"
},
"typeVersion": 3
},
{
"name": "Mark message as read",
"type": "n8n-nodes-base.gmail",
"position": [
1920,
0
],
"parameters": {
"messageId": "={{ $('Set Required Fields').item.json.id }}",
"operation": "markAsRead"
},
"typeVersion": 2.1
},
{
"name": "Merge Data for Upload",
"type": "n8n-nodes-base.merge",
"position": [
1472,
0
],
"parameters": {
"mode": "combine",
"options": {},
"combineBy": "combineByPosition"
},
"typeVersion": 3.2
},
{
"name": "Get Unread Messages with Attachments",
"type": "n8n-nodes-base.gmail",
"position": [
224,
0
],
"parameters": {
"filters": {
"readStatus": "unread"
},
"operation": "getAll"
},
"typeVersion": 2.1
},
{
"name": "Set Required Fields",
"type": "n8n-nodes-base.set",
"position": [
448,
0
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"name": "id",
"type": "string",
"value": "={{ $json.id }}"
},
{
"name": "threadId",
"type": "string",
"value": "={{ $json.threadId }}"
},
{
"name": "from.value[0].name",
"type": "string",
"value": "={{ $json.from.value[0].name }}"
},
{
"name": "date",
"type": "string",
"value": "={{ $json.date }}"
}
]
}
},
"typeVersion": 3.4
},
{
"name": "Download Attachments",
"type": "n8n-nodes-base.gmail",
"position": [
672,
0
],
"parameters": {
"simple": false,
"options": {
"downloadAttachments": true
},
"messageId": "={{ $json.id }}",
"operation": "get"
},
"typeVersion": 2.1
},
{
"name": "Extract from Attachments",
"type": "n8n-nodes-base.extractFromFile",
"position": [
896,
0
],
"parameters": {
"options": {},
"operation": "pdf",
"binaryPropertyName": "attachment_0"
},
"typeVersion": 1
}
],
"active": false,
"settings": {
"executionOrder": "v1"
},
"versionId": "81cda4d6-8828-4b64-8afe-88b302168717",
"connections": {
"AI Agent": {
"main": [
[
{
"node": "Merge Data for Upload",
"type": "main",
"index": 1
}
]
]
},
"Upload file": {
"main": [
[
{
"node": "Mark message as read",
"type": "main",
"index": 0
}
]
]
},
"Schedule Trigger": {
"main": [
[
{
"node": "Get Unread Messages with Attachments",
"type": "main",
"index": 0
}
]
]
},
"OpenAI Chat Model": {
"ai_languageModel": [
[
{
"node": "AI Agent",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Set Required Fields": {
"main": [
[
{
"node": "Download Attachments",
"type": "main",
"index": 0
}
]
]
},
"Download Attachments": {
"main": [
[
{
"node": "Extract from Attachments",
"type": "main",
"index": 0
}
]
]
},
"Merge Data for Upload": {
"main": [
[
{
"node": "Upload file",
"type": "main",
"index": 0
}
]
]
},
"Extract from Attachments": {
"main": [
[
{
"node": "AI Agent",
"type": "main",
"index": 0
}
],
[
{
"node": "Merge Data for Upload",
"type": "main",
"index": 0
}
]
]
},
"Get Unread Messages with Attachments": {
"main": [
[
{
"node": "Set Required Fields",
"type": "main",
"index": 0
}
]
]
}
}
}
For the full experience including quality scoring and batch install features for each workflow upgrade to Pro
About this workflow
This workflow is perfect for anyone who regularly receives important email attachments like reports, invoices, or PDFs and wants them: Renamed using clean AI generated filenames Automatically saved to a specific Google Drive folder Neatly organized without manual work
Source: https://n8n.io/workflows/7585/ — 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 n8n automation workflow automates the creation, scripting, production, and posting of YouTube videos. It leverages AI (OpenAI), image generation (PIAPI), video rendering (Shotstack), and platform
The Multi-Model Agency Content Engine is a high-performance editorial system designed for agencies. It solves the "blank page" problem by alternating between real-world social proof and strategic expe
This workflow automates the creation, rendering, approval, and posting of TikTok-style POV (Point of View) videos to Instagram, with cross-posting to Facebook and YouTube. It eliminates manual video p
Note: This template is for self-hosted n8n instances only
Consolidates daily revenue from Stripe, PayPal, Shopify, and bank feeds into a single system. The workflow automatically normalizes data across payment sources, uses AI to categorize income transactio