{
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "bb1ccd05-9815-4e29-a58c-df19556a3eff",
      "name": "AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        1136,
        656
      ],
      "parameters": {
        "options": {
          "systemMessage": "You are a helpful assistant that has access to one tool, Pinecone Assistant. This tool should get context snippets based on a query. Include the file name and file url in citations wherever referenced in output."
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "2a28776e-0038-47b2-b034-8c1831e39316",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        1072,
        880
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "c1101518-eb8f-4ac7-82cb-4dbdec371424",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        688,
        -224
      ],
      "parameters": {
        "color": 7,
        "width": 864,
        "height": 640,
        "content": "## 1. Add new or update files from Google Drive to Pinecone Assistant"
      },
      "typeVersion": 1
    },
    {
      "id": "e22e1d25-ee77-417f-8775-c9ba676732ae",
      "name": "File updated",
      "type": "n8n-nodes-base.googleDriveTrigger",
      "position": [
        768,
        160
      ],
      "parameters": {
        "event": "fileUpdated",
        "options": {},
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        },
        "triggerOn": "specificFolder",
        "folderToWatch": {
          "__rl": true,
          "mode": "list",
          "value": "1gsyG6CMIIVkLU9fHpmrrf3GVja6VFDrO",
          "cachedResultUrl": "",
          "cachedResultName": "n8n-pinecone-demo"
        }
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "c03b5276-e734-44e3-95a2-69a9010fefda",
      "name": "File added",
      "type": "n8n-nodes-base.googleDriveTrigger",
      "position": [
        768,
        -128
      ],
      "parameters": {
        "event": "fileCreated",
        "options": {},
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        },
        "triggerOn": "specificFolder",
        "folderToWatch": {
          "__rl": true,
          "mode": "list",
          "value": "1gsyG6CMIIVkLU9fHpmrrf3GVja6VFDrO",
          "cachedResultUrl": "",
          "cachedResultName": "n8n-pinecone-demo"
        }
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "812ecf77-4026-4b86-92b4-9c8a108434eb",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        688,
        544
      ],
      "parameters": {
        "color": 7,
        "width": 864,
        "height": 576,
        "content": "## 2. Chat with your docs"
      },
      "typeVersion": 1
    },
    {
      "id": "4f4e6d2a-568d-448b-8b47-7fc68f4da206",
      "name": "Chat input",
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "position": [
        768,
        656
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 1.3
    },
    {
      "id": "c6661264-14f0-47b0-ba0f-be746c7b7961",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -80,
        -224
      ],
      "parameters": {
        "width": 636,
        "height": 1536,
        "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/)\n* A GCP project with [Google Drive API enabled and configured](https://docs.n8n.io/integrations/builtin/credentials/google/oauth-single-service/)\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 named `n8n-assistant` in the Pinecone Console [here](https://app.pinecone.io/organizations/-/projects/-/assistant) \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. Use the Connect to Pinecone button to authenticate to Pinecone or if you self-host n8n, create a Pinecone credential and add your [Pinecone API key](https://app.pinecone.io/organizations/-/projects/-/keys) directly\n4. Select your Assistant Name in each of the Pinecone Assistant nodes\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 and/or Snippet Size values to help manage token consumption by adding the Top K and/or Snippet Size parameters to Get context from Assistant node\n- Filter the context snippets even further by adding metadata filters to the Get context from Assistant node\n\n### Need help?\n\nYou can find help by asking in the [Pinecone Discord community](https://discord.gg/tJ8V62S3sH) or [filing an issue](https://github.com/pinecone-io/n8n-templates/issues/new/choose) on this repo."
      },
      "typeVersion": 1
    },
    {
      "id": "e007c0da-83eb-4248-af8b-eb4f8fdbce3f",
      "name": "Download new file",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        960,
        -128
      ],
      "parameters": {
        "fileId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $json.id }}"
        },
        "options": {
          "fileName": "={{ $json.name }}"
        },
        "operation": "download"
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "38d28c6e-a55e-4591-b389-d1763ee5fd66",
      "name": "Download updated file",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        960,
        160
      ],
      "parameters": {
        "fileId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $json.id }}"
        },
        "options": {
          "fileName": "={{ $json.name }}"
        },
        "operation": "download"
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "1e7c14fa-e09a-4b88-b977-8cacf32557a0",
      "name": "Upload file to Assistant",
      "type": "@pinecone-database/n8n-nodes-pinecone-assistant.pineconeAssistant",
      "position": [
        1168,
        -128
      ],
      "parameters": {
        "resource": "file",
        "operation": "uploadFile",
        "assistantData": "{\"name\":\"n8n-assistant\",\"host\":\"https://prod-1-data.ke.pinecone.io\"}",
        "externalFileId": "={{ $json.id }}",
        "additionalFields": {
          "sourceTag": "n8n:n8n_nodes_pinecone_assistant:chat_with_google_drive_using_pinecone_assistant"
        }
      },
      "credentials": {
        "pineconeApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "c6ab752a-3b7e-4cb1-a87a-583180d5a71b",
      "name": "Get context from Assistant",
      "type": "@pinecone-database/n8n-nodes-pinecone-assistant.pineconeAssistantTool",
      "position": [
        1296,
        864
      ],
      "parameters": {
        "assistantData": "{\"name\":\"n8n-assistant\",\"host\":\"https://prod-1-data.ke.pinecone.io\"}",
        "additionalFields": {
          "sourceTag": "n8n:n8n_nodes_pinecone_assistant:chat_with_google_drive_using_pinecone_assistant"
        }
      },
      "credentials": {
        "pineconeApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "c6b52ee8-d0ae-4682-a560-f96c249541f9",
      "name": "Update file in Assistant",
      "type": "@pinecone-database/n8n-nodes-pinecone-assistant.pineconeAssistant",
      "position": [
        1168,
        160
      ],
      "parameters": {
        "resource": "file",
        "operation": "updateFile",
        "assistantData": "{\"name\":\"n8n-assistant\",\"host\":\"https://prod-1-data.ke.pinecone.io\"}",
        "externalFileId": "={{ $json.id }}",
        "additionalFields": {
          "sourceTag": "n8n:n8n_nodes_pinecone_assistant:chat_with_google_drive_using_pinecone_assistant"
        }
      },
      "credentials": {
        "pineconeApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    }
  ],
  "connections": {
    "Chat input": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "File added": {
      "main": [
        [
          {
            "node": "Download new file",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "File updated": {
      "main": [
        [
          {
            "node": "Download updated file",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download new file": {
      "main": [
        [
          {
            "node": "Upload file to Assistant",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Download updated file": {
      "main": [
        [
          {
            "node": "Update file in Assistant",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get context from Assistant": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    }
  }
}