Google 上的操作 - 没有输入提示作为对话流程的一部分被询问
Actions on Google - no input prompts being asked as part of conversation flow
我一直在查看有关 google 操作的最佳实践指南,具体来说,我正在尝试实施 'repeat' 概述的功能 here
现在,示例代码引用未定义的 params/functions 并没有帮助,但具体来说,看起来您应该能够将 'NO_INPUT_PROMPTS' 参数传递给 conv.ask()
因此,如果用户没有在指定时间内回答,它就会使用这些来提示他们。据我了解,这可能是一个字符串或数组。
问题是,当我将一个数组传递给函数时,它实际上停止了我的操作。如果我传递一个字符串,它会将它连接到初始问题而不是作为一个提示。
任何人都可以帮助解决这个问题。我的代码如下:
const {dialogflow} = require('actions-on-google');
const functions = require('firebase-functions');
const app = dialogflow({debug: true});
const NO_INPUT_PROMPTS = ['Would you like to answer the question?'];
function ask(conv, inputPrompt, noInputPrompts) {
conv.data.lastPrompt = inputPrompt;
conv.data.lastNoInputPrompts = noInputPrompts;
conv.ask(inputPrompt,noInputPrompt);
}
app.intent('Default Welcome Intent', conv => {
let message = "Hello what's your favourite color";
ask(conv,message,NO_INPUT_PROMPTS);
})
查看 https://github.com/actions-on-google/actions-on-google-nodejs/blob/master/src/service/actionssdk/conversation/conversation.ts#L431 处的代码,当我调用 ask
时,它实际上是将其附加到响应数组中,并且它们都被一起读出,而不是被解释为重新提示。有人知道这里缺少的 'link' 代码是什么吗?
我在库和 NodeJS v8 上使用 actions-on-google
的 v2.2.0。意图是在 dialogflow
中创建的
典型!因此,在尝试解决这个问题 2 天后,就在发布问题后,我偶然发现了可能的解决方案。
我认为问题在于您需要明确设置 conv.noInputs 属性,而不是将其作为询问的一部分传递。我打算将此作为文档错误提交,希望它不会让其他人发现。
function ask(conv, inputPrompt, noInputPrompts) {
conv.data.lastPrompt = inputPrompt;
conv.data.lastNoInputPrompts = noInputPrompts;
conv.noInputs = noInputPrompts
conv.ask(inputPrompt);
}
我一直在查看有关 google 操作的最佳实践指南,具体来说,我正在尝试实施 'repeat' 概述的功能 here
现在,示例代码引用未定义的 params/functions 并没有帮助,但具体来说,看起来您应该能够将 'NO_INPUT_PROMPTS' 参数传递给 conv.ask()
因此,如果用户没有在指定时间内回答,它就会使用这些来提示他们。据我了解,这可能是一个字符串或数组。
问题是,当我将一个数组传递给函数时,它实际上停止了我的操作。如果我传递一个字符串,它会将它连接到初始问题而不是作为一个提示。
任何人都可以帮助解决这个问题。我的代码如下:
const {dialogflow} = require('actions-on-google');
const functions = require('firebase-functions');
const app = dialogflow({debug: true});
const NO_INPUT_PROMPTS = ['Would you like to answer the question?'];
function ask(conv, inputPrompt, noInputPrompts) {
conv.data.lastPrompt = inputPrompt;
conv.data.lastNoInputPrompts = noInputPrompts;
conv.ask(inputPrompt,noInputPrompt);
}
app.intent('Default Welcome Intent', conv => {
let message = "Hello what's your favourite color";
ask(conv,message,NO_INPUT_PROMPTS);
})
查看 https://github.com/actions-on-google/actions-on-google-nodejs/blob/master/src/service/actionssdk/conversation/conversation.ts#L431 处的代码,当我调用 ask
时,它实际上是将其附加到响应数组中,并且它们都被一起读出,而不是被解释为重新提示。有人知道这里缺少的 'link' 代码是什么吗?
我在库和 NodeJS v8 上使用 actions-on-google
的 v2.2.0。意图是在 dialogflow
典型!因此,在尝试解决这个问题 2 天后,就在发布问题后,我偶然发现了可能的解决方案。
我认为问题在于您需要明确设置 conv.noInputs 属性,而不是将其作为询问的一部分传递。我打算将此作为文档错误提交,希望它不会让其他人发现。
function ask(conv, inputPrompt, noInputPrompts) {
conv.data.lastPrompt = inputPrompt;
conv.data.lastNoInputPrompts = noInputPrompts;
conv.noInputs = noInputPrompts
conv.ask(inputPrompt);
}