alexa-skills-kitjovo-framework

User response is being cutoff and throwing an Unexpected Error. How to get the error message that happened


I am developing a skill using JOVO which takes notes from users and saves in a database. The workflow is working OK but when I am saying something the data is being cut off and a portion of it is getting saved in the database but the session seems to be alive still.

When I am trying to say something again, Alexa is saying Unexpected Error. This is happening for one intent only. It has one slot and the type is AMAZON.SearchQuery.

I want to know the exact error happened and take it to my email address for better understanding. How can I do this?

According to this article, I can customize the error. But I want to know the exact type of error occurred and get the full error message in my email. How can I do this?

I checked my database field length and it is good enough to store a long text. The portion being saved, is nowhere near the field length. It is much lower.

However, this is not happening when I am testing from Alexa test console. Even a 500 character long text is getting saved fine in the database from here. I am using AMAZON.SearchQuery for this slot. Does Alexa have a restriction of character length to be passed as slot value?

I am not able to locate the issue. Google could not help either!

UPDATE

Intent Code:

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 function:

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;
  }

Solution

  • after analyzing your code to find out what causes the session to stay alive, it seems that it is in the next code fraction:

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

    the line this.ask(`${output}`); you must replace it with this.tell(`${output}`);

    For more info about it you can check the next link:
    https://www.jovo.tech/docs/output