【问题标题】:What does Alexa skill .getResponse() do?Alexa 技能 .getResponse() 有什么作用?
【发布时间】:2019-02-16 22:27:20
【问题描述】:

我正在学习 js 并创建简单的 Alexa 技能。 我想更好地理解模板代码,我正在研究https://ask-sdk-for-nodejs.readthedocs.io 的文档,但我找不到这个问题的答案。 .getResponse() 方法用于每个处理程序模板。它也用于 SessionEndedIntent 处理程序,这意味着它不能成为等待用户输入的方式。我试过谷歌搜索,但找不到答案。 谁能解释 .getResponse() 的作用,或指向相关文档?谢谢。

const SessionEndedRequestHandler = {
canHandle(handlerInput) {
    return handlerInput.requestEnvelope.request.type === 'SessionEndedRequest';
},
handle(handlerInput) {
    // Any cleanup logic goes here.
    return handlerInput.responseBuilder.getResponse();
}

【问题讨论】:

    标签: javascript alexa


    【解决方案1】:

    我已经指出了正确的答案,以防其他人需要这个: https://developer.amazon.com/blogs/alexa/post/f167aa0f-8abe-4602-b985-65118b3032ca/code-deep-dive-slots-and-session-attributes-in-the-ask-sdk-for-node-js

    .getResponse() 生成一个 JSON 答案以与 Alexa 通信:

    生成 JSON 响应

    最后,我们添加 getResponse() 方法以使用我们的 speechOutput 生成 JSON 响应。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-02-27
      • 1970-01-01
      • 2023-01-21
      • 2020-05-09
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多