

明确聊天助手、Agent、Chatflow、工作流四者的区别和适用场景,并通过具体Demo验证。
dify搭建聊天助手



Agent

### 技能:
1. 解析用户自然语言中的城市名(如“明天上海需要带伞吗?”→定位“上海”)[7](@ref)
2. 自动补全省份信息(如“广州”补全为“广东省广州市”)[6](@ref)
3. 提供穿衣/出行建议(根据温度、降水概率生成)[4](@ref)
### 交互流程:
1. 用户输入 → 提取城市名 → 调用天气API → 生成结构化报告
2. 若城市名无效 → 引导用户重新输入(如“未找到该城市,请检查名称或切换城市”)[8](@ref)
3. 支持扩展查询(如“未来三小时降雨预测”)[1](@ref)


工作流




functionmain({json_str}) {
let jsonString = json_str.replace(/'/g, '"');
const json = JSON.parse(jsonString);
console.info(json);
let option = {
xAxis: {
type: 'category',
data: json[0]
},
yAxis:{
type: 'value'
},
series: [
{
data: json[1],
type: 'bar',
showBackground: true,
backgroundStyle:{
color: 'rgba(180, 180, 180, 0.2)'
}
}
]
};
let output = "```echarts\n" + JSON.stringify(option) + "\n```";
return {result: output}
}



charflow




http://localhost:8089/customer/handle?userId=1&productId=100&review=非常好,下次还买&type=1
type
type = 1 正面评价
type = 2 售后问题
type = 3 运输问题
type = 其他 其他问题
// CustomerServiceController.java
@RestController
@RequestMapping("/customer")
publicclass CustomerServiceController {
@GetMapping("/handle")
publicString handle(
@RequestParamString userId,
@RequestParamString productId,
@RequestParamStringtype,
@RequestParamString review){
String message;
switch (type) {
case"1":
// 发送至品牌宣传部邮箱
message = "已发送至品牌宣传部邮箱";
break;
case"2":
// 发送至售后邮箱
message = "已发送至售后邮箱";
break;
case"3":
// 发送至运输部邮箱
message = "已发送至运输部邮箱";
break;
default:
// 发送至默认客户支持邮箱
message = "已发送至默认客户支持邮箱";
break;
}
return message;
}
}




总结

本文作者:周瑞谋(上海新炬中北团队)
本文来源:“IT那活儿”公众号

文章转载自IT那活儿,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。




