Actions on google 在意图实现中回退到特定意图

Actions on google 在意图实现中回退到特定意图,actions-on-google,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) => {

当我检查执行错误处理时,我发现以下代码:

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.ask(
myintent.fallback”)
api调用(比如一些
conv.intent.fallback”)

听起来你在混合两个概念

app.fallback()
函数仅用于注册一个函数,如果没有其他意图处理程序函数匹配,则将调用该函数。你不应该用它来监视意图是什么

您应该使用以下内容注册意图处理程序函数,包括命名的回退意图

app.intent( 'fallback intent name', function(conv) )

我认为
app.fallback
可以将意图注册到特定意图,更像是尝试捕捉对话流。但是,似乎app.fallback
更像是一个全局性的方法,比如“默认的回退意图”,对吗?有点像。正如我在回答中所说,如果您想注册到特定的意图,请使用
app.intent()
。如果没有与
app.intent()
匹配的函数可用,则调用
app.fallback()
中的函数。酷,有意义!