ReferenceError:在Google动作中未定义转化 [英] ReferenceError: conv is not defined in actions-on-google
问题描述
我想在我的对话框流程中实现建议芯片(在Google助手中使用)。.但是我遇到了这个错误
I want to implement Suggestions chips in my Dialog flow (to be use in Google Assistant)..But I am getting this error
ReferenceError:未定义转换
"ReferenceError: conv is not defined"
我不理解。我已经查阅了官方文档,但我是什么人失踪?我还在他的事件 <<中添加了 actions_intent_OPTION
img src = https://i.stack.imgur.com/5Z8ZS.png alt =在此处输入图片描述>
which i didn't understand.I have go through the official docs but what am i missing? I have also added actions_intent_OPTION
in his Event
以下是我的代码
const functions = require('firebase-functions');
const {actionssdk} = require('actions-on-google');
const app = actionssdk({debug: true});
var admin = require("firebase-admin");
admin.initializeApp(functions.config().firebase);
var firestore = admin.firestore();
exports.webhook = functions.https.onRequest((request, response) => {
switch (request.body.result.action) {
case 'countitem':
firestore.collection('orders').get()
.then((querySnapshot) => {
var orders = [];
querySnapshot.forEach((doc) => { orders.push(doc.data()) });
// now orders have something like this [ {...}, {...}, {...} ]
response.send({
speech: `you have ${orders.length} orders11, would you like to see them? (yes/no)`
});
})
.catch((err) => {
console.log('Error getting documents', err);
response.send({
speech: "something went wrong when reading from database"
})
})
conv.ask(new Suggestions('Suggestion Chips'));
conv.ask(new Suggestions(['suggestion 1', 'suggestion 2']));
break;
default:
response.send({
speech: "no action matched in webhook"
})
}
});
推荐答案
问题是 conv
未定义。通常,如果您使用的是 Google行动库,转换
传递给您的履行功能,其中包含可用于设置答复等的方法。
The issue is that conv
isn't defined. Typically, if you're using the actions-on-google library, conv
is passed to your fulfillment function and contains methods you can use to set replies and so forth.
看起来您要自己处理一切并手动生成JSON响应。如果是这样,您应该将使用JSON 指南作为Webhook的一部分,并 JSON示例存储库。
It looks like you're handling everything yourself and generating the JSON response manually. If so, you should consult the guide for using JSON as part of your webhook and the repository of JSON examples.
这篇关于ReferenceError:在Google动作中未定义转化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!