Created
November 5, 2017 14:00
-
-
Save frogermcs/311cba2b1675ad893bd0ef4e1b48805c 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
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