{
  "id": "FqCqWFe2l39CkWJJ",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "LENOHA-Customer-Support",
  "tags": [],
  "nodes": [
    {
      "id": "a1572a1d-1d1f-4abc-8f1d-364e58381368",
      "name": "When clicking \u2018Execute workflow\u2019",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -64,
        -432
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "31098d41-56e5-4859-8218-41b79b6878c1",
      "name": "Embeddings HuggingFace Inference",
      "type": "@n8n/n8n-nodes-langchain.embeddingsHuggingFaceInference",
      "position": [
        480,
        -208
      ],
      "parameters": {
        "options": {}
      },
      "credentials": {
        "huggingFaceApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "41ff1a9f-9b1a-4ae4-a93b-f55c63ad430b",
      "name": "Default Data Loader",
      "type": "@n8n/n8n-nodes-langchain.documentDefaultDataLoader",
      "position": [
        688,
        -208
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 1.1
    },
    {
      "id": "d22d074b-35f8-4a65-9b2d-1e9d697076f5",
      "name": "When chat message received",
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "position": [
        -128,
        496
      ],
      "parameters": {
        "options": {
          "responseMode": "responseNodes"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "8209ba33-0036-45e7-993b-d3a1ee26c4db",
      "name": "Respond to Chat",
      "type": "@n8n/n8n-nodes-langchain.chat",
      "position": [
        1104,
        192
      ],
      "parameters": {
        "message": "={{ $json.Answer }}",
        "options": {}
      },
      "typeVersion": 1
    },
    {
      "id": "9142cb58-be78-476c-a545-83f6f75c1986",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -128,
        -560
      ],
      "parameters": {
        "width": 1104,
        "height": 512,
        "content": "## 0. Create Embeddings\n- Get common questions from your own knowledge base\n- Use persistent vector store for embeddings"
      },
      "typeVersion": 1
    },
    {
      "id": "c36b56dc-375f-417f-ae07-38433f800cca",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -256,
        384
      ],
      "parameters": {
        "color": 2,
        "width": 368,
        "height": 272,
        "content": "## 1. Receive a user message"
      },
      "typeVersion": 1
    },
    {
      "id": "5f7477ea-3529-427e-a565-8653e4ba5210",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        272,
        32
      ],
      "parameters": {
        "color": 3,
        "width": 528,
        "height": 480,
        "content": "## 2. Evaluate user message\n- Generate embeddings for the user message\n- Check against your vector store for relevant questions\n- IMPORTANT: You need to fine-tune your similarity score threshold within the If/Else-Node"
      },
      "typeVersion": 1
    },
    {
      "id": "b5a86a31-cc26-43ec-bebc-18c3e6077777",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        832,
        32
      ],
      "parameters": {
        "color": 4,
        "width": 512,
        "height": 352,
        "content": "## 3.1 Reply from FAQ\n- If the user query is similar to a question from your knowledge base, the pre-defined, static answer is returned"
      },
      "typeVersion": 1
    },
    {
      "id": "361a09fd-2384-478b-b05e-3dc07fcc6c40",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        816,
        432
      ],
      "parameters": {
        "color": 4,
        "width": 784,
        "height": 368,
        "content": "## 3.2 Reply via LLM\n- If the user query is not found within the knowledge base, a smaller LLM can answer"
      },
      "typeVersion": 1
    },
    {
      "id": "ea069bda-92ef-441b-ab7c-79aa85602d0a",
      "name": "Embeddings HuggingFace Inference2",
      "type": "@n8n/n8n-nodes-langchain.embeddingsHuggingFaceInference",
      "position": [
        432,
        368
      ],
      "parameters": {
        "options": {}
      },
      "credentials": {
        "huggingFaceApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "f04bce14-f24f-4ef2-968a-5d9c529ee9de",
      "name": "Respond to Chat1",
      "type": "@n8n/n8n-nodes-langchain.chat",
      "position": [
        1392,
        544
      ],
      "parameters": {
        "message": "={{ $json.content.parts[0].text }}",
        "options": {}
      },
      "typeVersion": 1
    },
    {
      "id": "4a302856-38e1-413f-8810-d140a99a0187",
      "name": "Knowledge Database",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        144,
        -432
      ],
      "parameters": {
        "options": {
          "returnFirstMatch": false
        },
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 1748220104,
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1tSEu_-7KAupdkFJGzoPBc-zqBBAmPgGoc89JyvqhY90/edit#gid=1748220104",
          "cachedResultName": "Tabellenblatt2"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1tSEu_-7KAupdkFJGzoPBc-zqBBAmPgGoc89JyvqhY90",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1tSEu_-7KAupdkFJGzoPBc-zqBBAmPgGoc89JyvqhY90/edit?usp=drivesdk",
          "cachedResultName": "Stripe_Dummy_FAQ"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7,
      "alwaysOutputData": false
    },
    {
      "id": "d9c346d2-4b07-460d-8154-1a0749e4d921",
      "name": "Extract Questions",
      "type": "n8n-nodes-base.set",
      "position": [
        352,
        -432
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "48e49d98-11b7-478a-91fb-ecf198fdd9e7",
              "name": "row_number",
              "type": "number",
              "value": "={{ $json.row_number }}"
            },
            {
              "id": "9b40b5a1-a73b-4af3-a96c-bc52226cc4bc",
              "name": "Question",
              "type": "string",
              "value": "={{ $json.Question }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "dc2510c2-0cc2-436c-92eb-854aae56efd8",
      "name": "Generate & Store Embeddings",
      "type": "@n8n/n8n-nodes-langchain.vectorStoreInMemory",
      "position": [
        560,
        -432
      ],
      "parameters": {
        "mode": "insert",
        "memoryKey": {
          "__rl": true,
          "mode": "list",
          "value": "vector_store_key"
        },
        "embeddingBatchSize": 1
      },
      "typeVersion": 1.3
    },
    {
      "id": "672b7a01-d236-412b-acef-09b1e7674ae9",
      "name": "Retrieve & Score Embeddings",
      "type": "@n8n/n8n-nodes-langchain.vectorStoreInMemory",
      "position": [
        336,
        208
      ],
      "parameters": {
        "mode": "load",
        "topK": 2,
        "prompt": "={{ $json.chatInput }}",
        "memoryKey": {
          "__rl": true,
          "mode": "list",
          "value": "vector_store_key"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "b5d2db8d-b14c-4162-8fd1-c3163efd2b72",
      "name": "Determine Question Type",
      "type": "n8n-nodes-base.if",
      "position": [
        624,
        208
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "f6f2c4ab-cebf-4dea-baec-5ec3e50e88ab",
              "operator": {
                "type": "number",
                "operation": "gte"
              },
              "leftValue": "={{ $json.score }}",
              "rightValue": 0.8
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "d182bbc1-1822-424f-8c05-b3503b53b6c1",
      "name": "Get Respective Answers",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        880,
        192
      ],
      "parameters": {
        "options": {},
        "filtersUI": {
          "values": [
            {
              "lookupValue": "={{ $json.document.pageContent }}",
              "lookupColumn": "Question"
            }
          ]
        },
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 1748220104,
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1tSEu_-7KAupdkFJGzoPBc-zqBBAmPgGoc89JyvqhY90/edit#gid=1748220104",
          "cachedResultName": "Tabellenblatt2"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1tSEu_-7KAupdkFJGzoPBc-zqBBAmPgGoc89JyvqhY90",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1tSEu_-7KAupdkFJGzoPBc-zqBBAmPgGoc89JyvqhY90/edit?usp=drivesdk",
          "cachedResultName": "Stripe_Dummy_FAQ"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "2f3bf992-7f08-40f4-86ab-16242abc79d5",
      "name": "Forward Chat Message",
      "type": "n8n-nodes-base.merge",
      "position": [
        880,
        544
      ],
      "parameters": {
        "mode": "chooseBranch",
        "useDataOfInput": 2
      },
      "typeVersion": 3.2
    },
    {
      "id": "69646d36-32f5-4f04-bf15-4463398d969d",
      "name": "Chat Model",
      "type": "@n8n/n8n-nodes-langchain.googleGemini",
      "position": [
        1072,
        544
      ],
      "parameters": {
        "modelId": {
          "__rl": true,
          "mode": "list",
          "value": "models/gemini-2.5-flash-lite",
          "cachedResultName": "models/gemini-2.5-flash-lite"
        },
        "options": {
          "systemMessage": "# Role:\nYou are a conversational AI assistant. Your primary function is to handle casual conversation and general inquiries that do not pertain to specific company policies or user account details.\n\n# Task:\nEngage the user in a friendly, helpful, and brief manner. You are the fallback agent for queries that could not be answered by our primary FAQ knowledge base.\n\n# CRITICAL RULES:\nScope Limitation: You MUST NOT attempt to answer any specific questions related to policies, pricing, fees, disputes, payout schedules, security, or personal account information. Your knowledge base does not contain this information.\nNo Speculation: If you are unsure about a user's query, NEVER guess the answer. It is safer to state your limitation.\nBrevity: Keep your responses concise and to the point (1-2 sentences).\n\n# Response Strategy & Disclaimer:\nIf a user's question seems to be asking for specific details, even if it appears simple, you must use the following disclaimer. Do not attempt to answer the question first.\n\n# Disclaimer: \"I am not equipped to handle specific policy or account-level questions to ensure your information is kept safe and accurate. For detailed assistance, I recommend checking our official Help Center or contacting a human support agent.\""
        },
        "messages": {
          "values": [
            {
              "content": "={{ $json.chatInput }}"
            }
          ]
        }
      },
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "650ce0df-104b-417a-903d-160f095dc823",
  "connections": {
    "Chat Model": {
      "main": [
        [
          {
            "node": "Respond to Chat1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Questions": {
      "main": [
        [
          {
            "node": "Generate & Store Embeddings",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Knowledge Database": {
      "main": [
        [
          {
            "node": "Extract Questions",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Default Data Loader": {
      "ai_document": [
        [
          {
            "node": "Generate & Store Embeddings",
            "type": "ai_document",
            "index": 0
          }
        ]
      ]
    },
    "Forward Chat Message": {
      "main": [
        [
          {
            "node": "Chat Model",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Respective Answers": {
      "main": [
        [
          {
            "node": "Respond to Chat",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Determine Question Type": {
      "main": [
        [
          {
            "node": "Get Respective Answers",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Forward Chat Message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When chat message received": {
      "main": [
        [
          {
            "node": "Retrieve & Score Embeddings",
            "type": "main",
            "index": 0
          },
          {
            "node": "Forward Chat Message",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Generate & Store Embeddings": {
      "main": [
        []
      ]
    },
    "Retrieve & Score Embeddings": {
      "main": [
        [
          {
            "node": "Determine Question Type",
            "type": "main",
            "index": 0
          }
        ]
      ],
      "ai_tool": [
        []
      ]
    },
    "Embeddings HuggingFace Inference": {
      "ai_embedding": [
        [
          {
            "node": "Generate & Store Embeddings",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "Embeddings HuggingFace Inference2": {
      "ai_embedding": [
        [
          {
            "node": "Retrieve & Score Embeddings",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "When clicking \u2018Execute workflow\u2019": {
      "main": [
        [
          {
            "node": "Knowledge Database",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}