AutomationFlowsAI & RAG › Gmail to Google Drive & Sheets Ingestion

Gmail to Google Drive & Sheets Ingestion

Original n8n title: Ingest Agent Workflow

INGEST Agent Workflow. Uses gmail, googleDrive, googleSheets. Event-driven trigger; 9 nodes.

Event trigger★★★★☆ complexity9 nodesGmailGoogle DriveGoogle Sheets
AI & RAG Trigger: Event Nodes: 9 Complexity: ★★★★☆ Added:

This workflow follows the Gmail → Google Drive 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 →

Download .json
{
  "name": "INGEST Agent Workflow",
  "nodes": [
    {
      "parameters": {},
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        -1536,
        -288
      ],
      "id": "manual_trigger_node",
      "name": "Manual Trigger"
    },
    {
      "parameters": {
        "operation": "getAll",
        "limit": 10,
        "filters": {
          "q": "has:attachment newer_than:1d"
        }
      },
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.1,
      "position": [
        -1344,
        -288
      ],
      "id": "YOUR_ID",
      "name": "Gmail \u2014 Get many messages",
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "operation": "get",
        "messageId": "={{$json.id}}",
        "simple": false,
        "options": {
          "downloadAttachments": true
        }
      },
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.1,
      "position": [
        -1120,
        -288
      ],
      "id": "YOUR_ID",
      "name": "Gmail \u2014 (Get Message + Download Attachments)",
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "fieldToSplitOut": "$binary",
        "include": "allOtherFields",
        "options": {}
      },
      "type": "n8n-nodes-base.splitOut",
      "typeVersion": 1,
      "position": [
        -864,
        -288
      ],
      "id": "YOUR_ID",
      "name": "Split Out \u2014 (1 attachment = 1 item)"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "YOUR_ID",
              "leftValue": "={{ Object.keys($binary ?? {}).length }}",
              "rightValue": 0,
              "operator": {
                "type": "number",
                "operation": "gt"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        -624,
        -288
      ],
      "id": "YOUR_ID",
      "name": "IF Node \u2014 Condition: Item has $binary"
    },
    {
      "parameters": {
        "inputDataFieldName": "={{ Object.keys($binary)[0] }}",
        "name": "={{ $binary[Object.keys($binary)[0]].fileName }}",
        "driveId": {
          "__rl": true,
          "mode": "list",
          "value": "My Drive"
        },
        "folderId": {
          "__rl": true,
          "value": "YOUR_GOOGLE_DRIVE_FOLDER_ID",
          "mode": "id"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleDrive",
      "typeVersion": 3,
      "position": [
        -336,
        -384
      ],
      "id": "YOUR_ID",
      "name": "Google Drive \u2014 Upload file to RAW folder",
      "credentials": {
        "googleDriveOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "operation": "append",
        "documentId": {
          "__rl": true,
          "value": "YOUR_SPREADSHEET_ID",
          "mode": "list",
          "cachedResultName": "AI_Factory_Control",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1G4x50V3uHSy-jCFt_pf-ZDpvlJN9HPX018-ju8PHdNY/edit?usp=drivesdk"
        },
        "sheetName": {
          "__rl": true,
          "value": "YOUR_SHEET_ID",
          "mode": "list",
          "cachedResultName": "DATA_CATALOG",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1G4x50V3uHSy-jCFt_pf-ZDpvlJN9HPX018-ju8PHdNY/edit#gid=0"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "source": "gmail",
            "status": "raw",
            "added_at": "={{$now}}",
            "filename": "={{ $json[\"originalFilename\"] }}",
            "mime": "={{ $json[\"mimeType\"] }}",
            "raw_path": "={{ $node[\"Google Drive \u2014 Upload file to RAW folder\"].json[\"webViewLink\"] }}",
            "size": "={{ (Number($json[\"size\"]) / 1024).toFixed(2) }} KB",
            "email_id": "={{ $node[\"Split Out \u2014 (1 attachment = 1 item)\"].json[\"messageId\"] }}",
            "id": "={{ $json[\"id\"] }}"
          },
          "matchingColumns": [
            "id"
          ],
          "schema": [
            {
              "id": "id",
              "displayName": "id",
              "required": false,
              "defaultMatch": true,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "source",
              "displayName": "source",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "email_id",
              "displayName": "email_id",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "filename",
              "displayName": "filename",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "mime",
              "displayName": "mime",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "size",
              "displayName": "size",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "raw_path",
              "displayName": "raw_path",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "clean_path",
              "displayName": "clean_path",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "gold_path",
              "displayName": "gold_path",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "status",
              "displayName": "status",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "added_at",
              "displayName": "added_at",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.7,
      "position": [
        -112,
        -384
      ],
      "id": "YOUR_ID",
      "name": "Google Sheets \u2014 Append (DATA_CATALOG)",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "operation": "append",
        "documentId": {
          "__rl": true,
          "value": "YOUR_SPREADSHEET_ID",
          "mode": "list",
          "cachedResultName": "AI_Factory_Control",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1G4x50V3uHSy-jCFt_pf-ZDpvlJN9HPX018-ju8PHdNY/edit?usp=drivesdk"
        },
        "sheetName": {
          "__rl": true,
          "value": "YOUR_SHEET_ID",
          "mode": "list",
          "cachedResultName": "EVENT_LOG",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1G4x50V3uHSy-jCFt_pf-ZDpvlJN9HPX018-ju8PHdNY/edit#gid=2072862873"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "ts": "={{ $now }}",
            "agent": "ingest",
            "action": "save_to_raw_folder",
            "notes": "Attachment saved to RAW folder",
            "input": "={{ $node[\"Split Out \u2014 (1 attachment = 1 item)\"].json[\"messageId\"] }}",
            "output": "={{ $node[\"Google Drive \u2014 Upload file to RAW folder\"].json[\"webViewLink\"] }}",
            "status": "={{ $node[\"Google Sheets \u2014 Append (DATA_CATALOG)\"].json ? \"success\" : \"error\" }}"
          },
          "matchingColumns": [],
          "schema": [
            {
              "id": "ts",
              "displayName": "ts",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "agent",
              "displayName": "agent",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "action",
              "displayName": "action",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "input",
              "displayName": "input",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "output",
              "displayName": "output",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "status",
              "displayName": "status",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "notes",
              "displayName": "notes",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.7,
      "position": [
        112,
        -384
      ],
      "id": "YOUR_ID",
      "name": "Google Sheets \u2014 Append (EVENT_LOG)",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "content": "INGEST Agent",
        "height": 576,
        "width": 1920,
        "color": 6
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1616,
        -544
      ],
      "typeVersion": 1,
      "id": "YOUR_ID",
      "name": "Sticky Note - INGEST"
    }
  ],
  "connections": {
    "Manual Trigger": {
      "main": [
        [
          {
            "node": "Gmail \u2014 Get many messages",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Gmail \u2014 Get many messages": {
      "main": [
        [
          {
            "node": "Gmail \u2014 (Get Message + Download Attachments)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Gmail \u2014 (Get Message + Download Attachments)": {
      "main": [
        [
          {
            "node": "Split Out \u2014 (1 attachment = 1 item)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Out \u2014 (1 attachment = 1 item)": {
      "main": [
        [
          {
            "node": "IF Node \u2014 Condition: Item has $binary",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "IF Node \u2014 Condition: Item has $binary": {
      "main": [
        [
          {
            "node": "Google Drive \u2014 Upload file to RAW folder",
            "type": "main",
            "index": 0
          }
        ],
        []
      ]
    },
    "Google Drive \u2014 Upload file to RAW folder": {
      "main": [
        [
          {
            "node": "Google Sheets \u2014 Append (DATA_CATALOG)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Sheets \u2014 Append (DATA_CATALOG)": {
      "main": [
        [
          {
            "node": "Google Sheets \u2014 Append (EVENT_LOG)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "YOUR_ID",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "id": "ingest_agent_manual_trigger",
  "tags": []
}

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.

Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

INGEST Agent Workflow. Uses gmail, googleDrive, googleSheets. Event-driven trigger; 9 nodes.

Source: https://github.com/anshwysmcbel2710/anis-personal-ai-factory-controller/blob/main/workflows/agents/ingest_agent.json — original creator credit. Request a take-down →

More AI & RAG workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

AI & RAG

This advanced n8n workflow automates the full lead enrichment, qualification, and personalized outreach process tailored specifically for the B2B real estate sector. Integrating top platforms like Api

N8N Nodes Fillout, OpenAI Chat, Pinecone Vector Store +11
AI & RAG

This n8n template automatically classifies incoming emails (Sales, Support, Internal, Finance, Promotions) and routes them to a dedicated OpenAI LLM Agent for processing. Depending on the category, th

OpenAI, Gmail, Text Classifier +16
AI & RAG

This simple philosophy changes the way we think about automated sales agents. Context changes everything. In this 4-part workflow, we start by creating a knowledge base that will act as context across

Pinecone Vector Store, Document Default Data Loader, Text Splitter Recursive Character Text Splitter +12
AI & RAG

This workflow automates the early-stage job application process using AI.

Pinecone Vector Store, Document Default Data Loader, Google Drive +9
AI & RAG

Every company has documents sitting in Google Drive that nobody reads. HR policies, sales playbooks, product FAQs, financial guidelines — all written once, never found again. This workflow turns all o

Google Sheets, Gmail, Google Drive +5