Created
October 14, 2019 17:37
-
-
Save kinisoftware/882a5046a5401468bcc7f78edee02947 to your computer and use it in GitHub Desktop.
UsingTranslations.kt
This file contains hidden or 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
| override fun handle(input: HandlerInput): Optional<Response> { | |
| val request = input.requestEnvelope.request | |
| val intentRequest = request as IntentRequest | |
| val intent = intentRequest.intent | |
| val slots = intent.slots | |
| val releasesDate = slots["releasesDate"]!! | |
| val dateValue = releasesDate.value | |
| DirectiveServiceHandler(input).onRequestingUpcomings(input.getLanguage()) | |
| val movies = moviesGetter.getUpcomings(intentRequest.locale, dateValue) | |
| return if (movies.isBlank()) { | |
| val text = Translations.getMessage(input.getLanguage(), Translations.TranslationKey.UPCOMINGS_NOT_FOUND) | |
| val reprompt = Translations.getMessage(input.getLanguage(), Translations.TranslationKey.ASKING_FOR_NOW_PLAYING) | |
| input.responseBuilder | |
| .withSpeech(text + reprompt) | |
| .withReprompt(reprompt) | |
| .build() | |
| } else { | |
| val text = "${Translations.getMessage(input.getLanguage(), Translations.TranslationKey.UPCOMINGS_RESPONSE)}: $movies" | |
| input.responseBuilder | |
| .withSpeech(text) | |
| .withShouldEndSession(true) | |
| .build() | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment