Workflow: chat-with-google-drive-using-pinecone-assistant
Integrations: googleDrive, googleDriveTrigger, httpRequest, set, stickyNote, switch, wait

{"nodes": [{"parameters": {"method": "POST", "url": "=https://prod-1-data.ke.pinecone.io/assistant/files/n8n-assistant", "authentication": "predefinedCredentialType", "nodeCredentialType": "pineconeApi", "sendQuery": true, "queryParameters": {"parameters": [{"name": "metadata", "value": "={\n  \"external_file_id\": \"{{ $json.id }}\",\n  \"external_file_name\": \"{{ $json.name }}\"\n}"}]}, "sendBody": true, "contentType": "multipart-form-data", "bodyParameters": {"parameters": [{"parameterType": "formBinaryData", "name": "file", "inputDataFieldName": "data"}]}, "options": {}}, "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [1808, -160], "id": "42bb3e3b-1636-46e2-958e-64af75fade80", "name": "Upload file to assistant", "credentials": {"httpHeaderAuth": {"id": "GvkhUuYna3y7p9e8", "name": "Pinecone API key - HTTP"}, "pineconeApi": {"id": "pBm0ARHJdLXfTUXe", "name": "Pinecone"}}}, {"parameters": {"operation": "download", "fileId": {"__rl": true, "value": "={{ $json.id }}", "mode": "id"}, "options": {"fileName": "={{ $json.name }}"}}, "type": "n8n-nodes-base.googleDrive", "typeVersion": 3, "position": [1616, -160], "id": "df16c93e-d136-470e-981d-2c0cb0b8c75d", "name": "Download file", "credentials": {"googleDriveOAuth2Api": {"id": "jfHLEN7hcvGOLbW5", "name": "Google Drive account"}}}, {"parameters": {"options": {"systemMessage": "You are a helpful assistant that has access to one tool, Pinecone Assistant MCP server. This tool should use the get_context function. Include the file name and file url in citations wherever referenced in output."}}, "type": "@n8n/n8n-nodes-langchain.agent", "typeVersion": 2.2, "position": [1168, 624], "id": "6b6b8e41-79a0-48a8-a8cc-077abb4e9593", "name": "AI Agent"}, {"parameters": {"model": {"__rl": true, "mode": "list", "value": "gpt-4.1-mini"}, "options": {}}, "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi", "typeVersion": 1.2, "position": [1104, 848], "id": "a42a4cf7-abb2-4be4-a1b8-2bd8e12603c6", "name": "OpenAI Chat Model", "credentials": {"openAiApi": {"id": "gv5VN25jRLU7YkML", "name": "OpenAI"}}}, {"parameters": {"method": "DELETE", "url": "=https://prod-1-data.ke.pinecone.io/assistant/files/n8n-assistant/{{ $json.files[0].id }}", "authentication": "predefinedCredentialType", "nodeCredentialType": "pineconeApi", "options": {"response": {"response": {"responseFormat": "text"}}}}, "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [1216, 128], "id": "4e8f58d3-9867-4783-9d6a-c3698fa67df9", "name": "Delete file from assistant", "credentials": {"httpHeaderAuth": {"id": "GvkhUuYna3y7p9e8", "name": "Pinecone API key - HTTP"}, "pineconeApi": {"id": "pBm0ARHJdLXfTUXe", "name": "Pinecone"}}}, {"parameters": {"content": "## 1. Add new or update files from Google Drive to Pinecone Assistant", "height": 640, "width": 1776, "color": 7}, "type": "n8n-nodes-base.stickyNote", "position": [720, -256], "typeVersion": 1, "id": "a1bee741-f334-4348-8364-70d078da2bb0", "name": "Sticky Note1"}, {"parameters": {"pollTimes": {"item": [{"mode": "everyMinute"}]}, "triggerOn": "specificFolder", "folderToWatch": {"__rl": true, "value": "", "mode": "list", "cachedResultName": "n8n-pinecone-demo", "cachedResultUrl": ""}, "event": "fileUpdated", "options": {}}, "type": "n8n-nodes-base.googleDriveTrigger", "typeVersion": 1, "position": [800, 128], "id": "61a18380-76af-4e1c-af56-3c80cd1ddc95", "name": "File updated", "credentials": {"googleDriveOAuth2Api": {"id": "jfHLEN7hcvGOLbW5", "name": "Google Drive account"}}}, {"parameters": {"pollTimes": {"item": [{"mode": "everyMinute"}]}, "triggerOn": "specificFolder", "folderToWatch": {"__rl": true, "value": "", "mode": "list", "cachedResultName": "n8n-pinecone-demo", "cachedResultUrl": ""}, "event": "fileCreated", "options": {}}, "type": "n8n-nodes-base.googleDriveTrigger", "typeVersion": 1, "position": [800, -160], "id": "af09de5a-495e-489e-9d05-1b434d4500d6", "name": "File added", "credentials": {"googleDriveOAuth2Api": {"id": "jfHLEN7hcvGOLbW5", "name": "Google Drive account"}}}, {"parameters": {"url": "https://prod-1-data.ke.pinecone.io/assistant/files/n8n-assistant", "authentication": "predefinedCredentialType", "nodeCredentialType": "pineconeApi", "sendQuery": true, "queryParameters": {"parameters": [{"name": "filter", "value": "={\n  \"external_file_id\": \"{{ $json.id }}\"\n}"}]}, "options": {}}, "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [1008, 128], "id": "245b7f1d-66c5-4f96-acd9-14d75fe5b4a0", "name": "Get file to delete", "credentials": {"httpHeaderAuth": {"id": "GvkhUuYna3y7p9e8", "name": "Pinecone API key - HTTP"}, "pineconeApi": {"id": "pBm0ARHJdLXfTUXe", "name": "Pinecone"}}}, {"parameters": {"mode": "raw", "jsonOutput": "={\n  \"id\": \"{{ $('File updated').item.json.id }}\",\n  \"name\": \"{{ $('File updated').item.json.name }}\"\n}\n", "options": {}}, "type": "n8n-nodes-base.set", "typeVersion": 3.4, "position": [1408, 128], "id": "b646d256-1ac7-452c-aa5e-a15cf7c6bee1", "name": "Set file data"}, {"parameters": {"content": "## 2. Chat with your docs", "height": 576, "width": 1344, "color": 7}, "type": "n8n-nodes-base.stickyNote", "position": [720, 512], "typeVersion": 1, "id": "8b073801-e2c5-48ec-adba-d80ee4634399", "name": "Sticky Note2"}, {"parameters": {"options": {}}, "type": "@n8n/n8n-nodes-langchain.chatTrigger", "typeVersion": 1.3, "position": [800, 624], "id": "2774dcc8-f067-4a81-bfa6-7559c93c3320", "name": "Chat input", "webhookId": "1bdcb9d4-a367-4d25-9405-ab765e595bf4"}, {"parameters": {"endpointUrl": "https://prod-1-data.ke.pinecone.io/mcp/assistants/n8n-assistant", "serverTransport": "httpStreamable", "authentication": "bearerAuth", "options": {}}, "type": "@n8n/n8n-nodes-langchain.mcpClientTool", "typeVersion": 1.1, "position": [1504, 864], "id": "8c2465d8-1dda-462e-9e85-42dc299cb32c", "name": "Pinecone Assistant", "credentials": {"httpBearerAuth": {"id": "8w7bFCA8t1S9UJgx", "name": "Pinecone Bearer (n8n-demo)"}}}, {"parameters": {"content": "![Pinecone logo](https://www.pinecone.io/images/pinecone-logo-for-n8n-templates.png)\n\n\n## Try it out\n\nThis n8n workflow template lets you chat with your Google Drive documents (.docx, .json, .md, .txt, .pdf) using OpenAI and Pinecone Assistant. It retrieves relevant context from your files in real time so you can get accurate, context-aware answers about your proprietary data\u2014without the need to train your own LLM.\n\n### What is Pinecone Assistant?\n\n[Pinecone Assistant](https://docs.pinecone.io/guides/assistant/overview) allows you to build production-grade chat and agent-based applications quickly. It abstracts the complexities of implementing retrieval-augmented (RAG) systems by managing the chunking, embedding, storage, query planning, vector search, model orchestration, reranking for you.\n\n### Prerequisites\n\n* A [Pinecone account](https://app.pinecone.io/) and [API key](https://app.pinecone.io/organizations/-/projects/-/keys)\n* A GCP project with [Google Drive API enabled and configured](https://docs.n8n.io/integrations/builtin/credentials/google/oauth-single-service/)\n  * Note: When setting up the OAuth consent screen, skip steps 8-10 if running on localhost\n* An [Open AI account](https://auth.openai.com/create-account) and [API key](https://platform.openai.com/settings/organization/api-keys)\n\n### Setup\n\n1. Create a Pinecone Assistant in the Pinecone Console [here](https://app.pinecone.io/organizations/-/projects/-/assistant) \n\t1. Name your Assistant `n8n-assistant` and create it in the `United States` region\n\t2. If you use a different name or region, update the related nodes to reflect these changes\n\t3. No need to configure a Chat model or Assistant instructions\n2. Setup your Google Drive OAuth2 API credential in n8n\n\t1. In the File added node -> Credential to connect with, select Create new credential\n\t2. Set the Client ID and Client Secret from the values generated in the prerequisites\n\t3. Set the OAuth Redirect URL from the n8n credential in the Google Cloud Console ([instructions](https://docs.n8n.io/integrations/builtin/credentials/google/oauth-single-service/#create-your-google-oauth-client-credentials))\n\t4. Name this credential `Google Drive account` so that other nodes reference it\n3. Setup Pinecone API key credential in n8n\n\t1. In the Upload file to assistant node -> PineconeApi section, select Create new credential\n\t2. Paste in your Pinecone API key in the API Key field\n4. Setup Pinecone MCP Bearer auth credential in n8n\n\t1. In the Pinecone Assistant node -> Credential for Bearer Auth section, select Create new credential\n\t2. Set the Bearer Token field to your Pinecone API key used in the previous step\n5. Setup the Open AI credential in n8n\n\t1. In the OpenAI Chat Model node -> Credential to connect with, select Create new credential\n\t2. Set the API Key field to your OpenAI API key\n6. Add your files to a Drive folder named `n8n-pinecone-demo` in the root of your My Drive\n\t1. If you use a different folder name, you'll need to update the Google Drive triggers to reflect that change\n7. Activate the workflow or test it with a manual execution to ingest the documents\n8. Chat with your docs!\n\n### Ideas for customizing this workflow\n\n- Customize the System Message on the AI Agent node to your use case to indicate what kind of knowledge is stored in Pinecone Assistant\n- Change the top_k value of results returned from Assistant by adding \"and should set a top_k of 3\" to the System Message to help manage token consumption\n- Configure the Context Window Length in the Conversation Memory node\n- Swap out the Conversation Memory node for one that is more persistent\n- Make the [chat node publicly available](https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-langchain.chattrigger/#make-chat-publicly-available) or [create your own chat interface](https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-langchain.chattrigger/#mode) that calls the chat webhook URL.\n\n### Need help?\n\nYou can find help by asking in the [Pinecone Discord community](https://discord.gg/tJ8V62S3sH), asking on the [Pinecone Forum](https://community.pinecone.io/), or [filing an issue](https://github.com/pinecone-io/n8n-templates/issues/new/choose) on this repo.", "height": 1696, "width": 636}, "id": "2df456a3-331e-42ee-9f70-582e72d83e6f", "name": "Sticky Note7", "type": "n8n-nodes-base.stickyNote", "position": [-48, -256], "typeVersion": 1}, {"parameters": {"url": "=https://prod-1-data.ke.pinecone.io/assistant/files/n8n-assistant/{{ $json.id }}", "authentication": "predefinedCredentialType", "nodeCredentialType": "pineconeApi", "options": {}}, "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [1856, 128], "id": "0e6c99c7-b606-49e2-8360-103364ab22d0", "name": "Check file status", "credentials": {"httpHeaderAuth": {"id": "GvkhUuYna3y7p9e8", "name": "Pinecone API key - HTTP"}, "pineconeApi": {"id": "pBm0ARHJdLXfTUXe", "name": "Pinecone"}}}, {"parameters": {"amount": 3}, "type": "n8n-nodes-base.wait", "typeVersion": 1.1, "position": [2304, 128], "id": "81b56a1e-ae46-4457-aaea-7dc5f8259d69", "name": "Wait", "webhookId": "67aeb741-7264-44d9-af9d-a349d1d32eac"}, {"parameters": {"rules": {"values": [{"conditions": {"options": {"caseSensitive": true, "leftValue": "", "typeValidation": "strict", "version": 2}, "conditions": [{"id": "7d41378e-7b21-4dbf-8586-f027b3f57d91", "leftValue": "={{ $json.status }}", "rightValue": "Available", "operator": {"type": "string", "operation": "equals", "name": "filter.operator.equals"}}], "combinator": "and"}, "renameOutput": true, "outputKey": "Available"}, {"conditions": {"options": {"caseSensitive": true, "leftValue": "", "typeValidation": "strict", "version": 2}, "conditions": [{"leftValue": "={{ $json.status }}", "rightValue": "Processing", "operator": {"type": "string", "operation": "equals"}, "id": "5d7d1c72-0fdc-4258-ae0f-045f58c37242"}], "combinator": "and"}, "renameOutput": true, "outputKey": "Processing"}]}, "options": {}}, "type": "n8n-nodes-base.switch", "typeVersion": 3.3, "position": [2064, 128], "id": "08870689-0537-49ab-9a12-07b4719f0500", "name": "End if status Available"}, {"parameters": {}, "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow", "typeVersion": 1.3, "position": [1264, 880], "id": "a743300c-c238-47ce-8c5b-fa266b0eb26d", "name": "Conversation Memory"}, {"parameters": {"content": "![Pinecone logo](https://www.pinecone.io/images/pinecone-logo-for-n8n-templates.png)", "height": 240, "color": 7}, "type": "n8n-nodes-base.stickyNote", "position": [1424, 752], "typeVersion": 1, "id": "5299b25d-e202-471e-9ff0-63ccd341f99d", "name": "Sticky Note"}, {"parameters": {"content": "![Pinecone logo](https://www.pinecone.io/images/pinecone-logo-for-n8n-templates.png)", "height": 240, "color": 7}, "type": "n8n-nodes-base.stickyNote", "position": [1136, 48], "typeVersion": 1, "id": "85636b67-7657-42d3-80ce-56660b38d28f", "name": "Sticky Note3"}, {"parameters": {"content": "![Pinecone logo](https://www.pinecone.io/images/pinecone-logo-for-n8n-templates.png)", "height": 240, "color": 7}, "type": "n8n-nodes-base.stickyNote", "position": [1744, -240], "typeVersion": 1, "id": "aa6e7c58-f06a-4a69-87e6-46fa4b7b811b", "name": "Sticky Note4"}, {"parameters": {"content": "![Pinecone logo](https://www.pinecone.io/images/pinecone-logo-for-n8n-templates.png)", "height": 240, "color": 7}, "type": "n8n-nodes-base.stickyNote", "position": [1776, 48], "typeVersion": 1, "id": "01f3bfb5-31ff-471f-9b9f-f38b9b6d762a", "name": "Sticky Note5"}], "connections": {"Upload file to assistant": {"main": [[{"node": "Check file status", "type": "main", "index": 0}]]}, "Download file": {"main": [[{"node": "Upload file to assistant", "type": "main", "index": 0}]]}, "OpenAI Chat Model": {"ai_languageModel": [[{"node": "AI Agent", "type": "ai_languageModel", "index": 0}]]}, "Delete file from assistant": {"main": [[{"node": "Set file data", "type": "main", "index": 0}]]}, "File updated": {"main": [[{"node": "Get file to delete", "type": "main", "index": 0}]]}, "File added": {"main": [[{"node": "Download file", "type": "main", "index": 0}]]}, "Get file to delete": {"main": [[{"node": "Delete file from assistant", "type": "main", "index": 0}]]}, "Set file data": {"main": [[{"node": "Download file", "type": "main", "index": 0}]]}, "Chat input": {"main": [[{"node": "AI Agent", "type": "main", "index": 0}]]}, "Pinecone Assistant": {"ai_tool": [[{"node": "AI Agent", "type": "ai_tool", "index": 0}]]}, "Check file status": {"main": [[{"node": "End if status Available", "type": "main", "index": 0}]]}, "Wait": {"main": [[{"node": "Check file status", "type": "main", "index": 0}]]}, "End if status Available": {"main": [[], [{"node": "Wait", "type": "main", "index": 0}]]}, "Conversation Memory": {"ai_memory": [[{"node": "AI Agent", "type": "ai_memory", "index": 0}]]}}, "pinData": {}, "meta": {"templateCredsSetupCompleted": true, "instanceId": "6ae6d27e57788e6797af2bf16734f2cac83ad4b8f8ebbf57445f55ef5d3a52da"}}