8
n8n 中文网amn8n.com

与 XML 文件聊天

中级

这是一个Document Extraction, AI RAG领域的自动化工作流,包含 10 个节点。主要使用 Set, Xml, Code, HttpRequest, Agent 等节点。 使用 GPT 和 LangChain 分析与聊天 XML 文件

前置要求
  • 可能需要目标 API 的认证凭证
  • OpenAI API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "1pfNtfDuGq3yud8G",
  "meta": {
    "instanceId": "546be790303d737c735a8648874bae91a6b66b48cd2b10cbe4cbfb78039ceb03",
    "templateCredsSetupCompleted": true
  },
  "name": "与 XML 文件聊天",
  "tags": [],
  "nodes": [
    {
      "id": "4f235bd2-f128-4875-958a-2cddc66c05c8",
      "name": "执行工作流触发器",
      "type": "n8n-nodes-base.executeWorkflowTrigger",
      "position": [
        -200,
        240
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "28d8e809-12d7-4381-9e0b-7c4ac95f0739",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        40,
        0
      ],
      "parameters": {
        "model": "gpt-3.5-turbo-0125",
        "options": {
          "temperature": 0
        }
      },
      "credentials": {
        "openAiApi": {
          "id": "xGszewSHddi4rRZl",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "dba1ce53-98d8-4337-a7cf-47b13a7afc08",
      "name": "聊天触发器",
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "position": [
        -200,
        -120
      ],
      "webhookId": "2b9d9c42-adf4-425d-b0a5-e4f60c750e63",
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "cb21eb41-af05-447b-89eb-627c7f5f0e4e",
      "name": "AI 代理",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        20,
        -220
      ],
      "parameters": {
        "agent": "reActAgent",
        "options": {
          "suffix": "Here is an XML file. Please parse it and answer questions based on its structure and content. I might ask you to extract specific nodes, attributes, or explain its hierarchy. First, read and understand the XML. Then wait for my questions."
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "aa4a86eb-c634-4a03-a127-0c2c47932ba9",
      "name": "HTTP 请求",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        240,
        240
      ],
      "parameters": {
        "url": "={{ $json.xml_url }}",
        "options": {}
      },
      "typeVersion": 4.2
    },
    {
      "id": "14deaea3-f968-48fa-8979-2d65f8251ce7",
      "name": "XML",
      "type": "n8n-nodes-base.xml",
      "position": [
        460,
        240
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 1
    },
    {
      "id": "99775ddb-ddbb-426c-a008-442201212c66",
      "name": "获取 XML",
      "type": "@n8n/n8n-nodes-langchain.toolWorkflow",
      "position": [
        160,
        0
      ],
      "parameters": {
        "workflowId": {
          "__rl": true,
          "mode": "id",
          "value": "1pfNtfDuGq3yud8G"
        },
        "description": "获取 XML",
        "workflowInputs": {
          "value": {},
          "schema": [],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "f4535013-2fe7-4ccc-b01d-0fe1fc161251",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -920,
        -160
      ],
      "parameters": {
        "width": 620,
        "height": 520,
        "content": "## 与 XML 聊天"
      },
      "typeVersion": 1
    },
    {
      "id": "14e9e36d-b6ec-43a1-8094-308e925f6b87",
      "name": "准备输出",
      "type": "n8n-nodes-base.code",
      "position": [
        680,
        240
      ],
      "parameters": {
        "jsCode": "return {\n 'response': $input.all()\n}"
      },
      "typeVersion": 2
    },
    {
      "id": "e93ae034-9c9b-4dac-b694-a37ec55cfbef",
      "name": "设置 XML URL",
      "type": "n8n-nodes-base.set",
      "position": [
        20,
        240
      ],
      "parameters": {
        "fields": {
          "values": [
            {
              "name": "xml_url",
              "stringValue": "https://www.w3schools.com/xml/note.xml"
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 3.2
    }
  ],
  "active": false,
  "pinData": {
    "Execute Workflow Trigger": [
      {
        "json": {
          "query": "222",
          "operation": "row"
        }
      }
    ]
  },
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "7c401d7f-c51d-40c5-982d-0751a92fd048",
  "connections": {
    "XML": {
      "main": [
        [
          {
            "node": "Prepare output",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get XML": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Set XML URL": {
      "main": [
        [
          {
            "node": "HTTP Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Chat Trigger": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request": {
      "main": [
        [
          {
            "node": "XML",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Execute Workflow Trigger": {
      "main": [
        [
          {
            "node": "Set XML URL",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。

这个工作流适合什么场景?

中级 - 文档提取, AI RAG 检索增强

需要付费吗?

本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。

工作流信息
难度等级
中级
节点数量10
分类2
节点类型10
难度说明

适合有一定经验的用户,包含 6-15 个节点的中等复杂度工作流

外部链接
在 n8n.io 查看

分享此工作流