我想构建一个 Google Assistant 应用程序以在我的组织内使用。该应用程序将告诉用户当前可用的物品库存。该应用程序将从 Google 电子表格中读取此数据。在 doc.getInfo(function(err, info) 中,在 Google Simulator 上的 Actions 中测试我的应用程序时,我得到的“信息”未定义。有人可以告诉我为什么吗?我按照这些示例在https://www.twilio下面编写代码.com/blog/2017/03/google-spreadsheets-and-javascriptnode-js.html和https://developers.google.com/actions/dialogflow/first-app
'use strict';
process.env.DEBUG = 'actions-on-google:*';
const App = require('actions-on-google').DialogflowApp;
const functions = require('firebase-functions');
// a. the action name from the get_item_name Dialogflow intent
const NAME_ACTION = 'get_item_name';
// b. the parameters that are parsed from the item_name_intent intent
const ITEM_NAME_ARGUMENT = 'item_name_entity';
var GoogleSpreadsheet = require('google-spreadsheet');
var credentials = require('./factoryStockTeller-77942d.json');
var doc = new GoogleSpreadsheet('17E49xZp_JjylT-oVFS1Q8zzJZ9qGkSgQps');
exports.factoryStockTeller = functions.https.onRequest((request, response) =>
{
const app = new App({request, response});
function itemStock(app)
{
let itemName = app.getArgument(ITEM_NAME_ARGUMENT);
// Authenticate with the Google Spreadsheets API.
doc.useServiceAccountAuth(credentials, function (err)
{
doc.getInfo(function(err, info)
{
if(typeof info === "undefined")
app.tell('UnDefined');
else
app.tell('Defined');
});
});
}
// d. build an action map, which maps intent names to functions
let actionMap = new Map();
actionMap.set(NAME_ACTION, itemStock);
app.handleRequest(actionMap);
});