dialogflow-es - 擦除/删除/清除要替换的简单响应文本(非连接)
问题描述
在 google library 上的 nodejs 操作中,调用.add(text)
,.ask(text)
和.close(text)
on the conversation 将其连接text
到简单的文本响应中,即
conv.add('hello');
conv.close('world');
// yields text response "hello world"
这通常很好。但是,我遇到了一个情况,我需要清除添加到简单响应文本中的所有内容,以用一些错误处理响应替换它,即
conv.add('hello');
// something went wrong, need to clear "hello" and replace
conv.ask('sorry, could you repeat your command?');
// yields text reponse "sorry, could you repeat your command?"
// *does not* yield "hello sorry, could you repeat your command?"
我在对话对象上找不到实现此行为的函数。有没有办法我可以手动清除响应以便用新的东西替换它们?
解决方案
看起来我可以手动访问Response[]
对话对象上的数组并用空数组将其清除。所以,在我的例子中,我可以这样做:
conv.add('hello');
conv.responses = []; // clears out the previously added "hello"
conv.ask('sorry, could you repeat your command?');
// yields text response "sorry, could you repeat your command?"
推荐阅读
- java - 尽管正在使用“方法从未使用过”-Android工作室
- c# - 使用 Process.Start(Url) 获取 Token 响应
- numpy - sklearn random_state 无法正常工作
- node.js - 按照文档中所示启动 yugabyte 时出错
- python - 将字符串拆分为熊猫中的单独列
- isabelle - 在 Isabelle 中提取 BNF 数据
- java - Jtable 中的小数点显示不正确
- javascript - 是否可以在 React return function() 中使用 if..else 语句
- scala - sbt 程序集创建的 JAR 中缺少的类
- performance - 编译警告 OpenCL 矩阵乘法