Workflow: Google Drive Automation
Integrations: code, extractFromFile, googleDrive, googleDriveTrigger, noOp, stopAndError

{"id": "lC8xkfCSTjIiUhpk", "meta": {"instanceId": "workflow-7e960603", "versionId": "1.0.0", "createdAt": "2025-09-29T07:07:43.842207", "updatedAt": "2025-09-29T07:07:43.842222", "owner": "n8n-user", "license": "MIT", "category": "automation", "status": "active", "priority": "high", "environment": "production"}, "name": "Google Drive Automation", "tags": ["automation", "n8n", "production-ready", "excellent", "optimized"], "nodes": [{"id": "e7769ee7-a247-426e-b792-c095597ada54", "name": "AI Agent", "type": "n8n-nodes-base.noOp", "position": [320, 700], "parameters": {"text": "={{ $json.prompt }}", "options": {"systemMessage": "You are a knowledgeable and helpful assistant. Respond with clear, concise, and detailed answers formatted in markdown. Use proper markdown formatting including headings, bullet points, numbered lists, code blocks, and other structures as needed to improve readability and clarity."}, "promptType": "define"}, "typeVersion": 1.7, "notes": "This agent node performs automated tasks as part of the workflow."}, {"id": "72ca46ad-891f-42f2-81d7-00e04e1c6f5f", "name": "Monitor Google Drive for New Files", "type": "n8n-nodes-base.googleDriveTrigger", "position": [-520, -240], "parameters": {"event": "fileCreated", "options": {}, "pollTimes": {"item": [{}]}, "triggerOn": "specificFolder", "folderToWatch": {"__rl": true, "mode": "list", "value": "1RQvAHIw8cQbtwI9ZvdVV0k0x6TM6HZwP", "cachedResultUrl": "{{ $env.WEBHOOK_URL }}", "cachedResultName": "RAG_Files"}}, "credentials": {"googleDriveOAuth2Api": {"id": "zj3v6gsTRb9CreKV", "name": "Google Drive account"}}, "typeVersion": 1, "notes": "This googleDriveTrigger node performs automated tasks as part of the workflow."}, {"id": "03e9dc61-bdba-49d7-859e-73b8adebae41", "name": "Download File from Google Drive", "type": "n8n-nodes-base.googleDrive", "position": [-300, -240], "parameters": {"fileId": {"__rl": true, "mode": "id", "value": "={{ $json.id }}"}, "options": {}, "operation": "download"}, "credentials": {"googleDriveOAuth2Api": {"id": "zj3v6gsTRb9CreKV", "name": "Google Drive account"}}, "typeVersion": 3, "notes": "This googleDrive node performs automated tasks as part of the workflow."}, {"id": "782fc162-0c3f-40fc-af92-455c1250ede0", "name": "Extract PDF Content", "type": "n8n-nodes-base.extractFromFile", "position": [-80, -240], "parameters": {"options": {}, "operation": "pdf"}, "typeVersion": 1, "notes": "This extractFromFile node performs automated tasks as part of the workflow."}, {"id": "b8da9cff-756b-419e-b39a-4ad1020092d0", "name": "Insert Document into Pinecone Vector Store", "type": "n8n-nodes-base.noOp", "position": [360, -240], "parameters": {"mode": "insert", "options": {}, "pineconeIndex": {"__rl": true, "mode": "list", "value": "n8n-rag-demo", "cachedResultName": "n8n-rag-demo"}}, "credentials": {"pineconeApi": {"id": "ldIxYWz8E9e0N4yV", "name": "PineconeApi account"}}, "typeVersion": 1, "notes": "This vectorStorePinecone node performs automated tasks as part of the workflow."}, {"id": "f5b93646-b466-4cd7-aec9-6fae62023fa3", "name": "Generate Document Embeddings (Google Gemini)", "type": "n8n-nodes-base.noOp", "position": [260, 20], "parameters": {"modelName": "models/text-embedding-004"}, "credentials": {"googlePalmApi": {"id": "prd6Qnbbj4UbNH75", "name": "Google Gemini(PaLM) Api account"}}, "typeVersion": 1, "notes": "This embeddingsGoogleGemini node performs automated tasks as part of the workflow."}, {"id": "b5277663-3120-4614-85e3-f7dc05c4e1c2", "name": "Clean and Normalize PDF Text", "type": "n8n-nodes-base.code", "position": [140, -240], "parameters": {"jsCode": "const rawData = $json[\"text\"];\nconst cleanedData = rawData\n  .replace(/(\\r\\n|\\n|\\r)/gm, \" \")   // remove line breaks\n  .trim()                           // remove extra spaces\n  .replace(/[^\\w\\s]/gi, \"\");         // remove special characters\nreturn { cleanedData };\n"}, "typeVersion": 2, "notes": "This code node performs automated tasks as part of the workflow."}, {"id": "68aa5515-6b58-4e98-ab08-4d9516e1f2a3", "name": "Load Document Data for Processing", "type": "n8n-nodes-base.noOp", "position": [480, 20], "parameters": {"options": {}}, "typeVersion": 1, "notes": "This documentDefaultDataLoader node performs automated tasks as part of the workflow."}, {"id": "3f463338-c692-4b7b-a888-8c00d190c441", "name": "Split Document Text into Chunks", "type": "n8n-nodes-base.noOp", "position": [380, 240], "parameters": {"options": {}, "chunkSize": 3000, "chunkOverlap": 300}, "typeVersion": 1, "notes": "This textSplitterRecursiveCharacterTextSplitter node performs automated tasks as part of the workflow."}, {"id": "9c4a7ec9-0808-443f-9e12-9ec12c7288b9", "name": "Chat Message Trigger", "type": "n8n-nodes-base.noOp", "position": [-520, 700], "webhookId": "d36e67b9-a789-4801-b624-64bf8b88d702", "parameters": {"options": {}}, "typeVersion": 1.1, "notes": "This chatTrigger node performs automated tasks as part of the workflow."}, {"id": "ee62efc9-60b2-40ec-a10c-8897d24b1429", "name": "Retrieve Relevant Documents from Pinecone", "type": "n8n-nodes-base.noOp", "position": [-260, 700], "parameters": {"mode": "load", "prompt": "={{ $json.chatInput }}", "options": {}, "pineconeIndex": {"__rl": true, "mode": "list", "value": "n8n-rag-demo", "cachedResultName": "n8n-rag-demo"}}, "credentials": {"pineconeApi": {"id": "ldIxYWz8E9e0N4yV", "name": "PineconeApi account"}}, "typeVersion": 1, "notes": "This vectorStorePinecone node performs automated tasks as part of the workflow."}, {"id": "8d479b6b-3c87-40c6-8a68-4390e6bafac8", "name": "Generate Query Embeddings (Google Gemini)", "type": "n8n-nodes-base.noOp", "position": [-280, 940], "parameters": {"modelName": "models/text-embedding-004"}, "credentials": {"googlePalmApi": {"id": "prd6Qnbbj4UbNH75", "name": "Google Gemini(PaLM) Api account"}}, "typeVersion": 1, "notes": "This embeddingsGoogleGemini node performs automated tasks as part of the workflow."}, {"id": "f521d243-1b62-4bc5-972d-736c65c48818", "name": "Generate Chat Prompt with Context", "type": "n8n-nodes-base.code", "position": [100, 700], "parameters": {"jsCode": "const userQuery =  $('Chat Message Trigger').first().json.chatInput\n// Retrieve the user query from the previous node output.\n// Assuming the Pinecone node has passed an array of items where each item has a document and score:\nlet documents = items.map(item => {\n  return {\n    pageContent: item.json.document.pageContent,\n    score: item.json.score\n  };\n});\n\n// Sort the documents by their score in descending order.\ndocuments.sort((a, b) => b.score - a.score);\n\n// Pick the top 3 documents to use as context.\nconst topDocuments = documents.slice(0, 3);\n\n// Combine the top documents into one context string.\nconst contextContent = topDocuments\n  .map((doc, index) => `Document ${index + 1}:\\n${doc.pageContent}`)\n  .join(\"\\n\\n\");\n\n// Build the final prompt that combines the context with the user query.\nconst prompt = `Using the following context from documents:\\n\\n${contextContent}\\n\\nAnswer the following question:\\n${userQuery}\\n\\nAnswer:`;\n\n// Return the prompt so it can be passed to a Chat/AI node for further processing.\nreturn [{ json: { prompt } }];\n"}, "typeVersion": 2, "notes": "This code node performs automated tasks as part of the workflow."}, {"id": "208057c8-8672-41d2-9c99-89e52856a742", "name": "OpenRouter Chat Model Interface", "type": "n8n-nodes-base.noOp", "position": [280, 940], "parameters": {"model": "google/gemini-2.0-flash-exp:free", "options": {}}, "credentials": {"openRouterApi": {"id": "iTDRPtvPicVqeXaT", "name": "OpenRouter account"}}, "typeVersion": 1, "notes": "This lmChatOpenRouter node performs automated tasks as part of the workflow."}, {"id": "error-600a3383", "name": "Error Handler", "type": "n8n-nodes-base.stopAndError", "typeVersion": 1, "position": [1000, 400], "parameters": {"message": "Workflow execution error", "options": {}}}], "active": false, "pinData": {}, "settings": {"executionOrder": "v1", "saveManualExecutions": true, "callerPolicy": "workflowsFromSameOwner", "errorWorkflow": null, "timezone": "UTC", "executionTimeout": 3600, "maxExecutions": 1000, "retryOnFail": true, "retryCount": 3, "retryDelay": 1000}, "versionId": "43fd0dd9-5ec1-401a-b1c2-368b15c9f0db", "connections": {"72ca46ad-891f-42f2-81d7-00e04e1c6f5f": {"main": [[{"node": "error-handler-72ca46ad-891f-42f2-81d7-00e04e1c6f5f-72613183", "type": "main", "index": 0}]]}, "03e9dc61-bdba-49d7-859e-73b8adebae41": {"main": [[{"node": "error-handler-03e9dc61-bdba-49d7-859e-73b8adebae41-9c94dc19", "type": "main", "index": 0}]]}, "782fc162-0c3f-40fc-af92-455c1250ede0": {"main": [[{"node": "error-handler-782fc162-0c3f-40fc-af92-455c1250ede0-1e9dccd1", "type": "main", "index": 0}]]}, "f5b93646-b466-4cd7-aec9-6fae62023fa3": {"main": [[{"node": "error-handler-f5b93646-b466-4cd7-aec9-6fae62023fa3-444bce0b", "type": "main", "index": 0}]]}, "8d479b6b-3c87-40c6-8a68-4390e6bafac8": {"main": [[{"node": "error-handler-8d479b6b-3c87-40c6-8a68-4390e6bafac8-c8f41a03", "type": "main", "index": 0}]]}}, "description": "Automated workflow: Google Drive Automation. This workflow processes data and performs automated tasks.", "notes": "Excellent quality workflow: Google Drive Automation. This workflow has been optimized for production use with comprehensive error handling, security, and documentation."}