Skip to content

Instantly share code, notes, and snippets.

@frogermcs
Created November 5, 2017 14:00
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/311cba2b1675ad893bd0ef4e1b48805c to your computer and use it in GitHub Desktop.
Save frogermcs/311cba2b1675ad893bd0ef4e1b48805c to your computer and use it in GitHub Desktop.
class Conversation {
//...
//GREETING_EXISTING_USER starts with "Hey%s! ...". So you can put there a name with preceding space,
//or simply an empty String
_greetExistingUser() {
const loggedWaterPromise = this.waterLog.getLoggedWaterForUser(this._getCurrentUserId());
const userNamePromise = this.userManager.loadAssistantUser(this._getCurrentUserId());
return Promise.all([loggedWaterPromise, userNamePromise])
.then(values => {
const loggedWater = values[0];
const userGivenName = values[1].givenName;
let formattedName = '';
if (userGivenName) {
formattedName = ' ' + userGivenName;
}
this.dialogflowApp.ask(
util.format(Str.GREETING_EXISTING_USER, formattedName, loggedWater),
Str.GREETING_EXISTING_USER_NO_INPUT_PROMPT
);
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment