{
  "name": "Website Knowledge Chatbot (RAG + Supabase)",
  "nodes": [
    {
      "parameters": {
        "public": true,
        "mode": "webhook",
        "options": {}
      },
      "id": "62d84f48-dfaf-44eb-b4f3-44a594f41b32",
      "name": "When chat message received",
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "position": [
        500,
        -580
      ],
      "webhookId": "b2f41eb8-55c2-488c-ae59-8dbda9efc76d",
      "typeVersion": 1.1
    },
    {
      "parameters": {
        "extractionValues": {
          "values": [
            {
              "key": "title",
              "cssSelector": "title, h1"
            },
            {
              "key": "content",
              "cssSelector": "p, article, .content, .post-content, main"
            },
            {
              "key": "meta_description",
              "cssSelector": "meta[name='description']",
              "returnValue": "attribute",
              "attribute": "content"
            },
            {
              "key": "links",
              "cssSelector": "a[href]",
              "returnValue": "attribute",
              "attribute": "href"
            }
          ]
        },
        "options": {}
      },
      "id": "b89fa08e-89f9-47c8-90c0-92e7e9453161",
      "name": "HTML Extract",
      "type": "n8n-nodes-base.htmlExtract",
      "typeVersion": 1,
      "position": [
        -460,
        -540
      ]
    },
    {
      "parameters": {
        "dataType": "binary",
        "loader": "jsonLoader",
        "options": {
          "metadata": {
            "metadataValues": [
              {
                "name": "website_url",
                "value": "={{ $('Enter Website Url').item.json['Website Url'] }}"
              }
            ]
          }
        }
      },
      "id": "c8d42e80-1e33-4b2c-a29e-50182bcd9d29",
      "name": "Default Data Loader",
      "type": "@n8n/n8n-nodes-langchain.documentDefaultDataLoader",
      "position": [
        20,
        -360
      ],
      "typeVersion": 1
    },
    {
      "parameters": {
        "chunkSize": 3000,
        "chunkOverlap": 500,
        "options": {}
      },
      "id": "38ace870-d5f6-43f9-8e2d-adfd09fe903d",
      "name": "Recursive Character Text Splitter",
      "type": "@n8n/n8n-nodes-langchain.textSplitterRecursiveCharacterTextSplitter",
      "position": [
        120,
        -160
      ],
      "typeVersion": 1
    },
    {
      "parameters": {
        "mode": "insert",
        "tableName": {
          "__rl": true,
          "value": "documents",
          "mode": "list",
          "cachedResultName": "documents"
        },
        "embeddingBatchSize": 100,
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.vectorStoreSupabase",
      "typeVersion": 1.1,
      "position": [
        -40,
        -540
      ],
      "id": "513e0ed7-edde-4967-9b27-7e0588c89fc4",
      "name": "Supabase Vector Store",
      "credentials": {
        "supabaseApi": {
          "id": "FXKF57EL51h4uQq9",
          "name": "Supabase account"
        }
      }
    },
    {
      "parameters": {
        "formTitle": "Form",
        "formDescription": "Enter Website Url",
        "formFields": {
          "values": [
            {
              "fieldLabel": "Website Url",
              "placeholder": "Enter Website Url"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.formTrigger",
      "typeVersion": 2.2,
      "position": [
        -820,
        -540
      ],
      "id": "be2d9e11-7621-4f4a-8a55-5d1a9927ea39",
      "name": "Enter Website Url",
      "webhookId": "0bd46793-0470-462c-a8ee-7263cf35a5fb"
    },
    {
      "parameters": {
        "content": "## Generating Embeddings from Website Content",
        "height": 100,
        "width": 520,
        "color": 3
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -180,
        -680
      ],
      "typeVersion": 1,
      "id": "89f1dedf-0e9d-4d10-969b-3d265d3f515c",
      "name": "Sticky Note1"
    },
    {
      "parameters": {
        "content": "## User-Initiated Question",
        "height": 80,
        "width": 300
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        380,
        -680
      ],
      "typeVersion": 1,
      "id": "2fecebba-e54e-40aa-b522-c6c6eafb8d86",
      "name": "Sticky Note2"
    },
    {
      "parameters": {
        "content": "## Vector-Based Answer Retrieval",
        "height": 80,
        "width": 540,
        "color": 3
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        700,
        -680
      ],
      "typeVersion": 1,
      "id": "0f013227-553b-43c8-a228-30e4ebac079b",
      "name": "Sticky Note3"
    },
    {
      "parameters": {
        "content": "## Website Data Extraction\n\n",
        "height": 100,
        "width": 640
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -840,
        -680
      ],
      "typeVersion": 1,
      "id": "774791fd-914d-431f-8ade-ef79664fa48b",
      "name": "Sticky Note"
    },
    {
      "parameters": {
        "url": "={{ $json['Website Url'] }}",
        "options": {
          "redirect": {
            "redirect": {
              "maxRedirects": 5
            }
          },
          "timeout": 30000
        }
      },
      "id": "cdc726cf-df8f-4cf9-b7dc-a11d6ec3f9f9",
      "name": "Website Data Scraping",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.1,
      "position": [
        -640,
        -540
      ],
      "retryOnFail": true,
      "maxTries": 3
    },
    {
      "parameters": {
        "operation": "toJson",
        "options": {}
      },
      "type": "n8n-nodes-base.convertToFile",
      "typeVersion": 1.1,
      "position": [
        -320,
        -540
      ],
      "id": "ad98fac0-41a6-4e82-b352-8b5200116853",
      "name": "Convert to File"
    },
    {
      "parameters": {},
      "type": "@n8n/n8n-nodes-langchain.embeddingsCohere",
      "typeVersion": 1,
      "position": [
        -100,
        -360
      ],
      "id": "2f162957-49a1-4d6f-af39-c434031cf492",
      "name": "Embeddings Cohere",
      "credentials": {
        "cohereApi": {
          "id": "jplEM5bX2S3Rh9FQ",
          "name": "Cohere account"
        }
      }
    },
    {
      "parameters": {
        "options": {
          "systemMessage": "=# Overview  \nYou are an AI agent that responds strictly using information from stored document embeddings in a supabase vector store.  \n\n## Context  \n- The agent is designed to provide accurate, document-based answers.  \n- It must avoid using external knowledge or assumptions.  \n\n## Instructions  \n1. Analyze the user's question.  \n2. Retrieve relevant content from the document embeddings using supabase.  \n3. Construct a response only from the matching document chunks.\n## Tools  \n- Vector store containing embedded documents\n- Embeddings Cohere  \n\n## SOP (Standard Operating Procedure)  \n1. Receive user query.  \n2. Search the vector store for relevant document chunks.  \n3. Extract and synthesize an answer using only that content.  \n4. If no matches, issue fallback message.  \n\n## Final Notes  \n- Do not rely on prior training or external facts.  \n- The response must remain strictly grounded in the documents.  "
        }
      },
      "id": "97666948-17f0-4e7b-9603-2b7a27a4f847",
      "name": "Question & Answer Retrieve",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        820,
        -580
      ],
      "typeVersion": 1.8
    },
    {
      "parameters": {
        "mode": "retrieve-as-tool",
        "toolName": "documents_knowledge_base",
        "toolDescription": "work with documents data in Supabase vector store",
        "tableName": {
          "__rl": true,
          "value": "documents",
          "mode": "list",
          "cachedResultName": "documents"
        },
        "topK": null,
        "includeDocumentMetadata": false,
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.vectorStoreSupabase",
      "typeVersion": 1.1,
      "position": [
        1000,
        -360
      ],
      "id": "d32f817a-2955-4bca-922d-b6808141be9e",
      "name": "Data From Supabase Vector Store",
      "credentials": {
        "supabaseApi": {
          "id": "FXKF57EL51h4uQq9",
          "name": "Supabase account"
        }
      }
    },
    {
      "parameters": {},
      "type": "@n8n/n8n-nodes-langchain.embeddingsCohere",
      "typeVersion": 1,
      "position": [
        1020,
        -140
      ],
      "id": "dcb21275-41cb-4407-915d-3e57cfd8b08a",
      "name": "Embeddings With Cohere",
      "credentials": {
        "cohereApi": {
          "id": "jplEM5bX2S3Rh9FQ",
          "name": "Cohere account"
        }
      }
    },
    {
      "parameters": {
        "tableName": "chat_memory",
        "contextWindowLength": 3
      },
      "type": "@n8n/n8n-nodes-langchain.memoryPostgresChat",
      "typeVersion": 1.3,
      "position": [
        900,
        -320
      ],
      "id": "faa8d8be-e998-4912-87cb-61b46eabdfc1",
      "name": "Chat Memory",
      "credentials": {
        "postgres": {
          "id": "UXzyRBB6JOHPLQsR",
          "name": "Postgres account"
        }
      }
    },
    {
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini"
        },
        "options": {}
      },
      "id": "67b648d8-5fae-4681-aa27-db816f5f79b9",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        760,
        -340
      ],
      "typeVersion": 1.2,
      "credentials": {
        "openAiApi": {
          "id": "ZJWEBPL8ZXq1R00F",
          "name": "OpenAI account"
        }
      }
    }
  ],
  "pinData": {},
  "connections": {
    "When chat message received": {
      "main": [
        [
          {
            "node": "Question & Answer Retrieve",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTML Extract": {
      "main": [
        [
          {
            "node": "Convert to File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Default Data Loader": {
      "ai_document": [
        [
          {
            "node": "Supabase Vector Store",
            "type": "ai_document",
            "index": 0
          }
        ]
      ]
    },
    "Recursive Character Text Splitter": {
      "ai_textSplitter": [
        [
          {
            "node": "Default Data Loader",
            "type": "ai_textSplitter",
            "index": 0
          }
        ]
      ]
    },
    "Enter Website Url": {
      "main": [
        [
          {
            "node": "Website Data Scraping",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Website Data Scraping": {
      "main": [
        [
          {
            "node": "HTML Extract",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Convert to File": {
      "main": [
        [
          {
            "node": "Supabase Vector Store",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Embeddings Cohere": {
      "ai_embedding": [
        [
          {
            "node": "Supabase Vector Store",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "Data From Supabase Vector Store": {
      "ai_tool": [
        [
          {
            "node": "Question & Answer Retrieve",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Embeddings With Cohere": {
      "ai_embedding": [
        [
          {
            "node": "Data From Supabase Vector Store",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "Chat Memory": {
      "ai_memory": [
        [
          {
            "node": "Question & Answer Retrieve",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Question & Answer Retrieve",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "5d582b47-5d05-4c59-abfe-f8b28bebad87",
  "meta": {
    "templateCredsSetupCompleted": true,
    "instanceId": "f1c26778ec36097a9722a22c47c5e9c01f00b8862dadd0121ec118026a370fa6"
  },
  "id": "pOp4bZ29Qp74IW1c",
  "tags": []
}