使用确认助手时的自定义后备意图 [英] Custom fallback intents when using confirmation helper

查看:128
本文介绍了使用确认助手时的自定义后备意图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为包含确认的意图创建自定义后备。下面是代码:

I'm trying to create custom fallbacks for intents that contain confirmations. Here is the code:

const functions = require('firebase-functions');
const {
    dialogflow,
    Confirmation
} = require('actions-on-google');


const app = dialogflow({
    debug: true,
});

app.intent('vitals-confirmation', (conv, input, confirmation) => {
    conv.ask(new Confirmation(`Great! Have you fainted recently?`));
});

app.intent('vitals-confirmation-fallback', (conv, input, confirmation) => {
    conv.ask(new Confirmation(`Sorry I didn't understand what you said. Did you faint?`));
})

app.intent('S1-confirmation', (conv, input, confirmation) => {
    if (confirmation) {
        conv.ask(new Confirmation(`I have recorded that you have fainted. Have your feet been hurting?`));
    } else {
        conv.ask(new Confirmation(`I have recorded that you have not fainted. Have your feet been hurting?`));
    }
});

我的应用程序询问用户是否对 vitals-confirmation感到晕厥,并且预期用户会答案为肯定或否的答案,将由确认帮助者确定,如果他们正确地执行了操作,则将转到 S1-confirmation,并被问到下一个问题。

My app asks the user if they have fainted in "vitals-confirmation" and the user is expected to answer with a yes or no type answer that will be identified by the confirmation helper, if they do this correctly they will go to "S1-confirmation" and will be asked the next question.

但是,当我回答不是肯定/否定答案的答案(例如:红色)时,输出以下内容:

However the following is outputted when I respond with an answer that is not a yes/no type answer (for example: "red"):

Sorry, Great! Have you fainted recently?

似乎有一个默认的后备,其响应为对不起,[重复以前的文本输出] ,并且不会转到我创建的自定义后备意图(这是我想要的结果)。

It seems as though there is a default fallback that responds with "Sorry, [repeats previous text output]" and does not go to a custom fallback intent which I have created (which is my desired result).

推荐答案

有关确认帮助器的文档中

Take a look at the documentation for Confirmation helper of Actions SDK for Node.js.

您必须使用DialogFlow中的 actions_intent_CONFIRMATION 事件设置一个意图。为了检索用户响应。我的建议是检查您如何配置意图并使用此方法,否则请确保创建具有所需上下文寿命的后续意图。

You have to setup an intent with the actions_intent_CONFIRMATION event in DialogFlow in order to retrieve the user response. My advice is to check how you configured your intents and use this method, otherwise be sure to create the follow-up intents with the desired context lifespan.

文档中的示例:

app.intent('Default Welcome Intent', conv => {
  conv.ask(new Confirmation('Are you sure you want to do that?'))
})

// Create a Dialogflow intent with the `actions_intent_CONFIRMATION` event
app.intent('Get Confirmation', (conv, input, confirmation) => {
  if (confirmation) {
    conv.close(`Great! I'm glad you want to do it!`)
  } else {
    conv.close(`That's okay. Let's not do it now.`)
  }
})

这篇关于使用确认助手时的自定义后备意图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆