{
  "name": "Google Drive Files Loader",
  "nodes": [
    {
      "id": "3d066626-a87d-4e7b-bc16-9f47e1277dde",
      "name": "When Executed by Another Workflow",
      "type": "n8n-nodes-base.executeWorkflowTrigger",
      "position": [
        0,
        0
      ],
      "parameters": {
        "inputSource": "jsonExample",
        "jsonExample": "{\n}"
      },
      "typeVersion": 1.1
    },
    {
      "id": "cb0e5563-1550-4121-9fd5-b1cbd9810476",
      "name": "Code",
      "type": "n8n-nodes-base.code",
      "position": [
        960,
        0
      ],
      "parameters": {
        "jsCode": "// n8n Code Node\n\n// Initialize an empty object to store the aggregated results\nconst aggregatedDict = {};\n\n// Get all input items passed to this node\nconst inputItems = $input.all();\n\n// Loop through each input item\nfor (const item of inputItems) {\n  // Get the JSON data from the current item\n  const itemJson = item.json;\n\n  // Check if item.json is actually an object and not null/undefined\n  // Also ensure it's not an array, as we expect key-value pairs\n  if (itemJson && typeof itemJson === 'object' && !Array.isArray(itemJson)) {\n\n    // Iterate over all the keys within the current item's JSON object\n    for (const key of Object.keys(itemJson)) {\n      // Add/overwrite the key-value pair to our aggregated dictionary\n      aggregatedDict[key] = itemJson[key].replaceAll(/\\n+/g, \"\\n\");\n      // console.log(`Adding/Updating key: ${key}`); // Optional: for debugging\n    }\n\n  } else {\n    // Optional: Log a warning if an item doesn't have the expected format\n    console.warn(`Skipping item - 'json' property is not a valid object:`, itemJson);\n  }\n}\n\n// n8n expects an array of items as output.\n// We return a single item containing the final aggregated dictionary in its 'json' property.\nreturn [{ json: aggregatedDict }];"
      },
      "typeVersion": 2
    },
    {
      "id": "1b90ca95-7251-4573-9b0b-4af3622721ba",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        140,
        -140
      ],
      "parameters": {
        "height": 300,
        "content": "## Step1\nDefine folder you want to search all files in."
      },
      "typeVersion": 1
    },
    {
      "id": "d26c2f27-0095-4dd6-9aa5-94c68f58bda3",
      "name": "Get files from folder",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        220,
        0
      ],
      "parameters": {
        "filter": {
          "folderId": {
            "mode": "list",
            "value": "root",
            "cachedResultName": "/ (Root folder)"
          }
        },
        "options": {},
        "resource": "fileFolder"
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "938c8f7c-84b1-4eeb-a7c8-894ae5fbc275",
      "name": "Download Google Docs",
      "type": "n8n-nodes-base.googleDocs",
      "position": [
        500,
        0
      ],
      "parameters": {
        "operation": "get",
        "documentURL": "={{ $json.id }}"
      },
      "credentials": {
        "googleDocsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "caa075a2-2e85-47e5-a829-425a1177e5be",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        420,
        -140
      ],
      "parameters": {
        "height": 300,
        "content": "## Step2\nIf you have files other than google docs change node here."
      },
      "typeVersion": 1
    },
    {
      "id": "05db5439-584e-40aa-9c1d-101618f66fdc",
      "name": "Mapping",
      "type": "n8n-nodes-base.set",
      "position": [
        780,
        0
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "b33e9355-659a-4b71-ba5c-00c90b7ed792",
              "name": "={{ $('Get files from folder').item.json.name }}",
              "type": "string",
              "value": "={{ $json.content }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "85dc7e65-7d50-4b13-b114-88b4020865e8",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        720,
        -140
      ],
      "parameters": {
        "color": 3,
        "width": 400,
        "height": 300,
        "content": "## Mapping\nThis mapping part will output a dictionary with key:value where key if file name and value is file content"
      },
      "typeVersion": 1
    }
  ],
  "connections": {
    "Mapping": {
      "main": [
        [
          {
            "node": "Code",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download Google Docs": {
      "main": [
        [
          {
            "node": "Mapping",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get files from folder": {
      "main": [
        [
          {
            "node": "Download Google Docs",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When Executed by Another Workflow": {
      "main": [
        [
          {
            "node": "Get files from folder",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}