https://goo-ai.vip/api/process-v2 注意:必须为异步请求,收到值时根据结果修改流程状态
POST
| 参数名 | 必选 | 类型 | 说明 |
|---|---|---|---|
| question | 是 | string | 对方(债务人)说的话 1、max-lenght:300字 |
| userProp | 是 | object | 用户参数 |
| chatHistory | 是 | array | 历史聊天记录 1、暂时先传历史2轮记录,后期可调整; 2、需要传递客服实际回复的内容。 |
| questionRole | 是 | string | 对方角色(债务人或其亲属、朋友等) |
| answerRole | 是 | string | 客服角色(如调解专员) |
| employeeId | 否 | string | 员工编号(如”160101“,用于调用私有话术库。不传则默认线上话术库) |
| currentNode | v2必须 | DesideNode | 当前节点状态。 ---V2版决策流程(同步) 配合"modelVersion"="2.0"使用 |
| modelVersion | v2必须 | string | 不传时为默认版本1.0。目前有1.0和2.0 |
| processJsonV2 | v2必须 | json | 流程图导出的json内容 |
| 参数名 | 必选 | 类型 | 说明 |
|---|---|---|---|
| userName | 是 | string | 债务人称呼 |
| delayDays | 是 | number | 逾期天数 |
| debt | 是 | number | 债务金额 |
| proxyName | 否 | string | 委托授权方,也叫项目(不传则不过滤该参数) |
| product | 否 | string | 产品名称(不传则不过滤该参数) |
| interest | 否 | number | 利息 |
| rates | 否 | number | 利息可减免比例 |
| character | 否 | string | 债务人性格 |
| gender | 否 | string | 性别 |
| 参数名 | 必选 | 类型 | 说明 |
|---|---|---|---|
| node | 是 | String | 决策流程id |
| isAI | 是 | number | 当前节点是否为协商节点。 为0表示为判断节点,为1表示为协商(AI+话术回复) |
| maxCount | 是 | number | 协商节点最大对话轮数(超过maxCount时,强制进入下一节点) |
| currentIndex | 是 | number | 当前节点对话轮数 |
1、需要维护当前流程状态(包含当前所在节点以及对应的对话轮数),见DesideNode
2、每次请求流式接口(docs)都需要带上currentNode字段。
x
let currentNode:DesideNode = { node: "96162319-6621-4153-8b77-e97310aa3817", maxCount : 1, currentIndex : 1, isAI : 1 }
const params = { question, userProp, chatHistory: newHistoryQ, questionRole, answerRole, employeeId: getEmployeeId(), modelVersion: "2.0", currentNode, processJsonV2 } if(currentNode.isAI == 1){ fetch("/api/process-v2", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(params) }).then(async (response) => { if(response.status == 200){ const data = response.body; if (data) { const reader = data.getReader(); const decoder = new TextDecoder(); const { value } = await reader.read(); const content = decoder.decode(value); try { const json = JSON.parse(content); if(json && json.value && json.nextNode && json.currentIndex!=undefined && json.maxCount!=undefined && json.isAI!=undefined){ currentNode.node = json.nextNode; currentNode.currentIndex = json.currentIndex; currentNode.maxCount = json.maxCount; currentNode.isAI = json.isAI; } } catch (error) { console.log("no result."); } } } }); }
xxxxxxxxxx{ "process": "confirmPay-undefined", "question": "确认还款意愿", "value": "不确定", "detail": "债务人表示目前没有稳定的收入来源,也没有零工收入,因此无法确定是否能够还款。建议继续与债务人沟通,了解其财务状况,寻找更合适的还款方案。", "nextNode": "cantPay", "maxCount": 2, "currentIndex": 1, "isAI": 0}//把以上返回内容保存在currentNode