{
  "name": "Trợ lý bán hàng có kiến thức (RAG)",
  "nodes": [
    {
      "parameters": {
        "public": true,
        "initialMessages": "Xin chào! Em là trợ lý tư vấn của AgentHub Shop, anh/chị cần tìm sản phẩm gì ạ?",
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "typeVersion": 1.4,
      "position": [
        0,
        0
      ],
      "name": "When chat message received"
    },
    {
      "parameters": {
        "options": {
          "systemMessage": "Bạn là nhân viên tư vấn của shop áo thun \"AgentHub Shop\". Xưng \"em\", gọi khách là \"anh/chị\".\nBảng giá:\n- Áo thun basic: 150.000đ (size S, M, L, XL)\n- Áo polo: 250.000đ (size M, L, XL)\n- Áo hoodie: 390.000đ (size M, L)\nMiễn phí ship đơn từ 500.000đ.\nQuy trình: 1) Chào khách 2) Hỏi khách cần sản phẩm gì, size nào 3) Báo giá đúng bảng giá 4) Mời khách để lại tên và số điện thoại để chốt đơn.\nKhông bịa sản phẩm hay giá ngoài bảng giá."
        }
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 3.1,
      "position": [
        240,
        0
      ],
      "name": "AI Agent"
    },
    {
      "parameters": {
        "modelName": "models/gemini-3.1-flash-lite",
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "typeVersion": 1.1,
      "position": [
        140,
        220
      ],
      "name": "Google Gemini Chat Model"
    },
    {
      "parameters": {
        "contextWindowLength": 10
      },
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "typeVersion": 1.4,
      "position": [
        340,
        220
      ],
      "name": "Simple Memory"
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        0,
        400
      ],
      "name": "Nạp tài liệu (chạy 1 lần)"
    },
    {
      "parameters": {
        "mode": "insert",
        "memoryKey": {
          "__rl": true,
          "mode": "id",
          "value": "agenthub_shop_policy"
        },
        "options": {
          "clearStore": true
        }
      },
      "type": "@n8n/n8n-nodes-langchain.vectorStoreInMemory",
      "typeVersion": 1.3,
      "position": [
        260,
        400
      ],
      "name": "Vector Store - Nạp"
    },
    {
      "parameters": {
        "dataType": "json",
        "jsonMode": "expressionData",
        "jsonData": "=CHÍNH SÁCH CỬA HÀNG — AGENTHUB SHOP (tài liệu mẫu để nạp vào RAG)\n\n# Chính sách đổi trả\n- Khách được đổi trả trong vòng 7 ngày kể từ ngày nhận hàng.\n- Sản phẩm đổi trả phải còn nguyên tem mác, chưa qua sử dụng.\n- Không áp dụng đổi trả với sản phẩm giảm giá trên 50%.\n\n# Chính sách giao hàng\n- Giao hàng toàn quốc, thời gian 2-4 ngày làm việc tuỳ khu vực.\n- Miễn phí giao hàng cho đơn từ 500.000đ trở lên.\n- Không có dịch vụ giao hàng trong ngày hoặc giao hoả tốc dưới 2 giờ.\n\n# Giờ làm việc\n- Cửa hàng mở cửa từ 8 giờ sáng đến 9 giờ tối, tất cả các ngày trong tuần kể cả cuối tuần.\n- Bộ phận chăm sóc khách hàng trả lời tin nhắn trong giờ làm việc, thường trong vòng 15 phút.\n\n# Câu hỏi thường gặp\n- Có nhận đơn qua Zalo và Facebook không? Có, nhận đơn qua cả hai kênh.\n- Có ship ra nước ngoài không? Hiện tại chưa hỗ trợ giao hàng quốc tế.\n- Có xuất hoá đơn không? Có, khách yêu cầu khi đặt hàng sẽ được xuất hoá đơn.\n"
      },
      "type": "@n8n/n8n-nodes-langchain.documentDefaultDataLoader",
      "typeVersion": 1,
      "position": [
        260,
        620
      ],
      "name": "Tải tài liệu"
    },
    {
      "parameters": {
        "chunkSize": 400,
        "chunkOverlap": 40
      },
      "type": "@n8n/n8n-nodes-langchain.textSplitterRecursiveCharacterTextSplitter",
      "typeVersion": 1,
      "position": [
        180,
        780
      ],
      "name": "Chia nhỏ văn bản"
    },
    {
      "parameters": {},
      "type": "@n8n/n8n-nodes-langchain.embeddingsGoogleGemini",
      "typeVersion": 1,
      "position": [
        420,
        780
      ],
      "name": "Embeddings Gemini"
    },
    {
      "parameters": {
        "mode": "retrieve-as-tool",
        "toolName": "tra_cuu_chinh_sach_shop",
        "toolDescription": "Dùng khi khách hỏi về chính sách đổi trả, giao hàng, giờ làm việc của shop",
        "memoryKey": {
          "__rl": true,
          "mode": "id",
          "value": "agenthub_shop_policy"
        }
      },
      "type": "@n8n/n8n-nodes-langchain.vectorStoreInMemory",
      "typeVersion": 1.3,
      "position": [
        560,
        220
      ],
      "name": "Vector Store - Tra cứu (Tool)"
    }
  ],
  "connections": {
    "When chat message received": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Simple Memory": {
      "ai_memory": [
        [
          {
            "node": "AI Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Nạp tài liệu (chạy 1 lần)": {
      "main": [
        [
          {
            "node": "Vector Store - Nạp",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Tải tài liệu": {
      "ai_document": [
        [
          {
            "node": "Vector Store - Nạp",
            "type": "ai_document",
            "index": 0
          }
        ]
      ]
    },
    "Chia nhỏ văn bản": {
      "ai_textSplitter": [
        [
          {
            "node": "Tải tài liệu",
            "type": "ai_textSplitter",
            "index": 0
          }
        ]
      ]
    },
    "Embeddings Gemini": {
      "ai_embedding": [
        [
          {
            "node": "Vector Store - Nạp",
            "type": "ai_embedding",
            "index": 0
          }
        ],
        [
          {
            "node": "Vector Store - Tra cứu (Tool)",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "Vector Store - Tra cứu (Tool)": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  }
}