Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
const ARG_WATER_VOLUME = 'water_volume';
//...
class Conversation {
//...
actionLogWater() {
//Get argument extracted by Dialogflow
let waterToLog = this.dialogflowApp.getArgument(ARG_WATER_VOLUME);
//Save logged water into Firebase Realtime Database
this.waterLog.saveLoggedWater(this._getCurrentUserId(), waterToLog);
//Load sum of logged water for current user and reply user
//with how much water he or she logged so far.
//End the conversation.
return this.waterLog.getLoggedWaterForUser(this._getCurrentUserId())
.then(loggedWater => {
this.dialogflowApp.tell(
util.format(Str.WATER_LOGGED_NOW,
waterToLog.amount,
waterToLog.unit,
loggedWater
)
);
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment