I want to build a Google Assistant app for use within my organization. The app will tell the user the currently available stock of an item. The app will read this data from a Google Spreadsheet. In doc.getInfo(function(err, info) I am getting 'info' as undefined when testing my app in Actions on Google Simulator. Can someone please tell why? I followed these examples to write code below https://www.twilio.com/blog/2017/03/google-spreadsheets-and-javascriptnode-js.html and 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);
});