使用确认帮助程序时自定义回退意图

问题描述 投票:1回答:1

我正在尝试为包含确认的意图创建自定义回退。这是代码:

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?`));
    }
});

我的应用程序询问用户是否已经在“重要确认”中晕倒,并且用户应该回答肯定帮助者将识别的是或否类型答案,如果他们正确地执行此操作,他们将转到“S1-确认“并将被问到下一个问题。

但是,当我回答一个不是是/否类型答案的答案时,会输出以下内容(例如:“red”):

Sorry, Great! Have you fainted recently?

似乎有一个默认的回退响应“抱歉,[重复以前的文本输出]”并没有转到我创建的自定义回退意图(这是我想要的结果)。

dialogflow actions-on-google google-home
1个回答
0
投票

看一下针对Node.js的Actions SDK的documentation for Confirmation helper

您必须使用DialogFlow中的actions_intent_CONFIRMATION事件设置intent,以便检索用户响应。我的建议是检查你如何配置你的意图并使用这个方法,否则一定要创建具有所需上下文生命周期的后续意图。

文档示例:

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.`)
  }
})
© www.soinside.com 2019 - 2024. All rights reserved.