Keep your APL document and skill session running past the 30-second limit.
Alexander Martin, Jan 15, 2022 — 2 min read
With two components, you can keep your APL document and skill session running past the 30-second limit. Here's how:
First you need a video component and a video (with a minimum duration of 1 second) in your APL document that runs forever.
With repeatCount -1 we define that our document should be repeated forever.
The video must be at least 1x1px, therefore we place it with position absolute outside the visible area. It is also important to set the autoplay property on the video component to true, otherwise we would have to start the video manually in the onMount handler.
The video shown in my sample snippet has a playing time of 1 minute and can be downloaded here.
Learn more about the APL Video component
To keep our skill session alive, we play ping-pong between our APL document and our skill backend. For this we use a tick event handler and send an event to our skill backend every 15 seconds.
You can add the tick handler either to your previously created video component or directly to your APL document.
Learn more about tick event handlers
Now add an intent handler to your skill backend
We simply send an empty response to the PING request. Do not forget to register your handler.
With "withShouldEndSession(undefined)" we prevent the microphone from being opened on the device.
Learn more about the lifecycle of a skill session
Well, that's it. Have fun keeping your APL document and skill session alive! If you liked the post, leave a comment and ❤️.
Be the first to comment.