Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/amazon-s3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google cloud firestore 错误-警告,缺少FIREBASE_配置环境变量。初始化firebase管理员将失败_Google Cloud Firestore_Google Cloud Functions_Dialogflow Es - Fatal编程技术网

Google cloud firestore 错误-警告,缺少FIREBASE_配置环境变量。初始化firebase管理员将失败

Google cloud firestore 错误-警告,缺少FIREBASE_配置环境变量。初始化firebase管理员将失败,google-cloud-firestore,google-cloud-functions,dialogflow-es,Google Cloud Firestore,Google Cloud Functions,Dialogflow Es,我尝试将现有firestore数据库连接到Dialogflow实现。该功能已成功部署到谷歌云功能,但我无法将数据添加到我的数据库。我尝试更改节点版本8,但仍然失败。请帮帮我 Index.js 'use strict'; const admin = require('firebase-admin'); const {WebhookClient} = require('dialogflow-fulfillment'); const {Card, Suggestion} = require('dial

我尝试将现有firestore数据库连接到Dialogflow实现。该功能已成功部署到谷歌云功能,但我无法将数据添加到我的数据库。我尝试更改节点版本8,但仍然失败。请帮帮我

Index.js

'use strict';
const admin = require('firebase-admin');
const {WebhookClient} = require('dialogflow-fulfillment');
const {Card, Suggestion} = require('dialogflow-fulfillment');
   

  admin.initializeApp({
   apiKey: "Axxxx",
    authDomain: "/xxxxx.firebaseio.com",
    databaseURL: "https:/xxxxxx.firebaseio.com",
    projectId: "mxxxxx8",
    storageBucket: "xxxxx.com",
  });

  const functions = require('firebase-functions');
  const settings = {timestampsInSnapshots: true};
  var db = admin.firestore();
  admin.firestore().settings({ timestampsInSnapshots: true });
 
process.env.DEBUG = 'dialogflow:debug'; // enables lib debugging statements
 
exports.dialogflowFirebaseFulfillment = functions.https.onRequest((request, response) => {
  const agent = new WebhookClient({ request, response });
  console.log('Dialogflow Request headers: ' + JSON.stringify(request.headers));
  console.log('Dialogflow Request body: ' + JSON.stringify(request.body));
 
  function welcome(agent) {
    agent.add(`Welcome to my agent!`);
  }
 
  function fallback(agent) {
    agent.add(`I didn't understand`);
    agent.add(`I'm sorry, can you try again?`);
  }
  

  // Run the proper function handler based on the matched Dialogflow intent name
  let intentMap = new Map();
  intentMap.set('Default Welcome Intent', welcome);
  intentMap.set('Default Fallback Intent', fallback);
  // intentMap.set('your intent name here', yourFunctionHandler);
  // intentMap.set('your intent name here', googleAssistantHandler);
  agent.handleRequest(intentMap);
});
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.1.1",
    "firebase-functions": "^2.2.1",
    "dialogflow": "^0.6.0",
    "dialogflow-fulfillment": "^0.5.0"
  }

您的Firebase初始化似乎错误。以下是您应该如何做到这一点:

.
.
.
admin.initializeApp({
  credential: admin.credential.applicationDefault(),
  databaseURL: 'https://<DATABASE_NAME>.firebaseio.com'
});
.
.
.
。
.
.
admin.initializeApp({
凭据:admin.credential.applicationDefault(),
数据库URL:'https://.firebaseio.com'
});
.
.
.
这应该行得通。

基于此

servicecomport=require('./servicecomport.json');
const adminConfig=JSON.parse(process.env.FIREBASE\u CONFIG);
adminConfig.credential=admin.credential.cert(serviceAccount);
admin.initializeApp(adminConfig);

解决方案是将Firebase项目计划升级为Blaze计划。然后在Firebase项目下创建一个新的Dialogflow代理。

谢谢您的回复。我已经尝试过了,但仍然出现相同的错误。没关系,我找到了答案。我从当前的firebase项目中创建了一个新的google云项目。如果您已经解决了这个问题,并且不再相关,只需删除它。感谢您的回复。我已经找到解决方案了,请考虑将解决方案添加到您的问题中作为答案。