【问题标题】:Alexa skill problem with response after response is already returned已返回响应后响应的 Alexa 技能问题
【发布时间】:2018-12-04 21:36:20
【问题描述】:

我正在开发一项 Alexa 技能,该技能需要用户必须连续回答多个问题的多步骤对话。我正在尝试通过检查插槽是否已确认并返回addElicitSlotDirective 的响应来添加单个插槽提示,如果不是:

这是整个请求处理程序:

const isIntentRequest = require('../utils/isIntentRequest');
const sound = require('../utils/sound');
const loadUser = require('../utils/loadUser');
const loadWordByIndex = require('../utils/loadWordByIndex');

module.exports = {
  canHandle(handlerInput) {
    return isIntentRequest(handlerInput, 'NewWordPathIntent');
  },

  async handle(handlerInput) {
    const user = await loadUser(handlerInput);
    const { wordIndex } = user;
    const word = await loadWordByIndex(wordIndex);
    const slots = handlerInput.requestEnvelope.request.intent.slots;

    if(!hasAnswered('NewWordEnglishAnswer')) {
      return handlerInput.responseBuilder
        .speak('New Word English Answer word ' + word)
        .reprompt('New Word English Answer word ' + word + ' reprompt')
        .addElicitSlotDirective('NewWordEnglishAnswer')
        .getResponse();
    }

    return handlerInput.responseBuilder
      .speak('You answered the new word english question')
      .getResponse();

    function hasAnswered(slotName) {
      const slot = slots[slotName];
      if(!slot) throw new Error(`Invalid answer slot: "${slotName}"`);
      return slot.confirmationStatus === 'CONFIRMED';
    }
  },
};

这似乎主要是有效的。处理此意图后,Alexa 会回复:New Word English Answer word evidence,这是正确的,但随后她会立即使用 There was a problem with the requested skill's response 跟进并终止会话。

为什么会这样?如果正在输出响应,那么响应有什么问题?

【问题讨论】:

    标签: javascript node.js alexa-skills-kit alexa-skill


    【解决方案1】:

    使用 console.log 将内容写入日志并配置您的技能以使用 Amazon 的 CloudWatch Logs 查看日志。即使没有您自己向 console.log 编写语句,也会有关于“请求技能响应的问题”的信息。 即使没有,如果您使用 Alexa 开发人员控制台测试选项卡来测试您的技能,您通常也可以获得有关问题的信息。它可能会在 JSON 输入或 JSON 输出中向您显示一些可以为您提供线索的内容。

    【讨论】:

      猜你喜欢
      • 2020-07-23
      • 2019-03-15
      • 1970-01-01
      • 2019-01-23
      • 2019-11-12
      • 1970-01-01
      • 1970-01-01
      • 2020-11-15
      • 1970-01-01
      相关资源
      最近更新 更多