firebase - dialogflow 和 firebase - 无法从 firebase 读取数据
问题描述
以下是我的履行内联代码
const functions = require('firebase-functions');
const {WebhookClient} = require('dialogflow-fulfillment');
// initialise DB connection
const admin = require('firebase-admin');
admin.initializeApp({
credential: admin.credential.applicationDefault(),
databaseURL: 'ws://rochechatbot.firebaseio.com/',
});
process.env.DEBUG = 'dialogflow:debug';
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 handleData(agent) {
const Product_name = agent.parameters.Product_name;
agent.add('Hello');
return admin.database().ref('rochechatbot').once("value").then((snapshot) => {
var StockData = snapshot.child("Stock").val();
agent.add(StockData);
});
}
// Run the proper function handler based on the matched Dialogflow intent name
let intentMap = new Map();
intentMap.set('StockLevelEnquiry', handleData);
agent.handleRequest(intentMap);
});
下面是我的火力数据库
下面是我的对话流程,webhook 已启用
想知道为什么连“你好”都没有返回?如何从火力库中读取数据?
解决方案
推荐阅读
- docker - docker:两阶段构建中的变量
- ios - GraphQL Object mapping Apollo with different schema by target
- angular - Aggrid-如何添加数据绑定masterDetailComponent
- primefaces - 找不到 AdminFaces 的 theme.css 资源
- python - 为多个 celery worker 和线程正确设置 Flask-SQLAlchemy
- javascript - 如何强制 'asp:Image' 加载新的 'imageUrl' ?
- django - Elasticsearch 的问题:ConnectionError
- android - Flutter 是否有上下文操作栏,用于从列表视图中选择多个项目
- java - RxJava 门机制
- node.js - 使用带有大文件的 xlsx 模块时出现内存不足异常