I am creating an agent which can read a list of data from a database (Real Time Database on Firebase). With context and parameters, I can trigger the webhook and get the data I want.
But because the result is a List, output text will be too long to speak all data out in one time, so I want to return one child from the list each time and ask the user "Do you want to read the next section?". If the user says "Yes", I will continue reading likewise until the end. And if the user says "No", I will trigger an event.
For looping I am using this:
ref.once('value', function(snapshot) {
snapshot.forEach(function(childSnapshot) {
var childKey = childSnapshot.key;
var childData = childSnapshot.val();
// ...
});
});
(https://firebase.google.com/docs/database/web/lists-of-data#listen_for_value_events)
But this gives all data from the list at one. How do I output one data and ask the user for permission, and then continue with next data in the list? My query is how do I ask for the permission through Dialogflow-fulfillment in between of reading the list and then continue with the list according to the response given by the user? Please write for any clarifications.