Skip to content

Instantly share code, notes, and snippets.

@kinisoftware
Created October 14, 2019 17:37
Show Gist options
  • Select an option

  • Save kinisoftware/882a5046a5401468bcc7f78edee02947 to your computer and use it in GitHub Desktop.

Select an option

Save kinisoftware/882a5046a5401468bcc7f78edee02947 to your computer and use it in GitHub Desktop.
UsingTranslations.kt
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