So I figured out how the fulfillment connects with a real-time Firebase database. The issue I am having is structuring the data. I have a db with say a 100 collections that contain the following info per doc...
{
brandName: "Coca cola",
prodName: "Coke Zero",
price: 1.50
}
Researching all the tutorials I have to use the following command to fulfill in dialogflow
function getFromFirebase(agent) {
return firebaseAdmin.database().ref('prodName').once("value").then((snapshot) => {
var prodName = snapshot.val();
})
}
The issue is, I want the prodName's value to match the entity in dialogflow, and then return the whole collection. Since I want the bot reply to be the price of the product. I am guessing I have to query the value first and then pull the collection, but can't find a good example of this. Any advice is greatly appreciated