Last active
March 10, 2017 13:48
-
-
Save ajcrites/323dc219b588ca7f76c24afe95d03078 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
app.launch(function(request, response) { [8/89] | |
const accessTokenReceived = request.sessionDetails.accessToken; | |
if (accessTokenReceived === undefined) { | |
throw "no_access_token"; | |
} | |
return user.getUserFromAccessTokenPromise(accessTokenReceived) | |
.then(user => stuff.getStuffFromUserPromise(user).then(() => user.id)) | |
.then(userId => helper.getStaffUserIdPromise(userId)) | |
.then(() => { | |
if (numberOfStaff !== 0) { | |
return response.say(config.dialog.onLaunchIntent.case13.say) | |
.reprompt(config.dialog.onLaunchIntent.case13.reprompt) | |
.card(config.dialog.onLaunchIntent.case13.cardTitle, config.dialog.onLaunchIntent.case12.card) | |
.shouldEndSession(config.dialog.onLaunchIntent.case13.end); | |
} | |
throw "no_staff"; | |
}); | |
}); | |
app.error = (err, request, response) => { | |
err = Object.assign({message: null}, err); | |
switch (err.message) { | |
case "no_access_token": | |
response.say(config.dialog.onLaunchIntent.case10.say) | |
.reprompt(config.dialog.onLaunchIntent.case10.reprompt) | |
.linkAccount() | |
.shouldEndSession(config.dialog.onLaunchIntent.end); | |
break; | |
case "not_good_access_token": | |
response.say(config.dialog.onLaunchIntent.case10.say) | |
.reprompt(config.dialog.onLaunchIntent.case10.reprompt) | |
.linkAccount() | |
.shouldEndSession(config.dialog.onLaunchIntent.case10.end); | |
break; | |
case "no_stuff": | |
response.say(config.dialog.onLaunchIntent.case11.say) | |
.reprompt(config.dialog.onLaunchIntent.case11.reprompt) | |
.card(config.dialog.onLaunchIntent.case11.cardTitle, config.dialog.onLaunchIntent.case11.card) | |
.shouldEndSession(config.dialog.onLaunchIntent.case11.end); | |
break; | |
case "no_staff": | |
response.say(config.dialog.onLaunchIntent.case12.say) | |
.reprompt(config.dialog.onLaunchIntent.case12.reprompt) | |
.card(config.dialog.onLaunchIntent.case12.cardTitle, config.dialog.onLaunchIntent.case12.card) | |
.shouldEndSession(config.dialog.onLaunchIntent.case12.end); | |
break; | |
default: | |
response.say(config.dialog.onLaunchIntent.case6.say) | |
.reprompt(config.dialog.onLaunchIntent.case6.reprompt) | |
.card(config.dialog.onLaunchIntent.case6.cardTitle, config.dialog.onLaunchIntent.case6.card) | |
.shouldEndSession(config.dialog.onLaunchIntent.case6.end); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment