问题
I want to implement Suggestions chips in my Dialog flow (to be use in Google Assistant)..But I am getting this error
"ReferenceError: conv is not defined"
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
following is my code
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"
})
}
});
回答1:
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.
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.
来源:https://stackoverflow.com/questions/51192662/referenceerror-conv-is-not-defined-in-actions-on-google