{
  "name": "Trợ lý bán hàng có công cụ",
  "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á.\nKhi khách chốt đơn và đã cho tên, số điện thoại, hãy ghi đơn bằng công cụ."
        }
      },
      "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": {
        "descriptionType": "manual",
        "toolDescription": "Dùng khi khách đã chốt đơn, để ghi tên khách, số điện thoại và sản phẩm",
        "resource": "row",
        "operation": "insert",
        "dataTableId": {
          "__rl": true,
          "mode": "name",
          "value": "Đơn hàng thử"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "ten": "={{ $fromAI('ten', 'Tên khách hàng', 'string') }}",
            "sdt": "={{ $fromAI('sdt', 'Số điện thoại khách hàng', 'string') }}",
            "san_pham": "={{ $fromAI('san_pham', 'Sản phẩm và số lượng khách đặt, kèm size', 'string') }}"
          },
          "matchingColumns": [],
          "schema": [
            {
              "id": "ten",
              "displayName": "ten",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "sdt",
              "displayName": "sdt",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "san_pham",
              "displayName": "san_pham",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.dataTableTool",
      "typeVersion": 1.1,
      "position": [
        540,
        220
      ],
      "name": "Ghi đơn hàng"
    }
  ],
  "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
          }
        ]
      ]
    },
    "Ghi đơn hàng": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  }
}