英文:
Alexa Skill needs more than 8s for a Lambda to complete
问题
我正在使用Alexa的Python库编写一个Lambda函数,该函数调用了一些API。有时,这需要超过8秒的时间。这就是当Alexa设置为超时时的情况。
虽然我在API中找到了一个规范来帮助处理这个问题,但我还没有找到任何特定适用于为此编写的Python库的代码示例。我在哪里可以找到这样的代码示例来延迟响应?
英文:
I'm using Alexa's Python libraries to write a Lambda that hits a couple of APIs. Sometimes, this takes more than 8s. That's when Alexa is set to timeout.
class CustomIntentHandler(AbstractRequestHandler):
def can_handle(self, handler_input):
# type: (HandlerInput) -> bool
return ask_utils.is_intent_name("CustomIntentHandler")(handler_input)
def handle(self, handler_input):
f = open('secrets.json')
secrets = json.load(f)
f.close
# bulk of the code omitted (it works, it just takes too long sometimes)
return (
handler_input.response_builder
.speak(speak_output)
.response
)
While I have found a specification in the API to help with this matter by deferring the response, I haven't been able to find any code samples that apply specifically to the Python libraries written for this. Where can I find such code samples to defer the response?
答案1
得分: 1
渐进式响应是在需要准备完整响应用户请求时保持用户参与的良好选择。
如果您对此选项感兴趣,请在以下链接找到更多信息:https://developer.amazon.com/en-US/docs/alexa/custom-skills/send-the-user-a-progressive-response.html
这是一个很好的示例:
https://github.com/alexa-samples/progressive-response-demo
英文:
Progressive responses are a good option in this case where you need to keep the user engaged while your skill prepares a full response to the user's request.
If you are interest in this option, please find more information on this link https://developer.amazon.com/en-US/docs/alexa/custom-skills/send-the-user-a-progressive-response.html
This is a good example:
https://github.com/alexa-samples/progressive-response-demo
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论