Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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