Created
October 26, 2017 19:19
-
-
Save frogermcs/04817595eef92e876bc963b7c69e10d5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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