I am new to node js and developing chat bot using Dialogflow. To get specific response from firebase, I have to call functions as below.
admin.database().ref(institutes+'/'+ Programme).once("value").then((snapshot) => {
reply= snapshot.val();}).then((reply) => {
for (var key in reply)
{
console.log('1 executed');
admin.database().ref(institutes+'/'+ Programme +'/' + key + '/' + 'Group').once("value").then((datagroup)=>
{
if(datagroup.val() == Group)
{
console.log('2 executed');
result+=key;
}
});
}
});
agent.add(`Hello`);
Code run successfully with hello message in reply but It is not executing function written inside for loop. i.e. in console there is no messages like 1 executed or 2 executed.