Problema con conecc...
 

Problema con conecci贸n con Firebase (trabajando con Inline Editor)  

  RSS

tiago
(@tiago)
New Member
Registrado: hace 3 semanas
Respuestas: 1
18/11/2019 12:55 pm  

Hola Amigos,

Estoy con un problema al hacer la connecci贸n de un proyecto con el Firebase. Cual es el problema? El codigo est谩 abajo.

'use strict';
const {dialogflow} = require('actions-on-google'); //add teste
const functions = require('firebase-functions');
const {WebhookClient} = require('dialogflow-fulfillment');

//conecci贸n
const admin = require("firebase-admin");
admin.initializeApp({
credential: admin.credential.applicationDefault(),
databaseURL: "ws://buyindronesimport-gqknkq.firebaseio.com",
projectId: "buyindronesimport",
});
var db = admin.firestore();

//fim de la conecci贸n

process.env.DEBUG = 'dialogflow:debug';

exports.dialogflowFirebaseFulfillment = functions.https.onRequest((request, response) => {

let action = request.body.queryResult.action;

let responseJson = {};

switch (action) {
case "buy.drone-types":

let droneTypes = request.body.queryResult.parameters['drone-types'];
let droneTypesKey = droneTypes.replace(/\s/g,'');

let dronesRead = db.collection(droneTypesKey).get();

dronesRead.then((snapshot) => {
let richResponses = [
{
"text": {
"text": [
`Here is a list of all available ${droneTypes} from the dynamic fulfillment call`
]
},
"platform": "FACEBOOK"
}
];
snapshot.forEach((doc) => {
var data = doc.data();
let card = {
"card": {
"title": data.title,
"subtitle": data.subtitle,
"imageUrl": data.imageUrl,
"buttons": [
{
"text": data.buttons.text,
"postback": data.buttons.postback
}
]
},
"platform": "FACEBOOK"
};
richResponses.push(card);
});

return richResponses;
}).then((richResponses) => {
let responseJson = {};
response.json(responseJson);
})
.catch((err) => {
console.log('Error getting documents', err);
});

break;
default:

responseJson.fulfillmentText = 'Unknown action';
response.json(responseJson);
}
});


Citar
Topic Tags
David
(@david)
Trusted Member
Registrado: hace 1 a帽o
Respuestas: 96
18/11/2019 11:03 pm  
Respondido por: @tiago

Hola Amigos,

Estoy con un problema al hacer la connecci贸n de un proyecto con el Firebase. Cual es el problema? El codigo est谩 abajo.

'use strict';
const {dialogflow} = require('actions-on-google'); //add teste
const functions = require('firebase-functions');
const {WebhookClient} = require('dialogflow-fulfillment');

//conecci贸n
const admin = require("firebase-admin");
admin.initializeApp({
credential: admin.credential.applicationDefault(),
databaseURL: "ws://buyindronesimport-gqknkq.firebaseio.com",
projectId: "buyindronesimport",
});
var db = admin.firestore();

//fim de la conecci贸n

process.env.DEBUG = 'dialogflow:debug';

exports.dialogflowFirebaseFulfillment = functions.https.onRequest((request, response) => {

let action = request.body.queryResult.action;

let responseJson = {};

switch (action) {
case "buy.drone-types":

let droneTypes = request.body.queryResult.parameters['drone-types'];
let droneTypesKey = droneTypes.replace(/\s/g,'');

let dronesRead = db.collection(droneTypesKey).get();

dronesRead.then((snapshot) => {
let richResponses = [
{
"text": {
"text": [
`Here is a list of all available ${droneTypes} from the dynamic fulfillment call`
]
},
"platform": "FACEBOOK"
}
];
snapshot.forEach((doc) => {
var data = doc.data();
let card = {
"card": {
"title": data.title,
"subtitle": data.subtitle,
"imageUrl": data.imageUrl,
"buttons": [
{
"text": data.buttons.text,
"postback": data.buttons.postback
}
]
},
"platform": "FACEBOOK"
};
richResponses.push(card);
});

return richResponses;
}).then((richResponses) => {
let responseJson = {};
response.json(responseJson);
})
.catch((err) => {
console.log('Error getting documents', err);
});

break;
default:

responseJson.fulfillmentText = 'Unknown action';
response.json(responseJson);
}
});

Y exactamente que te sale.

Dame todos los detalles posibles para tratar de ayudarte...


ResponderCitar
Share:

Por favor Iniciar Sesi贸n o Registro