【发布时间】:2018-07-05 13:31:38
【问题描述】:
我想在我的 Dialog 流程中实现 Suggestions 芯片(在 Google Assistant 中使用)..但是我收到了这个错误
"ReferenceError: conv is not defined"
我不明白。我已经阅读了官方文档,但我错过了什么?我还在他的活动中添加了actions_intent_OPTION
以下是我的代码
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"
})
}
});
【问题讨论】:
标签: webhooks actions-on-google dialogflow-es