{
  "nodes": [
    {
      "id": "ef6899c9-4229-414b-9874-6bfd8091563a",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -112,
        112
      ],
      "parameters": {
        "width": 960,
        "height": 800,
        "content": "# AI Chatbot for businesses using Decodo, Pinecone, and Google Gemini\n\nThis n8n workflow provides an end-to-end solution for AI-powered customer support. It automates the process of scraping website data into a Pinecone knowledge base and provides a web-ready chat interface powered by Google Gemini.\n\n## 1. Data Ingestion & Knowledge Base Creation\n* This section gathers and refines website content to build the AI's \"memory.\"\n* URL Input & Consolidation: Accepts sitemaps or specific page URLs via a form, cleans the data, and removes duplicates.\n* Decodo Content Extraction: Fetches HTML for each URL and extracts the main text content, ensuring a clean dataset for the AI.\n* Embedding & Storage: Converts text into high-dimensional vectors using gemini-embedding-001 and stores them in the \"supportbot\" Pinecone index.\n\n## 2. AI Chat Interface (RAG Implementation)\n* This section handles the real-time interaction with users, using the knowledge base to answer questions.\n* Chat Trigger (Webhook): A public-facing node that allows the chatbot to be embedded on any website (typically appearing as a widget in the bottom-right corner).\n* AI Agent (LangChain): The central brain that coordinates between the user's question, the chat history, and the knowledge base.\n* Google Gemini Chat Model: Uses Gemini as the core LLM to generate natural, context-aware responses.\n* Window Buffer Memory: Maintains the last 10 exchanges of the conversation, allowing the AI to understand follow-up questions and maintain context.\n\n## 3. Vector Store Retrieval Tool\n* This bridges the chat interface with your stored data.\n* Pinecone Retrieval Tool: Configured as a tool for the AI Agent. When a user asks a question, the agent searches the \"supportbot\" index for relevant business information.\n* Gemini Embeddings: Converts the user\u2019s live chat query into a vector to find the most mathematically relevant matches within the Pinecone database."
      },
      "typeVersion": 1
    },
    {
      "id": "8fd9561e-0dc8-45b1-a932-9b2bc5f9faa8",
      "name": "Extract Page URLs",
      "type": "n8n-nodes-base.code",
      "position": [
        1568,
        448
      ],
      "parameters": {
        "jsCode": "const items = []\nfor (const item of $input.first().json.urlset.url) {\n  items.push({ url: item.loc })\n}\n\nreturn items;"
      },
      "typeVersion": 2
    },
    {
      "id": "1f5bc7b4-ad49-4fe9-9432-d353e1aae0f8",
      "name": "XML Conversion",
      "type": "n8n-nodes-base.xml",
      "position": [
        1424,
        448
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 1
    },
    {
      "id": "9885fdc2-d7ed-4d96-8f4d-fadd5deb0ed6",
      "name": "Fetch Sitemap",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1264,
        448
      ],
      "parameters": {
        "url": "={{ $json['Sitemap URL'] }}",
        "options": {}
      },
      "typeVersion": 4.2
    },
    {
      "id": "ede19831-b7ab-42fa-a30a-e642282b139f",
      "name": "Split Pages URL",
      "type": "n8n-nodes-base.code",
      "position": [
        1424,
        272
      ],
      "parameters": {
        "jsCode": "function addTrailingSlash(str) {\n  if (typeof str !== 'string') {\n    return str; // Or throw an error, handle non-string inputs\n  }\n  if (!str.endsWith('/')) {\n    return str + '/';\n  }\n  return str;\n}\n\nconst urls = []\nfor (const item of $input.first().json['Page URLs'].split(',')) {\n  urls.push({ url: addTrailingSlash(item).trim()})\n}\n\nreturn urls;"
      },
      "typeVersion": 2
    },
    {
      "id": "5ca54dbb-a1c3-467b-be2f-1331f83dd408",
      "name": "Merge URLs",
      "type": "n8n-nodes-base.merge",
      "position": [
        1760,
        288
      ],
      "parameters": {},
      "typeVersion": 3.2
    },
    {
      "id": "6de3aa8c-6f41-46b4-adea-ee8f77e8dec5",
      "name": "Remove Duplicate URLs",
      "type": "n8n-nodes-base.removeDuplicates",
      "position": [
        1904,
        288
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 2
    },
    {
      "id": "13033722-6fe1-4b10-9739-5c858de5c1f1",
      "name": "Loop Over Page URLs",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        2112,
        288
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "59f936d1-d8f6-4eb0-b329-ffe9059859d3",
      "name": "Extract Content",
      "type": "n8n-nodes-base.html",
      "position": [
        2512,
        192
      ],
      "parameters": {
        "options": {
          "cleanUpText": true
        },
        "operation": "extractHtmlContent",
        "extractionValues": {
          "values": [
            {
              "key": "content",
              "cssSelector": "body",
              "skipSelectors": "img"
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "cdfdf6ea-7e45-4460-8a30-81f723dd0b27",
      "name": "Wait 5 sec",
      "type": "n8n-nodes-base.wait",
      "position": [
        2512,
        384
      ],
      "parameters": {},
      "typeVersion": 1.1
    },
    {
      "id": "63ff031a-d48b-43ca-b784-0be36215eb68",
      "name": "Data Loader",
      "type": "@n8n/n8n-nodes-langchain.documentDefaultDataLoader",
      "position": [
        3104,
        400
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 1.1
    },
    {
      "id": "e196c8e3-6831-49b8-916a-cf6d2e466423",
      "name": "Gemini Embeddings",
      "type": "@n8n/n8n-nodes-langchain.embeddingsGoogleGemini",
      "position": [
        2912,
        400
      ],
      "parameters": {
        "modelName": "models/gemini-embedding-001"
      },
      "typeVersion": 1
    },
    {
      "id": "4b0fcd8c-127e-4cf5-9177-a50ad8bd23e6",
      "name": "Pinecone KnowledgeBase",
      "type": "@n8n/n8n-nodes-langchain.vectorStorePinecone",
      "position": [
        2912,
        192
      ],
      "parameters": {
        "mode": "insert",
        "options": {
          "clearNamespace": true
        },
        "pineconeIndex": {
          "__rl": true,
          "mode": "list",
          "value": "supportbot",
          "cachedResultName": "supportbot"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "ed948a05-fe45-4aa4-988d-c20916d5b224",
      "name": "Input Sitemap or page urls",
      "type": "n8n-nodes-base.formTrigger",
      "position": [
        928,
        432
      ],
      "parameters": {
        "options": {},
        "formTitle": "Agent Knowledge Base Input",
        "formFields": {
          "values": [
            {
              "fieldLabel": "Sitemap URL",
              "placeholder": "https://website.com/page-sitemap.xml"
            },
            {
              "fieldType": "textarea",
              "fieldLabel": "Page URLs",
              "placeholder": "https://website.com/about, https://website.com/contact"
            }
          ]
        },
        "formDescription": "This form is to input the page sitemap or pages of your website"
      },
      "typeVersion": 2.2
    },
    {
      "id": "39c6786e-f724-4484-af6c-845f1829a0c8",
      "name": "Switch",
      "type": "n8n-nodes-base.switch",
      "position": [
        1072,
        432
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "2af7e15b-2e56-40e5-addc-74bd0b4de214",
                    "operator": {
                      "type": "string",
                      "operation": "notEmpty",
                      "singleValue": true
                    },
                    "leftValue": "={{ $json['Page URLs'] }}",
                    "rightValue": ""
                  }
                ]
              }
            },
            {
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "02899ab6-0c0b-4c0f-89ad-ec5787da36eb",
                    "operator": {
                      "type": "string",
                      "operation": "endsWith"
                    },
                    "leftValue": "={{ $json['Sitemap URL'] }}",
                    "rightValue": "xml"
                  }
                ]
              }
            }
          ]
        },
        "options": {
          "allMatchingOutputs": true
        }
      },
      "typeVersion": 3.2
    },
    {
      "id": "d8423b14-305b-49f4-a158-8e472499c11c",
      "name": "Decodo",
      "type": "@decodo/n8n-nodes-decodo.decodo",
      "position": [
        2320,
        384
      ],
      "parameters": {
        "url": "={{ $json.url }}"
      },
      "typeVersion": 1
    },
    {
      "id": "34f9ca84-ca77-4abf-89c0-514039b39b99",
      "name": "When chat message received",
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "position": [
        1296,
        848
      ],
      "parameters": {
        "mode": "webhook",
        "public": true,
        "options": {
          "allowedOrigins": "*",
          "loadPreviousSession": "memory"
        }
      },
      "typeVersion": 1.4
    },
    {
      "id": "2bee1969-2704-4ff1-b485-2113370fb633",
      "name": "Simple Memory",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        1440,
        1120
      ],
      "parameters": {
        "contextWindowLength": 10
      },
      "typeVersion": 1.3
    },
    {
      "id": "c8a5e2f3-89fc-465b-8c20-458fd352db73",
      "name": "AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        1712,
        848
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3.1
    },
    {
      "id": "ce663f8f-2e39-4620-9c84-e0221964ba3b",
      "name": "Simple Memory1",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        1808,
        1120
      ],
      "parameters": {
        "contextWindowLength": 10
      },
      "typeVersion": 1.3
    },
    {
      "id": "243df850-90cf-4e30-a881-e3743cf4d22a",
      "name": "Google Gemini Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        1648,
        1120
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 1
    },
    {
      "id": "551156bb-949a-40a4-b519-b266b9485434",
      "name": "Pinecone Vector Store",
      "type": "@n8n/n8n-nodes-langchain.vectorStorePinecone",
      "position": [
        2000,
        1120
      ],
      "parameters": {
        "mode": "retrieve-as-tool",
        "options": {},
        "pineconeIndex": {
          "__rl": true,
          "mode": "list",
          "value": "supportbot",
          "cachedResultName": "supportbot"
        },
        "toolDescription": "Business information related to a business"
      },
      "typeVersion": 1.3
    },
    {
      "id": "5414b57b-dcf6-4712-9910-858d636e4aa1",
      "name": "Embeddings Google Gemini",
      "type": "@n8n/n8n-nodes-langchain.embeddingsGoogleGemini",
      "position": [
        2112,
        1280
      ],
      "parameters": {
        "modelName": "models/embedding-001"
      },
      "typeVersion": 1
    },
    {
      "id": "8ddfb5ba-461d-47d0-abf0-4ceb018c8832",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2048,
        112
      ],
      "parameters": {
        "color": 6,
        "width": 624,
        "height": 512,
        "content": "## Extracting HTML from a web page using Decodo with JS Rendering"
      },
      "typeVersion": 1
    },
    {
      "id": "3c04259f-d8e7-4592-8009-e0ac99246683",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2688,
        112
      ],
      "parameters": {
        "color": 2,
        "width": 624,
        "height": 512,
        "content": "## Saving Content in Pinecone Vector Database"
      },
      "typeVersion": 1
    },
    {
      "id": "6176a797-96fe-4ca2-88e6-92e15ebc5ea5",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1216,
        112
      ],
      "parameters": {
        "color": 5,
        "width": 816,
        "height": 512,
        "content": "## Processing Page URLs"
      },
      "typeVersion": 1
    },
    {
      "id": "5a8065c6-3f6b-4637-b0fe-a85e778189f1",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1216,
        736
      ],
      "parameters": {
        "color": 5,
        "width": 1072,
        "height": 720,
        "content": "## Chatbot which can be embedded to any website, will show on the bottom right side, and will work perfectly"
      },
      "typeVersion": 1
    }
  ],
  "connections": {
    "Decodo": {
      "main": [
        [
          {
            "node": "Wait 5 sec",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Switch": {
      "main": [
        [
          {
            "node": "Split Pages URL",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Fetch Sitemap",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge URLs": {
      "main": [
        [
          {
            "node": "Remove Duplicate URLs",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait 5 sec": {
      "main": [
        [
          {
            "node": "Loop Over Page URLs",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Data Loader": {
      "ai_document": [
        [
          {
            "node": "Pinecone KnowledgeBase",
            "type": "ai_document",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Sitemap": {
      "main": [
        [
          {
            "node": "XML Conversion",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Simple Memory": {
      "ai_memory": [
        [
          {
            "node": "When chat message received",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Simple Memory1": {
      "ai_memory": [
        [
          {
            "node": "AI Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "XML Conversion": {
      "main": [
        [
          {
            "node": "Extract Page URLs",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Content": {
      "main": [
        [
          {
            "node": "Pinecone KnowledgeBase",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Pages URL": {
      "main": [
        [
          {
            "node": "Merge URLs",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Page URLs": {
      "main": [
        [
          {
            "node": "Merge URLs",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Gemini Embeddings": {
      "ai_embedding": [
        [
          {
            "node": "Pinecone KnowledgeBase",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Page URLs": {
      "main": [
        [
          {
            "node": "Extract Content",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Decodo",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Pinecone Vector Store": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Remove Duplicate URLs": {
      "main": [
        [
          {
            "node": "Loop Over Page URLs",
            "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
          }
        ]
      ]
    },
    "Input Sitemap or page urls": {
      "main": [
        [
          {
            "node": "Switch",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When chat message received": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}