我有这个完整的对话流程代码
const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp();
...............
app.intent('Control_Devices',(conv, { devices, status }) => {
return admin.database().ref(`/ESP8266/${devices}/value`).set(status)
.then(snapshot => {
conv.ask(`OK, ${devices} ${status}. Do you want more?`);
conv.ask(new Suggestions(intentSuggestions));
});
});
并且返回return admin.database()。ref()。set()时出错,然后(snapshot => {}); 它无法与我的实时数据库连接。谁能帮我解决这个问题!!!!
答案 0 :(得分:0)
{
"name": "dialogflowFirebaseFulfillment",
"description": "This is the default fulfillment for a Dialogflow agents using Cloud Functions for Firebase",
"version": "0.0.1",
"private": true,
"license": "Apache Version 2.0",
"author": "Google Inc.",
"engines": {
"node": "8"
},
"scripts": {
"start": "firebase serve --only functions:dialogflowFirebaseFulfillment",
"deploy": "firebase deploy --only functions:dialogflowFirebaseFulfillment"
},
"dependencies": {
"actions-on-google": "^2.2.0",
"firebase-admin": "^5.13.1",
"firebase-functions": "^2.0.2",
"dialogflow": "^0.6.0",
"dialogflow-fulfillment": "^0.5.0"
}
}
这是我的package.json 我对此进行了编辑,但这是行不通的
{
"name": "dialogflowFirebaseFulfillment",
"description": "This is the default fulfillment for a Dialogflow agents using Cloud Functions for Firebase",
"version": "0.0.1",
"private": true,
"license": "Apache Version 2.0",
"author": "Google Inc.",
"engines": {
"node": "8"
},
"scripts": {
"start": "firebase serve --only functions:dialogflowFirebaseFulfillment",
"deploy": "firebase deploy --only functions:dialogflowFirebaseFulfillment"
},
"dependencies": {
"actions-on-google": "^2.2.0",
"firebase-admin": "^7.0.0",
"firebase-functions": "^2.2.0",
"dialogflow": "^0.6.0",
"dialogflow-fulfillment": "^0.5.0"
}
}