0

我正在开发一种技能,使用JOVO它记录用户的笔记并保存在数据库中。工作流程工作正常,但是当我说一些数据时,数据被切断,其中一部分被保存在数据库中,但会话似乎仍然存在。

当我想再说些什么时,Alexa 说的是Unexpected Error。这只发生在一个意图上。它有一个插槽,类型是AMAZON.SearchQuery

我想知道发生的确切错误并将其发送到我的电子邮件地址以便更好地理解。我怎样才能做到这一点?

根据这篇文章,我可以自定义错误。但我想知道发生的错误的确切类型并在我的电子邮件中获取完整的错误消息。我怎样才能做到这一点?

我检查了我的数据库字段长度,它足以存储长文本。被保存的部分远不及字段长度。它要低得多。

但是,当我从 Alexa 测试控制台进行测试时,这并没有发生。即使是 500 个字符长的文本也可以从这里很好地保存在数据库中。我正在使用AMAZON.SearchQuery这个插槽。Alexa 是否对作为槽值传递的字符长度有限制?

我无法找到问题所在。谷歌也无能为力!

更新

意图代码:

async NotesBuilderIntent() {
    if (this.$inputs.note.value === undefined) {
      this.ask("what do you want me to know?");
    } else {
      if (this.$session.$data.agent_code === undefined) {
        /**
         * This client has landed directly on the intent
         * let's retrieve his info based in Amazon access token
         * and create required session values.
         */
        if (!this.$request.getAccessToken()) {
          return this.tell(
            "Oops! Looks like you have either disabled or not enabled the skill yet. Please link your account by going to the Alexa app or companion app to proceed. thank you!"
          );
        } else {
          const token = this.$request.getAccessToken();
          //Retrieve user data using access_token.
          const profile = await custom.getUserAmazonProfile(token);
          // Extract email and amazon profile_id
          const profile_id = profile.user_id;
          const profile_email = profile.email;
          const profile_name = profile.name;
          const objUser = await custom.validate_account(
            profile_id,
            profile_email
          );
          const status_code = parseInt(objUser.status_code);
          if (status_code === 100) {
            this.$session.$data.agent_code = objUser.client.agent_code;
            this.$session.$data.account_code = objUser.client.account_code;
          } else {
            const user = await custom.skillTestMode(
              profile_email,
              profile_name
            );
            const mode_current = user.current_mode;
            if (mode_current === "D") {
              this.$session.$data.agent_code = user.client.agent_code;
              this.$session.$data.account_code = user.client.account_code;
            } else {
              return this.tell(
                "sorry! looks like you are not authorized to use this skill. please contact your account manager."
              );
            }
          }
        }
      }
      /**
       * We already have the client info based on
       * access token and built required session values
       * to proceed.
       */
      const agent_note = this.$inputs.note.value;
      const agent_code = this.$session.$data.agent_code;
      const account_code = this.$session.$data.account_code;
      if (
        agent_note === "stop" ||
        agent_note === "cancel" ||
        agent_note === "later" ||
        agent_note === "maybe later" ||
        agent_note === "not now" ||
        agent_note === "nothing" ||
        agent_note === "no"
      ) {
        return this.toIntent("StopIntent");
      } else {
        const result = await custom.saveAgentNote(
          agent_code,
          account_code,
          agent_note
        );
        const output = result.speech;
        this.ask(`${output}`);
      }
    }
  }

saveAgentNote 功能:

saveAgentNote: async (agent_code, account_code, agent_note) => {
    let data = {};
    await rp({
      url: baseURI,
      headers: { "Content-Type": "application/json" },
      qs: {
        action: actions.addNote,
        code: agent_code,
        account_code: account_code,
        note: agent_note
      },
      method: "POST"
    })
      .then(body => {
        data = JSON.parse(body);
      })
      .catch(error => {
        console.log(error);
      });

    return data;
  }
4

1 回答 1

1

在分析您的代码以找出导致会话保持活动状态的原因之后,它似乎在下一个代码部分中:

const result = await custom.saveAgentNote(
          agent_code,
          account_code,
          agent_note
        );
        const output = result.speech;
        this.ask(`${output}`);

this.ask(`${output}`);您必须将其替换为的行this.tell(`${output}`);

有关它的更多信息,您可以查看下一个链接:
https ://www.jovo.tech/docs/output

于 2020-10-12T23:52:59.783 回答