当我检查documentation的履行错误处理时,我发现了这段代码:
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.');
.
1 回答
听起来你在这里混合了两个概念 .
app.fallback()
函数仅用于注册在没有其他意图处理函数匹配时将被调用的函数 . 您不应该使用它来监视调用的意图 .您应该注册意图处理程序函数,包括命名的回退意图,类似于