question

Lius avatar image
Lius asked

what to respond in skill's lambda when directive Response will be pushed asynchronously?

The docs say: "You can send response events synchronously from your skill's Lambda function or asynchronously to the event gateway."


What the docs don't say is what to return from the skill's lambda function in case a directive response will be sent asynchronously. Deferred Responses seem to be the right choice only for certain controllers that take more than 7 seconds to complete.


So my question is what my skill's lambda function should return upon receiving a directive that will be responded to asynchronously just moments later.


I tried to immediately return true, null or undefined, which leads Alexa to say that the device is currently not reacting. When I delay the return value of the skill's lambda by 10 seconds though, Alexa plays the acknowledge sound as soon as the async response arrives (<2 sec) . That is the behaviour I am after, but without having to keep the lambda open for x seconds.


alexa skills kitskilllambdaresponsesmart home
10 |5000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

Jason@Amazon avatar image
Jason@Amazon answered

You should be okay to send the DeferredResponse in response to the directive in your case - we're working on updating the documentation but you should be good to use the DeferredResponse as the synchronous response.

10 |5000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.