Created
April 11, 2021 16:25
-
-
Save kinisoftware/ee17e2735c098a751079477e1cfb8271 to your computer and use it in GitHub Desktop.
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
class StartOverIntentHandler : RequestHandler { | |
override fun canHandle(input: HandlerInput) = | |
input.matches(Predicates.intentName("AMAZON.StartOverIntent")) | |
override fun handle(input: HandlerInput): Optional<Response> { | |
return input.attributesManager.persistentAttributes["lastPlayedAudio"]?.let { | |
input.playAudio(it.toAudio().url) | |
} ?: input.emptyResponse() | |
} | |
private fun HandlerInput.playAudio(audioUrl: String) = responseBuilder | |
.addAudioPlayerPlayDirective( | |
PlayBehavior.REPLACE_ALL, | |
0L, | |
null, | |
"token", | |
audioUrl | |
) | |
.build() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment