Skip to content

Instantly share code, notes, and snippets.

@kinisoftware
Last active April 11, 2021 16:37
Show Gist options
  • Save kinisoftware/a8123c0c9591aaa769414350e7cba5bb to your computer and use it in GitHub Desktop.
Save kinisoftware/a8123c0c9591aaa769414350e7cba5bb to your computer and use it in GitHub Desktop.
class NextIntentHandler : RequestHandler {
override fun canHandle(input: HandlerInput) = input.matches(intentName("AMAZON.NextIntent"))
override fun handle(input: HandlerInput) =
input.attributesManager.persistentAttributes["lastPlayedAudio"]?.let {
PlayAudioResponseBuilder.buildNewsResponse(
input,
Audio(it.toAudio().getNextDate())
)
} ?: input.responseBuilder.build()
}
class PreviousIntentHandler : RequestHandler {
override fun canHandle(input: HandlerInput) = input.matches(intentName("AMAZON.PreviousIntent"))
override fun handle(input: HandlerInput) =
input.attributesManager.persistentAttributes["lastPlayedAudio"]?.let {
PlayAudioResponseBuilder.buildNewsResponse(
input,
Audio(it.toAudio().getPreviousDate())
)
} ?: input.responseBuilder.build()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment