{
  "updatedAt": "2025-11-07T14:16:13.000Z",
  "createdAt": "2025-11-07T12:07:09.822Z",
  "id": "mpMlfXSSQNlvxjk9",
  "name": "41. The secret no one told you to maximize RAG AI Agent accuracy",
  "active": false,
  "isArchived": false,
  "nodes": [
    {
      "parameters": {
        "operation": "download",
        "fileId": {
          "__rl": true,
          "value": "={{ $json.id }}",
          "mode": "id"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleDrive",
      "typeVersion": 3,
      "position": [
        -1056,
        176
      ],
      "id": "cf8ac7db-1cfb-4dca-998c-7c8ef0f6052d",
      "name": "Download file",
      "credentials": {
        "googleDriveOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "mode": "insert",
        "pineconeIndex": {
          "__rl": true,
          "value": "appel",
          "mode": "list",
          "cachedResultName": "appel"
        },
        "embeddingBatchSize": 2,
        "options": {
          "pineconeNamespace": "={{ $json.File_Name }}"
        }
      },
      "type": "@n8n/n8n-nodes-langchain.vectorStorePinecone",
      "typeVersion": 1.3,
      "position": [
        -480,
        176
      ],
      "id": "5e86ad30-179b-4366-9236-1f876908db68",
      "name": "Pinecone Vector Store",
      "credentials": {
        "pineconeApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "dataType": "binary",
        "textSplittingMode": "custom",
        "options": {
          "metadata": {
            "metadataValues": [
              {
                "name": "Apple_Report",
                "value": "={{ $json.name }}"
              }
            ]
          }
        }
      },
      "type": "@n8n/n8n-nodes-langchain.documentDefaultDataLoader",
      "typeVersion": 1.1,
      "position": [
        -368,
        464
      ],
      "id": "8866273c-1dcd-4e9e-a6a5-c1994479b89f",
      "name": "Default Data Loader"
    },
    {
      "parameters": {
        "content": "# Knowledge Base\n",
        "height": 796,
        "width": 1436,
        "color": 4
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -1472,
        32
      ],
      "id": "de8fed7a-5d36-4b89-8f63-b6af14d4c9f9",
      "name": "Sticky Note"
    },
    {
      "parameters": {
        "content": "# RAG Chatbot\n",
        "height": 940,
        "width": 920,
        "color": 5
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        0,
        0
      ],
      "id": "cccf5007-bb61-43c2-a005-7fa274412d45",
      "name": "Sticky Note1"
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "={{ $('When chat message received').item.json.chatInput }}",
        "options": {
          "systemMessage": "=You are an AI assistant specialized in analyzing Apple\u2019s quarterly financial reports. Your main goal is to answer questions accurately and precisely using the vector database, which contains relevant Q1 reports.\n\nProvide only information that comes directly from these reports or verified data. If the requested information is missing or unclear, explicitly state that there is insufficient data.\n\nKeep responses concise and to the point. Include specific numbers and facts whenever possible, and clearly indicate whether the information is sourced from Q1 or Q2.\n\nDeliver quick, reliable insights into Apple\u2019s quarterly financials without adding unnecessary details."
        }
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 2,
      "position": [
        400,
        176
      ],
      "id": "4a4bf735-8da3-4137-9cc2-6fe7bff3de05",
      "name": "AI Agent"
    },
    {
      "parameters": {
        "description": "Returns documents related to Apple Q1 report, including financials, outlook, margins, and all key details from the earnings reports.",
        "topK": "=10"
      },
      "type": "@n8n/n8n-nodes-langchain.toolVectorStore",
      "typeVersion": 1.1,
      "position": [
        512,
        432
      ],
      "id": "e197bb62-92d6-4c9f-91d7-0a5a7d582516",
      "name": "Answer questions with a vector store"
    },
    {
      "parameters": {
        "public": true,
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "typeVersion": 1.1,
      "position": [
        16,
        176
      ],
      "id": "4da2f44d-9a51-480a-a7c2-066786a60169",
      "name": "When chat message received"
    },
    {
      "parameters": {
        "pineconeIndex": {
          "__rl": true,
          "value": "appel",
          "mode": "list",
          "cachedResultName": "appel"
        },
        "options": {
          "pineconeNamespace": "={{ $json.File_Name }}"
        }
      },
      "type": "@n8n/n8n-nodes-langchain.vectorStorePinecone",
      "typeVersion": 1.3,
      "position": [
        208,
        592
      ],
      "id": "dfcd8f4b-feb5-406f-b859-d70cd3925815",
      "name": "Pinecone Vector Store1",
      "credentials": {
        "pineconeApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        },
        "triggerOn": "specificFolder",
        "folderToWatch": {
          "__rl": true,
          "value": "1SPu2tAKIm_zXDUtUyIbt-w7I1myLXyyN",
          "mode": "list",
          "cachedResultName": "Appel",
          "cachedResultUrl": "https://drive.google.com/drive/folders/1SPu2tAKIm_zXDUtUyIbt-w7I1myLXyyN"
        },
        "event": "fileCreated",
        "options": {}
      },
      "type": "n8n-nodes-base.googleDriveTrigger",
      "typeVersion": 1,
      "position": [
        -1424,
        176
      ],
      "id": "ef767adb-2fc8-437e-9c7d-337ea2fee54a",
      "name": "Google Drive Trigger",
      "credentials": {
        "googleDriveOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        -1424,
        352
      ],
      "id": "ea4b3bbe-9480-469f-8ace-f1746a2a83cd",
      "name": "When clicking \u2018Execute workflow\u2019"
    },
    {
      "parameters": {
        "resource": "fileFolder",
        "filter": {
          "folderId": {
            "__rl": true,
            "value": "1SPu2tAKIm_zXDUtUyIbt-w7I1myLXyyN",
            "mode": "list",
            "cachedResultName": "Appel",
            "cachedResultUrl": "https://drive.google.com/drive/folders/1SPu2tAKIm_zXDUtUyIbt-w7I1myLXyyN"
          }
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleDrive",
      "typeVersion": 3,
      "position": [
        -1264,
        352
      ],
      "id": "9c9e7834-4c85-4a63-a1f7-9dd63ed164a4",
      "name": "Search files and folders",
      "credentials": {
        "googleDriveOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "operation": "download",
        "fileId": {
          "__rl": true,
          "value": "={{ $json.File_ID }}",
          "mode": "id"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleDrive",
      "typeVersion": 3,
      "position": [
        -928,
        352
      ],
      "id": "049e5790-4693-4999-bd5f-47fe82f75324",
      "name": "Download file1",
      "credentials": {
        "googleDriveOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "n8n-nodes-base.splitInBatches",
      "typeVersion": 3,
      "position": [
        -688,
        80
      ],
      "id": "6a9d3547-1a34-4d3a-9ea8-97f6c64bd901",
      "name": "Loop Over Items"
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.textSplitterRecursiveCharacterTextSplitter",
      "typeVersion": 1,
      "position": [
        -432,
        656
      ],
      "id": "4f47805a-316a-42dd-9b97-cfe2846e8e26",
      "name": "Recursive Character Text Splitter"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "dda116d7-f64b-48b8-9f22-fb35eb43c245",
              "name": "File_Name",
              "value": "={{ $json.name }}",
              "type": "string"
            },
            {
              "id": "3562a21f-d55f-4191-8f7a-cebb23c1da3b",
              "name": "File_ID",
              "value": "={{ $json.id }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -1088,
        352
      ],
      "id": "64126d73-b536-4b7a-9f52-e3bb2a914b6c",
      "name": "Edit Fields"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "c183a9f9-0bbd-40e4-ac35-b5111e3ec1ae",
              "name": "File_Name",
              "value": "={{$json[\"chatInput\"].match(/Q[1-4]/i) ? ($json[\"chatInput\"].match(/Q[1-4]/i)[0].toUpperCase() + \".pdf\").trim() : \"\"}}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        192,
        176
      ],
      "id": "b8846e9d-5347-4673-a08c-998893627287",
      "name": "Edit Fields1"
    },
    {
      "parameters": {},
      "type": "@n8n/n8n-nodes-langchain.embeddingsGoogleGemini",
      "typeVersion": 1,
      "position": [
        -672,
        528
      ],
      "id": "c52e16aa-e267-485b-845d-c56d14d49c48",
      "name": "Embeddings Google Gemini",
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "typeVersion": 1,
      "position": [
        272,
        384
      ],
      "id": "72f444cc-dc30-4d70-95de-7973a0b82416",
      "name": "Google Gemini Chat Model",
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "typeVersion": 1,
      "position": [
        560,
        656
      ],
      "id": "a31c81f0-46e1-4b2d-b8a7-e00dcef3d95e",
      "name": "Google Gemini Chat Model1",
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {},
      "type": "@n8n/n8n-nodes-langchain.embeddingsGoogleGemini",
      "typeVersion": 1,
      "position": [
        176,
        768
      ],
      "id": "3694d4f7-98e5-4765-b8fe-43588f601af5",
      "name": "Embeddings Google Gemini1",
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      }
    }
  ],
  "connections": {
    "Download file": {
      "main": [
        [
          {
            "node": "Pinecone Vector Store",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Default Data Loader": {
      "ai_document": [
        [
          {
            "node": "Pinecone Vector Store",
            "type": "ai_document",
            "index": 0
          }
        ]
      ]
    },
    "Answer questions with a vector store": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "When chat message received": {
      "main": [
        [
          {
            "node": "Edit Fields1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Pinecone Vector Store1": {
      "ai_vectorStore": [
        [
          {
            "node": "Answer questions with a vector store",
            "type": "ai_vectorStore",
            "index": 0
          }
        ]
      ]
    },
    "Pinecone Vector Store": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Drive Trigger": {
      "main": [
        [
          {
            "node": "Download file",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When clicking \u2018Execute workflow\u2019": {
      "main": [
        [
          {
            "node": "Search files and folders",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Search files and folders": {
      "main": [
        [
          {
            "node": "Edit Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download file1": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items": {
      "main": [
        [],
        [
          {
            "node": "Pinecone Vector Store",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Recursive Character Text Splitter": {
      "ai_textSplitter": [
        [
          {
            "node": "Default Data Loader",
            "type": "ai_textSplitter",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields": {
      "main": [
        [
          {
            "node": "Download file1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields1": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Embeddings Google Gemini": {
      "ai_embedding": [
        [
          {
            "node": "Pinecone Vector Store",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model1": {
      "ai_languageModel": [
        [
          {
            "node": "Answer questions with a vector store",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Embeddings Google Gemini1": {
      "ai_embedding": [
        [
          {
            "node": "Pinecone Vector Store1",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  },
  "staticData": null,
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "versionId": "2b5aab0c-89e4-401b-ad80-872ddb3dee2b",
  "activeVersionId": null,
  "triggerCount": 0,
  "shared": [
    {
      "updatedAt": "2025-11-07T12:07:09.843Z",
      "createdAt": "2025-11-07T12:07:09.843Z",
      "role": "workflow:owner",
      "workflowId": "mpMlfXSSQNlvxjk9",
      "projectId": "HHopAZ4lOFgjhBzT"
    }
  ],
  "activeVersion": null,
  "tags": []
}