【问题标题】:ReferenceError: conv is not defined in actions-on-googleReferenceError:conv 未在 actions-on-google 中定义
【发布时间】: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


    【解决方案1】:

    问题是conv 没有定义。通常,如果您使用的是actions-on-google libraryconv 将传递给您的履行函数,并包含可用于设置回复等的方法。

    您似乎在自己处理所有事情并手动生成 JSON 响应。如果是这样,您应该咨询 guide for using JSON 作为 webhook 的一部分和 repository of JSON examples

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-06-07
      • 2017-10-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多