【发布时间】:2020-02-03 09:46:55
【问题描述】:
我有 Dialogflow 的 Javascript 代码在 Google Actions 上做项目。对于此代码,如果答案在数据库中,则意味着它将回答,否则将退出应用程序。所以,我想对这段代码使用 else 循环,请帮助我
function handleCompanyDetails(agent){
const RegNo = agent.parameters.RegNo;
var ref8 = admin.database().ref().child("Table/");
var query8 = ref8.orderByChild("RegNo").equalTo(RegNo);
return query8.once("value")
.then(function(snapshot) {
snapshot.forEach(function(child) {
if( !snapshot.exists() ){
// There are no results, say so
agent.add("There are no results for that account.");
} else {
// ... Do something with the data
agent.add(`The student placed in ` + child.val().CompanyName);
}
});
});
}
【问题讨论】:
标签: javascript firebase dialogflow-es actions-on-google dialogflow-es-fulfillment