- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在 Dialogflow 上创建一个机器人,并使用 Dialogflow-fulfillment 进行动态响应和 Firebase 实时数据库作为数据库。
我在这里想做的是,假设一家提供某些设施的医院在该国拥有多个中心(地点)。现在当用户请求这样的医院时,机器人应该能够向他输出附近医院的位置。我确实在 Firebase 实时数据库中有所有此类医院的列表(具有唯一的纬度和经度)。我的方法是获取用户的精确位置,并将其与数据库中可用的位置进行比较,以找到最近的医院。现在我希望使用 Google Place API(我有一个计费帐户和 API key )向用户输出关于这家医院的额外信息(如医院地址、联系方式、网站、营业时间等)。
虽然我能够通过经纬度获得用户的精确位置,但我在处理 Google Place API 时遇到了一些问题。以下是我在“Firebase 日志”中遇到的一些错误:
Warning, estimating Firebase Config based on GCLOUD_PROJECT. Initializing firebase-admin may fail
Error: Can't set headers after they are sent.
at ServerResponse.OutgoingMessage.setHeader (_http_outgoing.js:356:11)
at ServerResponse.header (/var/tmp/worker/node_modules/express/lib/response.js:767:10)
at ServerResponse.send (/var/tmp/worker/node_modules/express/lib/response.js:170:12)
at ServerResponse.json (/var/tmp/worker/node_modules/express/lib/response.js:267:15)
at callPlaceAPI.then.catch (/user_code/index.js:480:34)
at process._tickDomainCallback (internal/process/next_tick.js:135:7)
var admin = require("firebase-admin");
admin.initializeApp({
credential: admin.credential.applicationDefault(),
databaseURL: "https://test-dia.firebaseio.com"
});
process.env.DEBUG = 'dialogflow:debug';
dmin.initializeApp({
credential: admin.credential.cert({
"type": "service_account",
"project_id": "took from Firebase Generated Private Key",
"private_key_id": "took from Firebase Generated Private Key",
"private_key": "took from Firebase Generated Private Key",
"client_email": "took from Firebase Generated Private Key",
"client_id": "took from Firebase Generated Private Key",
"auth_uri": "took from Firebase Generated Private Key",
"token_uri": "took from Firebase Generated Private Key",
"auth_provider_x509_cert_url": "took from Firebase Generated Private Key",
"client_x509_cert_url": "took from Firebase Generated Private Key"
}),
databaseURL: "https://test-dia.firebaseio.com"
});
process.env.DEBUG = 'dialogflow:debug';
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.5.0",
"firebase-admin": "^5.13.1",
"firebase-functions": "^2.0.2",
"dialogflow": "^0.6.0",
"dialogflow-fulfillment": "^0.6.0"
}
}
{
"candidates" : [
{
"formatted_address" : "140 George St, The Rocks NSW 2000, Australia",
"name" : "Museum of Contemporary Art Australia",
"opening_hours" : {
"open_now" : false
},
"photos" : [
{
"height" : 3492,
"html_attributions" : [
"\u003ca href=\"https://maps.google.com/maps/contrib/105784220914426417603/photos\"\u003eKeith Chung\u003c/a\u003e"
],
"photo_reference" : "CmRaAAAA4fqUuhQuWUh11h_QEJJY5c14dM5V6tRjv9662oZdRxQdyvnmzK6b2ENgL9dtUb_bkSnIUTAzEmxdtJfLFQ1H_eqHDJkkiTedPu664OqkUOtxAfoBPCU01FOI1nN9RifJEhA47TjtbpLsT_yU6mfs8VZKGhRef9lr97rh2asJsCF3XBM-TH-InA",
"width" : 4656
}
],
"place_id" : "ChIJ68aBlEKuEmsRHUA9oME5Zh0"
}
],
"status" : "OK"
}
最佳答案
我遇到了同样的问题,我可以通过在 Intents 页面的执行部分中选中 Enable webhook 按钮来解决它,如图所示
如果这不起作用,您可能想要克隆这个示例项目并尝试在那里添加您的 index.js 文件。 https://github.com/dialogflow/fulfillment-firestore-nodejs
关于firebase-realtime-database - Firebase 日志中的错误 : Warning, 估计基于 GCLOUD_PROJECT 的 Firebase 配置。初始化 firebase-admin 可能会失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54063595/
我尝试运行 index.js 文件,它显示了以下错误 C:\blog\functions>node index.js {"severity": "WARNING", "message": "Warni
我正在 Dialogflow 上构建一个机器人,并且正在使用 Dialogflow-fulfillment。但是,每当我部署时,我都会收到错误: Warning, estimating Firebas
我正在 Dialogflow 上创建一个机器人,并使用 Dialogflow-fulfillment 进行动态响应和 Firebase 实时数据库作为数据库。 我在这里想做的是,假设一家提供某些设施的
我是一名优秀的程序员,十分优秀!