Alexa Skill: is it possible to pause and resume the skill programmatically?

lolofoobar

I'm developing an Alexa skill that supports exercise training. While people are doing exercise, Alexa plays a background audio.

I'm wondering if it is possible to pause training and resume later. For example, suppose the training last for 60 seconds. When the user says "pause training" in 30 seconds, Alexa will stop playing the audio to wait for the next command. Later when the user says "resume training", Alexa will resume the audio starting from the 30 seconds where it paused. And if the waiting time is too long, say 60 seconds, Alexa will timeout. Currently, I'm simply using this.response.speak(audioName) to play audio.

I was searching through the developer document but couldn't find any relevant solutions. Is it possible at all? Thanks in advance!

bal simpson

Alexa Skills cannot be paused as such, but you can achieve a similar result by saving the skill session details to a database like firebase or dynamoDB. The data is saved as soon as you say Alexa, ask to pause training. So next time you say Alexa, ask to resume training, the skill fetches the saved details and starts off from there.

Few things to consider:

  1. Your skill is active only when the session is open. Which is about 8 seconds between each interaction. You can use a short audio clip, up to 90 seconds in your responses to keep the skill alive longer.

  2. You can use an AudioPlayer directive to play a 10 second music/silent track and loop it over. So the skill starts and it's your first exercise which is two minutes long. The audio plays in a loop for two minutes and after that you skill plays a notification sound. This has the added advantage of using native commands like Resume and Pause without using the skill name.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related