actions-on-google - 在意图实现中回退到特定意图
问题描述
当我检查有关履行错误处理的文档时,我发现了以下代码:
const WELCOME_INTENT = 'Default Welcome Intent';
const NUMBER_INTENT = 'Input Number';
const NUMBER_ARGUMENT = 'num';
// you can add a fallback function instead of a function for individual intents
app.fallback((conv) => {
// intent contains the name of the intent
// you defined in the Intents area of Dialogflow
const intent = conv.intent;
switch (intent) {
case WELCOME_INTENT:
conv.ask('Welcome! Say a number.');
break;
case NUMBER_INTENT:
const num = conv.arguments.get(NUMBER_ARGUMENT);
conv.close(`You said ${num}`);
break;
}
});
我想知道是否有办法直接引用自定义后备意图(my.intent.fallback
)(特定于意图,my.intent
)(如某些conv.intent("my.intent.fallback")
api 调用)而不是conv.ask('Welcome! Say a number.');
.
解决方案
听起来您在这里混合了两个概念。
该app.fallback()
函数仅用于注册一个函数,如果没有其他意图处理函数匹配,该函数将被调用。您不应该使用它来监视调用的意图。
您应该注册意图处理函数,包括命名的回退意图,例如
app.intent( 'fallback intent name', function(conv) )
推荐阅读
- vb.net - 输入超过 10 个数字时,“算术运算导致溢出”
- c++ - 如何将 IBM cplex 标准输出转换为字符串而不是在控制台上打印?
- r - PLS-DA 个人在 R 中使用插入符号包绘制
- python - 如何删除对“HTTP For Humans”请求库的依赖并改用 urllib?
- jasper-reports - 从 jasper 报告中的数据库中获取数据并将其显示在文本字段中
- android - 我正在使用 recreate() 刷新,但为什么它会双重刷新?
- ruby-on-rails - 无法使用 ruby 版本 ruby-1.8.7-p374 进行捆绑安装和 gem install bundler -v 1.17.3
- django - 使用 Django 表单和手动设置日期字段有什么区别?
- mysql - Sequelize:对连接表使用包含
- java - Google App Engine - 日志消息不可见