Ниже я тестирую клиентскую библиотеку node.js с помощью api.ai, я скопировал точный код из примера, приведенного на этой странице.
https://developers.google.com/actions/reference/nodejs/ApiAiApp
Но каждый раз, когда я получаю
TypeError: ApiAiApp is not a constructor
at /app/index.js:9:15
at Layer.handle [as handle_request] (/app/node_modules/express/lib/router/layer.js:95:5)
Вот мой файл index.js:
var express = require('express');
var request = require('request');
var exps = express();
const ApiAiApp = require('actions-on-google').ApiAiApp;
exps.post('/hook', function(request, response) {
const app = new ApiAiApp({request, response});
response.status(200)
response.json({
speech: "Hello from hook",
displayText: "Hello from hook",
source: 'HOOK'
})
console.log("RESPONSE :::: \n");
console.log(response);
});
exps.listen((process.env.PORT || 8000), function() {
console.log("App up and running, listening.")
})
Пакет.json
{
"name": "googleActionNode",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "node index.js"
},
"author": "Sukhvinder Singh",
"dependencies": {
"actions-on-google": "1.2.0",
"body-parser": "^1.15.0",
"express": "^4.13.4"
},
"devDependencies": {},
"repository": {
"type": "git",
"url": "git+https://github.com/sukhvinder1/googleActionNode.git"
},
"license": "ISC",
"bugs": {
"url": "https://github.com/sukhvinder1/googleActionNode/issues"
},
"homepage": "https://github.com/sukhvinder1/googleActionNode#readme"
}
если я закомментирую ниже строки, все работает нормально.
const app = new ApiAiApp({request: request, response: response});
Может ли кто-нибудь помочь мне здесь?