Dialogflow es 使用确认帮助程序时的自定义回退意图
我正在尝试为包含确认的意图创建自定义回退。代码如下:Dialogflow es 使用确认帮助程序时的自定义回退意图,dialogflow-es,actions-on-google,google-home,Dialogflow Es,Actions On Google,Google Home,我正在尝试为包含确认的意图创建自定义回退。代码如下: const functions = require('firebase-functions'); const { dialogflow, Confirmation } = require('actions-on-google'); const app = dialogflow({ debug: true, }); app.intent('vitals-confirmation', (conv, input, co
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”,并被问到下一个问题
但是,当我用非是/否类型的答案(例如:“红色”)回答时,输出以下内容:
似乎有一个默认的回退,响应为“对不起,[重复以前的文本输出]”,而不是我创建的自定义回退意图(这是我想要的结果)。看看Node.js SDK的操作
为了检索用户响应,您必须在DialogFlow中使用操作\u意图\u确认
事件设置意图。我的建议是检查如何配置意图并使用此方法,否则请确保创建具有所需上下文寿命的后续意图
文档中的示例:
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.`)
}
})
您能否更新您的问题以显示意图是如何配置的?
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.`)
}
})