回退到意图实现中的特定意图
Fallback to specific intent within intent fulfillment
当我检查 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.');
.
听起来你在这里混淆了两个概念。
app.fallback()
函数只是为了注册一个函数,如果没有其他意图处理函数匹配,该函数将被调用。您不应该使用它来监视调用的意图。
您应该注册意向处理函数,包括一个命名的后备意向,类似
app.intent( 'fallback intent name', function(conv) )
当我检查 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.');
.
听起来你在这里混淆了两个概念。
app.fallback()
函数只是为了注册一个函数,如果没有其他意图处理函数匹配,该函数将被调用。您不应该使用它来监视调用的意图。
您应该注册意向处理函数,包括一个命名的后备意向,类似
app.intent( 'fallback intent name', function(conv) )