我正在尝试使用Google图书馆操作中提供的帮助器意图(对于DialogFlow v2),到目前为止没有任何运气。代码编译完全正常,但在执行时(在移动设备和模拟器上),调用会引发Reference错误。我已经搜索了互联网全球,到目前为止没有运气。有什么建议吗?
我的代码(基于https://developers.google.com/actions/assistant/helpers#confirmation且几乎相同)
testdata
抛出的错误:
const { dialogflow } = require('actions-on-google');
const app = dialogflow();
...
app.intent('program', conv => {
if (somestatement) {
const parameters = somedata;
conv.contexts.set(contextVariable, 1, parameters);
return conv.ask(new Confirmation('prompt!'));
}
});
我也在使用最新的google依赖操作:
ReferenceError: Confirmation is not defined
at app.intent.conv (/user_code/index.js:161:25)
at Function.<anonymous> (/user_code/node_modules/actions-on-google/dist/service/dialogflow/dialogflow.js:146:23)
at next (native)
at /user_code/node_modules/actions-on-google/dist/service/dialogflow/dialogflow.js:22:71
at __awaiter (/user_code/node_modules/actions-on-google/dist/service/dialogflow/dialogflow.js:18:12)
at Function.handler (/user_code/node_modules/actions-on-google/dist/service/dialogflow/dialogflow.js:84:16)
at Object.<anonymous> (/user_code/node_modules/actions-on-google/dist/assistant.js:55:32)
at next (native)
at /user_code/node_modules/actions-on-google/dist/assistant.js:22:71
at __awaiter (/user_code/node_modules/actions-on-google/dist/assistant.js:18:12)
我甚至将新的Confirmation()帮助器更改为任何其他助手,没有运气。在DialogFlow方面,我有上述相同文档链接所需的意图。
任何帮助都很有帮助!
答案 0 :(得分:2)
你需要加载Confirmation
对象,所以用这样的东西替换你的第一行应该有效:
const { dialogflow, Confirmation } = require('actions-on-google');