alexa / alexa-skills-kit-sdk-for-nodejs

The Alexa Skills Kit SDK for Node.js helps you get a skill up and running quickly, letting you focus on skill logic instead of boilerplate code.
Apache License 2.0
3.12k stars 736 forks source link

Return responseBuilder speak with german "Umlaute" ("ä", "ö", "ü", ...) #675

Closed mbecker closed 3 years ago

mbecker commented 3 years ago

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[x] Bug report
[ ] Performance issue
[ ] Feature request
[ ] Documentation issue or request
[ ] Other... Please describe:

Expected Behavior

The following response with a german "Umlaut" ("ä") should be returned and processed by Alexa succesfully:

const doesWork = 'Woche 1 Freitag. Plan ist 45 Minuten Rad fahren. Nach dem Aufwaermen 3x EB mit je 4 Minuten EB und 4 Minuten G1.';
const doesNotWork = 'Woche 1 Freitag. Plan ist 45 Minuten Rad fahren. Nach dem Aufwärmen 3x EB mit je 4 Minuten EB und 4 Minuten G1.';

return handlerInput.responseBuilder
      .speak(`${doesNotWork}`)
      .withSimpleCard(i18n.t(Strings.SKILL_NAME), speechText)
      .withShouldEndSession(true)
      .getResponse()

Current Behavior

The parameter "doesWork" works as expected. But the parameter "doesNotWork" with it's value results in an error handling on Alexa (device).

Possible Solution

Maybe I missed some settings for locale?

Steps to Reproduce (for bugs)

Use the provided code above.

Context

Ask for text. Repond with a german text with german "Umlaute" like "ä", "ö", "ü" and so on.

Your Environment

"dependencies": {
    "@types/lodash": "^4.14.168",
    "ask-sdk-core": "^2.10.1",
    "ask-sdk-model": "^1.34.1",
    "aws-sdk": "^2.834.0",
    "axios": "^0.21.1",
    "i18next": "^15.0.5",
    "i18next-sprintf-postprocessor": "^0.2.2",
    "lodash": "^4.17.20"
  },
  "devDependencies": {
    "@types/node": "^10.10.0",
    "@types/i18next-sprintf-postprocessor": "^0.2.0",
    "typescript": "^3.0.2",
    "cpy-cli": "^3.1.0",
    "rimraf": "^3.0.0",
    "ts-node": "^7.0.1",
    "gts": "^1.1.2"
  }

Node.js and NPM Info

node v12.18.3 npm 6.14.6

Any help or tipp is highly welcome! Thanks guys.

ShenChen93 commented 3 years ago

Hi @mbecker ,

I tried to reproduce this issue by using the HelloWold template skill and using the following code in my helloWorld IntentHandler

const HelloWorldIntentHandler = {
    canHandle(handlerInput) {
        return Alexa.getRequestType(handlerInput.requestEnvelope) === 'IntentRequest'
            && Alexa.getIntentName(handlerInput.requestEnvelope) === 'HelloWorldIntent';
    },
    handle(handlerInput) {
        const doesNotWork = 'Woche 1 Freitag. Plan ist 45 Minuten Rad fahren. Nach dem Aufwärmen 3x EB mit je 4 Minuten EB und 4 Minuten G1.';

        return handlerInput.responseBuilder
            .speak(`${doesNotWork}`)
            //.reprompt('add a reprompt if you want to keep the session open for the user to respond')
            .getResponse();
    }
};

However, the skill works as expected when I tested it on simulator. image

Thus I wonder if the root cause is something else. If the error handling IntentHandler was triggered, could you please log the error in errorHandling IntentHandler and check the error on cloudWatch ?

Thanks, Shen

mbecker commented 3 years ago

Hi Shen,

thank you very much for trying this on your own! Highly appreciate that!

For me, no "error handling IntentHandler" is triggered. But immediately after the original IntentHandler is triggered the "Request Type SessionEndedRequest" is called with an "error type INVALID_RESPONSE".

The original from Alexa is as follows

{
  "requestEnvelope": {
    "version": "1.0",
    "session": {
      "deleted": "..."
    },
    "context": {
      "deleted": "..."
    },
    "request": {
      "type": "IntentRequest",
      "requestId": "amzn1.echo-api.request.b0225bc1-a39d-4b6c-acd5-9c9a960ef15f",
      "locale": "de-DE",
      "timestamp": "2021-02-01T22:30:04Z",
      "intent": {
        "name": "TrainingIntent",
        "confirmationStatus": "NONE",
        "slots": {
          "date": {
            "name": "date",
            "value": "2021-02-02",
            "confirmationStatus": "NONE",
            "source": "USER",
            "slotValue": {
              "type": "Simple",
              "value": "2021-02-02"
            }
          }
        }
      },
      "dialogState": "STARTED"
    }
  },
  "context": null,
  "attributesManager": {},
  "responseBuilder": {}
}

My skill is responding with

{
  "version": "1.0",
  "response": {
    "outputSpeech": {
      "type": "SSML",
      "ssml": "<speak>Äußerlich 60 Minuten Rad mit Doppelintervallen. erst 3 mal 3 Minuten EB mit 3 Minuten G1 Pause. Dann 10 Minuten G1. Dann 2 mal 5 Minuten G2 mit 4 Minuten G1 Pause. Den Rest im G1 rollen.</speak>"
    },
    "card": {
      "type": "Simple",
      "title": "Woche 2 Dienstag",
      "content": "Äußerlich 60 Minuten Rad mit Doppelintervallen. erst 3 mal 3 Minuten EB mit 3 Minuten G1 Pause. Dann 10 Minuten G1. Dann 2 mal 5 Minuten G2 mit 4 Minuten G1 Pause. Den Rest im G1 rollen."
    },
    "shouldEndSession": true
  },
  "userAgent": "ask-node/2.10.1 Node/v12.18.3",
  "sessionAttributes": {

  }
}

Immediately after the service is responding with the JSON above the following request is sent to the skill

{
  "requestEnvelope": {
    "version": "1.0",
    "session": {
      "deleted": "..."
    },
    "context": {
      "deleted": "..."
    },
    "request": {
      "type": "SessionEndedRequest",
      "requestId": "amzn1.echo-api.request.064af447-b31b-4e6e-a23e-5b24439c20a1",
      "timestamp": "2021-02-01T22:30:04Z",
      "locale": "de-DE",
      "reason": "ERROR",
      "error": {
        "type": "INVALID_RESPONSE",
        "message": "An exception occurred while dispatching the request to the skill."
      }
    }
  },
  "context": null,
  "attributesManager": {},
  "responseBuilder": {}
}

A successful request / response for the same IntentHandler without german umlaute is as follows

{
  "requestEnvelope": {
    "version": "1.0",
    "session": {
      "deleted": "..."
    },
    "context": {
      "deleted": "..."
    },
    "request": {
      "type": "IntentRequest",
      "requestId": "amzn1.echo-api.request.6e155ffe-23db-4af9-8918-6d4b95fa449b",
      "locale": "de-DE",
      "timestamp": "2021-02-01T22:39:21Z",
      "intent": {
        "name": "TrainingIntent",
        "confirmationStatus": "NONE",
        "slots": {
          "date": {
            "name": "date",
            "value": "2021-02-03",
            "confirmationStatus": "NONE",
            "source": "USER",
            "slotValue": {
              "type": "Simple",
              "value": "2021-02-03"
            }
          }
        }
      },
      "dialogState": "STARTED"
    }
  },
  "context": null,
  "attributesManager": {},
  "responseBuilder": {}
}
{
  "version": "1.0",
  "response": {
    "outputSpeech": {
      "type": "SSML",
      "ssml": "<speak>60 Minuten Laufen mit Doppelintervallen. Erst 3 mal 3 Minuten Tempodauerlauf mit 3 Minuten lockerer Pause. Dann 6 Minuten locker. Dann 2 mal 5 Minuten Dauerlauf intensiv mit 4 Minuten Pause. Den Rest locker.</speak>"
    },
    "card": {
      "type": "Simple",
      "title": "Woche 2 Mittwoch",
      "content": "60 Minuten Laufen mit Doppelintervallen. Erst 3 mal 3 Minuten Tempodauerlauf mit 3 Minuten lockerer Pause. Dann 6 Minuten locker. Dann 2 mal 5 Minuten Dauerlauf intensiv mit 4 Minuten Pause. Den Rest locker."
    },
    "shouldEndSession": true
  },
  "userAgent": "ask-node/2.10.1 Node/v12.18.3",
  "sessionAttributes": {

  }
}

I do have a "addRequestInterceptors" for translation. I'm looking into that later.

Thanks for your help and cheers.

ShenChen93 commented 3 years ago

Hi @mbecker

Thanks for providing the Original request / response. The skill response for unhappy case looks good to me. Probably I would need to reach out to runtime team to figure out why it's failed to dispatch the request to your skill. Thus could you please provide me with your skill ID and the time window when you met this issue ?

Thanks, Shen

mbecker commented 3 years ago

Hi Shen,

wow! Sure, the Alexa Skill ID is as follows: amzn1.ask.skill.a38f7e8e-c32a-48f6-ba34-1ab374bbe9ff

The datetime for the original request is as follows: 2021-02-01T22:57:23.000Z The datetime for the "error" request immediately after responding is as follows: 2021-02-01T22:57:24.000Z

I hope that helps. Thanks again!

mbecker commented 3 years ago

Hi Shen,

the Alexa Skill was self-hosted. That's why maybe that problem exists. With an AWS Lamdba hosted Alexa Skill the problem doesn't occur.

So, I would say it's more or less fixed because it was never an issue with an AWS Lambda hosted Alexa Skill.

But thanks for your looking into this!