Skip to content

Instantly share code, notes, and snippets.

@frogermcs
Created October 26, 2017 19:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save frogermcs/04817595eef92e876bc963b7c69e10d5 to your computer and use it in GitHub Desktop.
Save frogermcs/04817595eef92e876bc963b7c69e10d5 to your computer and use it in GitHub Desktop.
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