如何解决Dialogflow CX-如何清除参数
https://i.stack.imgur.com/uq9Yv.png
https://i.stack.imgur.com/jaPaz.png
https://i.stack.imgur.com/SHIuS.png
当我说“不”时,如何获取“数字”参数以清除并输出提示“说数字”?
解决方法
要清除会话中的参数以进行表单填充,必须先将会话中的参数值设置为null,然后再转换回具有表单填充的页面。
有两种方法可以在会话中将参数值设置为null:
-
在页面的意图/条件路由的实现参数预设中添加需要使用空值清除的参数。
a。根据您的情况,您可以在“确认编号”页面的“否”意图路线的实现参数预设中添加具有空值的“数字”参数。
b。当“确认编号”页面的“否”意图路由被触发时,“编号”参数将在会话中清除,并将转换回“插入编号”页面以再次询问该编号。
-
通过实现Web挂钩将参数值设置为null。下面是示例代码供参考:
app.post("/clearnumber",async (request,response) => { let params = request.body.sessionInfo.parameters; //get the current parameters in the session let message = "\n\n number parameter has been cleared... "; console.log("request body:" + request.body); console.log(".....number........... :" + params.number); params.number = null; // setting the number parameter to null console.log("..after.resetting.number........... :" + params.number); request.body.sessionInfo.parameters = params; //add the parameter changes in the sessionInfo that will be sent back to the agent let fulfillmentResponse = { fulfillmentResponse: { messages: [{ text: { text: [] } }] },sessionInfo: request.body.sessionInfo }; fulfillmentResponse.fulfillmentResponse.messages[0].text.text.push(message); response.json(fulfillmentResponse); });
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。