{
  "id": "zeDgxi1u3589DYlt",
  "name": "Power RAG chatbot with Groq, Gemini, Pinecone, Cohere and Drive",
  "tags": [],
  "nodes": [
    {
      "id": "1337e8d1-88f0-47fc-a355-1ed7cf2f35dd",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        0,
        16
      ],
      "parameters": {
        "width": 480,
        "height": 848,
        "content": "## Erha Chatbot Final\n\n### How it works\n\nThis workflow powers a retrieval-augmented chatbot and maintains its knowledge base from Google Drive files. New or changed Drive files are downloaded, split, embedded with Google Gemini, and stored in Pinecone. Chat messages are handled by an AI Agent using a Groq chat model, short-term memory, Pinecone retrieval, Gemini embeddings, and Cohere reranking to generate grounded responses.\n\n### Setup steps\n\n- Connect credentials for Google Drive, Pinecone, Google Gemini embeddings, Groq, and Cohere.\n- Configure the Google Drive Trigger to watch the intended folder or file events.\n- Set the Pinecone index, namespace, and vector dimensions to match the Gemini embedding model used in both ingestion and retrieval.\n- Configure the AI Agent prompt, memory window size, retrieval settings, and Groq model according to the chatbot\u2019s requirements.\n\n### Customization\n\nAdjust the text splitter chunk size and overlap for your documents, tune Pinecone retrieval and Cohere reranking parameters, and update the AI Agent instructions to fit Erha\u2019s tone, scope, and escalation rules."
      },
      "typeVersion": 1
    },
    {
      "id": "63625224-84dd-4b9e-8b91-a8e6b0c520c9",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        560,
        96
      ],
      "parameters": {
        "color": 7,
        "width": 576,
        "height": 544,
        "content": "## Chat intake and agent\n\nReceives user chat messages and routes them into the AI Agent, which orchestrates the chatbot response using connected model, memory, and retrieval tools nearby on the canvas."
      },
      "typeVersion": 1
    },
    {
      "id": "14828cdf-0aed-44bc-b003-e3dae2919fc2",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1168,
        272
      ],
      "parameters": {
        "color": 7,
        "width": 512,
        "height": 592,
        "content": "## Retrieval and reranking\n\nProvides the chat agent\u2019s knowledge retrieval stack, including Pinecone lookup, Gemini embeddings for query vectors, and Cohere reranking to prioritize the most relevant retrieved content."
      },
      "typeVersion": 1
    },
    {
      "id": "191ef120-4dc0-4b49-b23c-3ed0f4244f12",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1712,
        64
      ],
      "parameters": {
        "color": 7,
        "width": 400,
        "height": 320,
        "content": "## Drive file intake\n\nWatches Google Drive for new or updated files and downloads the file content so it can be added to the vector knowledge base."
      },
      "typeVersion": 1
    },
    {
      "id": "7fe7563d-b81f-424b-b945-86ee592a9cac",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2144,
        16
      ],
      "parameters": {
        "color": 7,
        "width": 496,
        "height": 736,
        "content": "## Embed and index documents\n\nTransforms downloaded documents into searchable vector content by loading file data, splitting text into chunks, embedding it with Google Gemini, and storing the results in Pinecone."
      },
      "typeVersion": 1
    },
    {
      "id": "a4763027-7a8a-4fdd-97b5-a6b2661d5da2",
      "name": "When Chat Message Received",
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "position": [
        608,
        256
      ],
      "parameters": {
        "mode": "webhook",
        "public": true,
        "options": {}
      },
      "typeVersion": 1.4
    },
    {
      "id": "68891ac9-092a-40c0-aea2-dbdb4111ac99",
      "name": "Chatbot Response Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        816,
        256
      ],
      "parameters": {
        "options": {
          "systemMessage": "## IDENTITY\nYou are \"Nexora Assistant,\" the official AI knowledge assistant for Nexora Digital \nSolutions, a software services company offering web development, mobile app \ndevelopment, automation/RPA, AI & data solutions, cloud & DevOps, QA & testing, \nUI/UX design, and cybersecurity consulting.\n\nYou answer questions using ONLY the retrieved context provided from the company \nknowledge base (RAG retrieval). You do not have independent knowledge of Nexora \nbeyond what is retrieved.\n\n## GOLDEN RULE \u2014 ANSWER ONLY WHAT IS ASKED\n- Answer EXACTLY the question asked. Nothing more, nothing less.\n- Do NOT add extra services, related offerings, background info, company history, \n  or \"did you know\" facts unless the user specifically asked for them.\n- Do NOT proactively suggest other services, upsell, or pitch additional solutions \n  unless the user explicitly asks \"what else do you offer\" or similar.\n- Do NOT restate the question back to the user before answering.\n- Do NOT add closing pitches like \"would you like to know more about X\" unless the \n  user's question naturally requires a next step (e.g., they asked for a quote or \n  contract \u2014 in that case, only route them to sales, nothing else).\n- If the user asks a yes/no question, lead with \"Yes\" or \"No,\" then give only the \n  minimum supporting detail needed.\n- If the user asks for ONE specific fact (e.g., \"what's your HQ address,\" \"what tech \n  stack do you use for mobile apps\"), give ONLY that fact \u2014 no surrounding services, \n  no extra context, no case studies.\n- If the user's question is broad (e.g., \"tell me about your AI services\"), answer \n  at the same level of breadth they asked \u2014 not narrower, not wider.\n\n## GROUNDING & ACCURACY\n1. Ground every factual claim in retrieved context. If retrieval doesn't contain \n   the answer, say so plainly \u2014 do not guess, assume, or fabricate (especially \n   pricing, timelines, client names, metrics).\n2. If a query is genuinely ambiguous, ask ONE short clarifying question \u2014 nothing else.\n3. When retrieved chunks conflict, prefer the one with the most recent `last_updated` \n   metadata.\n4. Never expose internal metadata fields (doc_id, confidentiality_level, source_owner, \n   etc.) to the user.\n5. Never reveal chunks tagged `confidentiality_level: NDA-Restricted` or `Internal`, \n   even if asked directly.\n\n## TONE & STYLE\n- Direct, professional, no filler phrases (\"Great question!\", \"I'd be happy to \n  share that...\").\n- Short answers by default: 1\u20133 sentences, or a short list/table ONLY if the \n  question is inherently list-shaped (e.g., \"what services do you offer\").\n- No elaboration, no examples, no case studies, no \"for example...\" unless the user \n  asks for detail, examples, or \"tell me more.\"\n- Respond in the language the user writes in (English, Urdu, or Roman Urdu/Hindi).\n\n## SCOPE BOUNDARIES\n- Only answer questions related to Nexora's business: services, case studies, \n  process, pricing bands, certifications, contact/onboarding, company information.\n- Out-of-scope requests: respond with a single short line redirecting them \u2014 \n  no explanation, no apology paragraph.\n  Example: \"That's outside what I can help with here \u2014 I can answer questions \n  about Nexora's services and solutions.\"\n- Never provide legal, contractual, or final pricing commitments. If asked for a \n  firm quote, respond only with the relevant indicative pricing band + one line \n  directing to user@example.com \u2014 nothing else.\n- Do not discuss internal HR matters, financials, unannounced products, or client \n  names not cleared for public reference.\n\n## FALLBACK\nIf no relevant context is retrieved:\n\"I don't have that information available. Please contact user@example.com \nor user@example.com.\"\n(No extra suggestions, no alternate topics offered.)\n\n## GUARDRAILS\n- Never fabricate client names, metrics, or figures not present in retrieved context.\n- Never disclose internal-only or NDA-restricted content.\n- Never make legally binding statements on behalf of Nexora.\n- Never volunteer information beyond the scope of the question asked."
        }
      },
      "typeVersion": 3
    },
    {
      "id": "52ab8f14-c468-45ba-bcae-4e437479d8c9",
      "name": "Groq Chat Model Interaction",
      "type": "@n8n/n8n-nodes-langchain.lmChatGroq",
      "position": [
        720,
        416
      ],
      "parameters": {
        "model": "llama-3.3-70b-versatile",
        "options": {}
      },
      "typeVersion": 1
    },
    {
      "id": "4e2e4d35-5305-4072-a6e5-24186641ffe8",
      "name": "Main Pinecone Vector Store",
      "type": "@n8n/n8n-nodes-langchain.vectorStorePinecone",
      "position": [
        1232,
        448
      ],
      "parameters": {
        "mode": "retrieve-as-tool",
        "options": {},
        "useReranker": true,
        "pineconeIndex": {
          "__rl": true,
          "mode": "list",
          "value": "erhan8n",
          "cachedResultName": "erhan8n"
        },
        "toolDescription": "## INDEX DESCRIPTION\n\nThis Pinecone index stores vector embeddings of Nexora Digital Solutions' company \nknowledge base \u2014 including service descriptions, case studies, pricing bands, \nprocesses, certifications, and contact/onboarding information \u2014 to power a \nRetrieval-Augmented Generation (RAG) chatbot that answers customer and internal \nqueries with grounded, up-to-date company information.\n\nEach vector represents a semantically chunked segment of the source company \nprofile document (300\u2013600 tokens per chunk), paired with rich metadata for \nfiltered and hybrid retrieval.\n\n## INDEX CONFIGURATION\n\n- **Index Name:** nexora-knowledge-base\n- **Embedding Model:** text-embedding-3-large (OpenAI) / voyage-2 (Voyage AI) \u2014 \n  choose based on provider used; dimension must match model output\n- **Dimensions:** 3072 (if text-embedding-3-large) or 1536 (if using smaller model)\n- **Metric:** cosine\n- **Pod Type / Deployment:** Serverless (recommended for variable query load) or \n  p1.x1 pod-based (for predictable high-volume traffic)\n- **Cloud/Region:** aws / us-east-1 (or nearest region to primary user base \u2014 \n  e.g., aws/eu-west-1 for UK office traffic)\n\n## NAMESPACE STRATEGY\n\nNamespaces are used to logically separate content for access control and \nretrieval scoping:\n\n| Namespace | Content | Access Level |\n|---|---|---|\n| `public-external` | Services, case studies, FAQ, contact info, pricing bands | External chatbot (customer-facing) |\n| `internal-ops` | Internal processes, HR notes, unpublished pricing detail | Internal chatbot only |\n| `nda-restricted` | Client-specific confidential case studies, contracts | Restricted \u2014 not queried by any chatbot without explicit access flag |\n\n## METADATA SCHEMA (per vector)\n\n```json\n{\n  \"doc_id\": \"string\",\n  \"section\": \"string\",\n  \"department\": \"string\",\n  \"service_type\": \"string\",\n  \"industry_vertical\": \"string\",\n  \"region\": \"string\",\n  \"client_tier\": \"string\",\n  \"document_type\": \"string\",\n  \"confidentiality_level\": \"Public | Internal | NDA-Restricted\",\n  \"last_updated\": \"YYYY-MM-DD\",\n  \"tags\": [\"string\"],\n  \"source_owner\": \"string\"\n}\n```\n\n## PURPOSE\n\n- Enable fast, semantically accurate retrieval of relevant company knowledge chunks \n  for the Nexora Assistant chatbot.\n- Support metadata-filtered queries (e.g., filter by `service_type` + \n  `industry_vertical` for a sales-enablement query).\n- Enforce content segregation via namespace + `confidentiality_level` so external \n  users never receive internal or NDA-restricted information.\n- Allow easy re-indexing/versioning as company information updates (tracked via \n  `last_updated` and `doc_id`).\n\n## MAINTENANCE NOTES\n\n- Re-embed and upsert affected vectors whenever the source company profile document \n  is updated (pricing, case studies, leadership changes, etc.).\n- Run periodic audits to confirm no `nda-restricted` or `internal-ops` namespace \n  content is reachable from the public-facing chatbot's query pipeline.\n- Recommended re-indexing cadence: monthly, or immediately after major content \n  updates."
      },
      "typeVersion": 1.3
    },
    {
      "id": "5ee75b41-1e65-406b-8356-83ae47222b29",
      "name": "Cohere Reranker",
      "type": "@n8n/n8n-nodes-langchain.rerankerCohere",
      "position": [
        1536,
        608
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "5f5a32cf-f96a-4496-b22e-e01ab3b55d21",
      "name": "When File Added to Drive",
      "type": "n8n-nodes-base.googleDriveTrigger",
      "position": [
        1760,
        224
      ],
      "parameters": {
        "event": "fileCreated",
        "options": {},
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        },
        "triggerOn": "specificFolder",
        "folderToWatch": {
          "__rl": true,
          "mode": "list",
          "value": "1dWj0JtJhRtnAOuc-SyJv0DS5CR-x9V6V",
          "cachedResultUrl": "https://drive.google.com/drive/folders/1dWj0JtJhRtnAOuc-SyJv0DS5CR-x9V6V",
          "cachedResultName": "Erha File"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "4bb361cc-6c1d-4192-a4fc-9d087eca1955",
      "name": "Download File from Drive",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        1968,
        224
      ],
      "parameters": {
        "fileId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $json.id }}"
        },
        "options": {},
        "operation": "download"
      },
      "typeVersion": 3
    },
    {
      "id": "d323eb20-0ae5-4f43-8c30-432352c440a6",
      "name": "Load Default Data Format",
      "type": "@n8n/n8n-nodes-langchain.documentDefaultDataLoader",
      "position": [
        2384,
        416
      ],
      "parameters": {
        "options": {
          "metadata": {
            "metadataValues": [
              {
                "name": "file",
                "value": "={{ $json.name }}"
              }
            ]
          }
        },
        "dataType": "binary",
        "textSplittingMode": "custom"
      },
      "typeVersion": 1.1
    },
    {
      "id": "bee7d987-1afe-49ee-814e-77cbbab5a70f",
      "name": "Split Text by Character",
      "type": "@n8n/n8n-nodes-langchain.textSplitterRecursiveCharacterTextSplitter",
      "position": [
        2384,
        592
      ],
      "parameters": {
        "options": {},
        "chunkSize": 500,
        "chunkOverlap": 200
      },
      "typeVersion": 1
    },
    {
      "id": "164ff8da-d217-4b51-9e54-e6488bb8844a",
      "name": "Generate Google Gemini Embeddings",
      "type": "@n8n/n8n-nodes-langchain.embeddingsGoogleGemini",
      "position": [
        2192,
        416
      ],
      "parameters": {
        "modelName": "models/gemini-embedding-2"
      },
      "typeVersion": 1
    },
    {
      "id": "e39800c8-a5e1-4b3e-9249-118b83cb8845",
      "name": "Secondary Pinecone Vector Store",
      "type": "@n8n/n8n-nodes-langchain.vectorStorePinecone",
      "position": [
        2288,
        224
      ],
      "parameters": {
        "mode": "insert",
        "options": {},
        "pineconeIndex": {
          "__rl": true,
          "mode": "list",
          "value": "erhan8n",
          "cachedResultName": "erhan8n"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "42742fe0-b038-44fd-9793-c1694831968d",
      "name": "Google Gemini Embeddings 1",
      "type": "@n8n/n8n-nodes-langchain.embeddingsGoogleGemini",
      "position": [
        1216,
        704
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "e5b5a6f3-004a-4f3b-9049-dcd78574f378",
      "name": "Memory Buffer Window",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        864,
        480
      ],
      "parameters": {},
      "typeVersion": 1.4
    }
  ],
  "active": false,
  "settings": {
    "binaryMode": "separate",
    "executionOrder": "v1"
  },
  "versionId": "474649f1-0b70-456a-9c14-ef24ce8fc1c3",
  "nodeGroups": [],
  "connections": {
    "Cohere Reranker": {
      "ai_reranker": [
        [
          {
            "node": "Main Pinecone Vector Store",
            "type": "ai_reranker",
            "index": 0
          }
        ]
      ]
    },
    "Split Text by Character": {
      "ai_textSplitter": [
        [
          {
            "node": "Load Default Data Format",
            "type": "ai_textSplitter",
            "index": 0
          }
        ]
      ]
    },
    "Download File from Drive": {
      "main": [
        [
          {
            "node": "Secondary Pinecone Vector Store",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Load Default Data Format": {
      "ai_document": [
        [
          {
            "node": "Secondary Pinecone Vector Store",
            "type": "ai_document",
            "index": 0
          }
        ]
      ]
    },
    "When File Added to Drive": {
      "main": [
        [
          {
            "node": "Download File from Drive",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Embeddings 1": {
      "ai_embedding": [
        [
          {
            "node": "Main Pinecone Vector Store",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "Main Pinecone Vector Store": {
      "ai_tool": [
        [
          {
            "node": "Chatbot Response Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "When Chat Message Received": {
      "main": [
        [
          {
            "node": "Chatbot Response Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Groq Chat Model Interaction": {
      "ai_languageModel": [
        [
          {
            "node": "Chatbot Response Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Generate Google Gemini Embeddings": {
      "ai_embedding": [
        [
          {
            "node": "Secondary Pinecone Vector Store",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    }
  }
}