跳转到主内容

教程 - 使用 RAGFlow 构建电商客服 Agent

阅读时间 7 分钟

目前,电商零售平台广泛使用智能客服系统来处理大量的用户咨询。然而,传统的智能客服往往难以满足用户日益复杂多样的需求。例如,客户在购买前可能需要详细比较不同型号产品的功能;由于丢失了说明书,他们可能无法使用某些功能;或者,对于家居产品,他们可能需要通过客服安排上门安装预约。

为了解决这些挑战,我们识别了几种常见的需求场景,包括产品型号功能差异查询、使用帮助请求以及上门安装服务预约。基于 RAGFlow 最近推出的 Agent 框架,本博客介绍了一种通过将工作流编排与大语言模型相结合,实现用户咨询自动识别和分支处理的方法。

工作流编排如下

Image

以下章节将详细解释该解决方案的实现过程。

1. 准备数据集

1.1 创建数据集

您可以从 Hugging Face Datasets 下载示例数据集。

创建“产品信息”和“用户指南”知识库,并上传相关的数据集文档。

1.2 解析文档

对于“产品信息”和“用户指南”知识库中的文档,我们选择使用手动分块。

Image

产品手册通常图文并茂,信息量大,结构复杂。仅仅依靠文本长度进行分割可能会破坏内容的完整性。RAGFlow 假定这类文档遵循层级结构,因此使用“最小标题”作为分割的基本单位,确保每段文本及其附图在单个块中保持完整。以下是用户手册分割后的预览

Image

2. 构建工作流

2.1 创建应用

成功创建后,系统将在画布上自动生成一个开始组件。

Image

在开始组件中,可以配置客服的开场问候语,例如

Hi! I'm your assistant. 

Image

2.2 添加分类(Categorize)组件

分类组件使用大语言模型(LLM)进行意图识别。它对用户输入进行分类,并根据类别的名称、描述和提供的示例,将其路由到适当的处理工作流。

Image

2.3 构建产品特性对比工作流

检索组件连接到“产品信息”知识库,以获取与用户查询相关的内容,然后将其传递给 Agent 组件以生成响应。

Image

添加一个名为“功能比较知识库”的检索组件,并将其链接到“产品信息”知识库。

Image

在检索组件后添加一个 Agent 组件,命名为“功能比较 Agent”,并按如下方式配置系统提示

## Role
You are a product specification comparison assistant.
## Goal
Help the user compare two or more products based on their features and specifications. Provide clear, accurate, and concise comparisons to assist the user in making an informed decision.
---
## Instructions
- Start by confirming the product models or options the user wants to compare.
- If the user has not specified the models, politely ask for them.
- Present the comparison in a structured way (e.g., bullet points or a table format if supported).
- Highlight key differences such as size, capacity, performance, energy efficiency, and price if available.
- Maintain a neutral and professional tone without suggesting unnecessary upselling.
---

配置用户提示

User's query is /(Begin Input) sys.query 

Schema is /(Feature Comparison Knowledge Base) formalized_content

配置完 Agent 组件后,结果如下

Image

2.4 构建产品用户指南工作流

检索组件查询“用户指南”知识库中与用户问题相关的内容,然后将结果传递给 Agent 组件以制定响应。

Image

添加一个名为“使用指南知识库”的检索组件,并将其链接到“用户指南”知识库。

Image

在检索组件后添加一个 Agent 组件,命名为“使用指南 Agent”,并按如下方式配置其系统提示

## Role
You are a product usage guide assistant.
## Goal
Provide clear, step-by-step instructions to help the user set up, operate, and maintain their product. Answer questions about functions, settings, and troubleshooting.
---
## Instructions
- If the user asks about setup, provide easy-to-follow installation or configuration steps.
- If the user asks about a feature, explain its purpose and how to activate it.
- For troubleshooting, suggest common solutions first, then guide through advanced checks if needed.
- Keep the response simple, clear, and actionable for a non-technical user.
---

编写用户提示

User's query is /(Begin Input) sys.query 

Schema is / (Usage Guide Knowledge Base) formalized_content

配置完 Agent 组件后,结果如下

Image

2.5 构建安装预约助手

Agent 与用户进行多轮对话,以收集三个关键信息:联系电话、安装时间和安装地址。创建一个名为“安装预约 Agent”的 Agent 组件,并按如下方式配置其系统提示

# Role
You are an Installation Booking Assistant.
## Goal
Collect the following three pieces of information from the user
1. Contact Number
2. Preferred Installation Time
3. Installation Address
Once all three are collected, confirm the information and inform the user that a technician will contact them later by phone.
## Instructions
1. **Check if all three details** (Contact Number, Preferred Installation Time, Installation Address) have been provided.
2. **If some details are missing**, acknowledge the ones provided and only ask for the missing information.
3. Do **not repeat** the full request once some details are already known.
4. Once all three details are collected, summarize and confirm them with the user.

编写用户提示

User's query is /(Begin Input) sys.query 

配置完 Agent 组件后,结果如下

Image

如果需要注册用户信息,可以在 Agent 组件后连接一个 HTTP 请求组件,将数据传输到 Google Sheets 或 Notion 等平台。开发者可以根据具体需求实现此功能;本博客文章不涉及实现细节。

Image

2.6 添加消息回复(Reply)组件

对于这三个工作流,使用单个消息组件来接收 Agent 组件的输出,然后向用户显示处理后的结果。

Image

2.7 保存并测试

点击保存 → 运行 → 查看执行结果。当询问产品型号和功能时,系统正确返回了比较结果

Image

当询问使用说明时,系统提供了准确的指导

Image

当预约安装时,系统收集并确认了所有必要信息

Image

小结

这个用例也可以使用基于 Agent 的工作流来实现,其优点是能灵活处理复杂问题。然而,由于 Agent 会主动进行规划和反思,它们通常会显著增加响应时间,导致客户体验下降。因此,这种方法不太适合像电商售后客服这样要求高响应性和任务相对直接的场景。对于涉及复杂问题的应用,我们之前分享过深度研究(Deep Research)多 Agent 框架。相关模板可在我们的模板库中找到。

Image

本文介绍的客服工作流是为电子商务设计的,但该领域还有更多适合工作流自动化的场景——例如用户评论分析和个性化邮件营销——本文并未涉及。通过遵循所提供的实践指南,您也可以轻松地将这种方法应用于其他客服环境。我们鼓励您使用 RAGFlow 构建此类应用。用大语言模型重塑客户服务,使支持超越了“机械式回应”,将能力从单纯的“检索与匹配”提升到“认知推理”。通过深度理解和实时知识生成,它提供了前所未有的“懂人话”的体验,从而重新定义了智能服务的上限,并将支持转变为企业的核心价值引擎。

© . This site is unofficial and not affiliated with InfiniFlow.