Request and Response Interceptors part 3 — Enabling repeat in your skills

Tom Berwick
Alexa Skills Dev
Published in
2 min readApr 27, 2020
Photo by Sarah Dorweiler on Unsplash

So this is part three of my posts on Request and Response Interceptors. I hadn’t planned on making this a three part series, but I wanted to cover a few points I raised at the end of my last post around using ResponseInterceptors.

So as mentioned in the previous articles response interceptors run just before your reply is forward to the Alexa Skills service and sent on to the end user. This gives you a chance to do anything you want (like saving sessionAttributes persistently as we did previously).

However, one really good use case for ResponseInterceptors is for working with Amazon’s built-in RepeatIntent. It’s always a good idea to include a repeat request as, just like in real life, sometimes people don’t catch what you say the first time around. Following the principles of DRY (don’t repeat yourself), and to stop you from missing a particular intent handler, the ResponseInterceptor becomes a prime location to add this functionality.

An example of how to format your responseInterceptor and a sample RepeatIntentHandler can be seen above. Just be aware that I’m accessing the ssml property of the response in my example, but you may need to check this for your response by inspecting the type property first to see if it’s ssml or text.

You will also notice that I check to make sure the lastSpeech property is set before returning it to the user in case I need to set a default value.

I hope you find this tip useful and I’ll try and move onto a different topic now. If anyone has any ideas what they would like to see, please leave a comment below or join the Facebook group and let me know there.

thanks

--

--

Tom Berwick
Alexa Skills Dev

Mobile App, game and full stack developer. Constantly trying to learn new things and dabble in growth hacking