【发布时间】:2019-01-09 15:51:15
【问题描述】:
我正在尝试使用我创建 Google Cloud 的实体中的实现,但是即使部署中没有错误,当我测试时我也会遇到错误:
{
"error": "Cannot read property 'Definicion' of undefined"
}
我附上带有云实体图片的链接enter image description here
这里也附上代码。
'use strict';
const functions = require ('firebase-functions');
const {dialogflow} = require ('actions-on-google');
// instantiate the object
const datastore_enfermedades = require('@google-cloud/datastore');
// instantiate a datastore client
const datastore = datastore_enfermedades ();
const WELCOME_INTENT = 'Default Welcome Intent';
const FALLBACK_INTENT = 'Default Fallback Intent';
const LOOKING_FOR_DISEASE_INTENT = 'InfoDisease';
const DISEASE_TYPE_ENTITY = 'TypeDisease';
const app = dialogflow ();
app.intent (WELCOME_INTENT, (conv) => {
conv.ask('Hola! Si quieres puedo darte más información sobre alguna enfermedad, pregúntame!');
});
app.intent (FALLBACK_INTENT, (conv) => {
conv.ask('Ai, no te he entendido, ¿puedes repetirmelo por favor?');
});
const disease1 = datastore.createQuery('Tabla de enfermedades').filter('Enfermedad', '=','artritis');
app.intent(LOOKING_FOR_DISEASE_INTENT, (conv) => {
const disease_type = conv.parameters[DISEASE_TYPE_ENTITY].toLowerCase();
if (disease_type == "artritis") {
return datastore.runQuery(disease1).then(results => {
conv.ask(results[0][1].Definicion);
});
} else {
conv.ask("Puedes repetirlo por favor?");
}
});
exports.dialogflowFirebaseFulfillment = functions.https.onRequest(app);
【问题讨论】:
标签: javascript google-cloud-datastore dialogflow-es actions-on-google google-home