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

Skill crashes when german characters are used in speak function during local debugging #661

Closed Betatester777 closed 3 years ago

Betatester777 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

lambda has the same behavior in alexa cloud as well as in local environment

Current Behavior

lambda works fine alexa hosted, but crashes when it is being executed locally

Possible Solution

Steps to Reproduce (for bugs)

const LaunchRequestHandler = { canHandle(handlerInput) { return Alexa.getRequestType(handlerInput.requestEnvelope) === 'LaunchRequest'; }, handle(handlerInput) { return handlerInput.responseBuilder .speak("ÄÖÜäöüß") .getResponse(); } };

Context

Same code works perfect in alexa hosted environment. If I try to run it locally, it works fine until speak, repromt or withSimpleCard params contain german characters e.g. ä ö ü

Your Environment

Node.js and NPM Info

Console output

`


    at Object.handle (index.js:575:14)
    at GenericHandlerAdapter.execute (lambda/node_modules/ask-sdk-runtime/dist/dispatcher/request/handler/GenericHandlerAdapter.js:25:24)
    at GenericRequestDispatcher.dispatchRequest (lambda/node_modules/ask-sdk-runtime/dist/dispatcher/GenericRequestDispatcher.js:95:38)
    at processTicksAndRejections (internal/process/task_queues.js:86:5)
`
ShenChen93 commented 3 years ago

Hi @Betatester777 ,

Thanks for using our SDK and the new local debug feature. I tried to reproduce this issue by using the hello world sample skill and replace the utterance in helloWorldHandler. And I can successfully get the expected response.

image

Is there any more detailed error message been printed ? Seems the error is thrown from the ask-sdk-runtime pkg, which is a dependency of ask-sdk-core. The latest version of ask-sdk-core is 2.10.1, and I don't think there's a version 2.326. Could you please try upgrade the ask-sdk-core dependency in your skill and see if error still exist ?

Thanks, Shen

Betatester777 commented 3 years ago

Hello Shen, thank you very much for quick help ;-) You are right. I'm using asp.sdk.core v 2.10.1. Your example is structured differently. You test uses alexa simulation in VS code and ask-sdk-local-debug module that works for me even with German characters fine too. But there is no speech output, just text prints and keyboard input.

I'm using ngrok and I have changed the endpoint in the web console to the ngrok url as explained in this tutorial: https://developer.amazon.com/en-US/blogs/alexa/alexa-skills-kit/2019/08/setup-your-local-environment-for-debugging-an-alexa-skill

This has the advantage that I also have speech output via microphones, loudspeakers and it works, if no German characters are used.

I have attached a Helloworld project with appropriate configuration.

Nice greetings,

Ingo helloworld.tar.gz

Betatester777 commented 3 years ago

Hello Shen, by the way, the documentation for ask-sdk-local-debug has a small issue: node ./node_modules/ask-sdk-local-debug/dist/LocalDebuggerInvoker.js --accessToken --skillID --skillEntryFile --handlerName Param skillID should be skillId

Greetings, Ingo

ShenChen93 commented 3 years ago

Hi @Betatester777 ,

Thanks for detailed explanation. Yeah, the extension way of simulation doesn't support audio output cause vscode doesn't provide those features so far. Sorry for the inconvenient.

The tutorial you pasted above is the temp solution we provide before we shipped the ask-sdk-local-debug module. With the ask-sdk-local-debug module, you won't need ngrok to redirect alexa request anymore, and it also support invoking skill through developer console as mentioned here: https://developer.amazon.com/en-US/docs/alexa/ask-toolkit/vs-code-testing-simulator.html#test. After you finished the previous three steps, you could go to developer console and do the regular test.

Could you please try and see if it works for you.

Thanks, Shen

ShenChen93 commented 3 years ago

Also thanks for pointing out the spelling issue, just fixed it :)

Betatester777 commented 3 years ago

Hi Shen, have already tried everything. Both: local and web simulator are using alexa hosted lambda and debugger doesn't stop at breakpoints. I worked exactly as described in the manual and created access tokens as described too.

Here is the console output:

` /home/vorwerk/.nvm/versions/node/v11.13.0/bin/node ./lambda/node_modules/ask-sdk-local-debug/dist/LocalDebuggerInvoker.js --accessToken mygeneratedaccestoken --skillId amzn1.ask.skill.6161cf8f-19f9-4b38-bd38-3e81227f4767 --handlerName handler --skillEntryFile /home/vorwerk/workspace/skill/helloworld/lambda/index.js Starting Skill Debug Session in NA region

lambda/node_modules/ask-sdk-local-debug/lib/client/LocalDebugClient.ts:55 NOTE: Skill debugging is currently only available for invocations from customer in North America region (https://developer.amazon.com/en-US/docs/alexa/custom-skills/develop-skills-in-multiple-languages.html#h2-multiple-endpoints)

lambda/node_modules/ask-sdk-local-debug/lib/client/LocalDebugClient.ts:56 Session will last for 1 hour ` Hint!: I've deleted the token in the output for security reasons.

And my project:

helloworld_local_debug.tar.gz

And JSON input:

{ "version": "1.0", "session": { "new": true, "sessionId": "amzn1.echo-api.session.138f6fef-1c7b-4069-b9d0-db00b8066226", "application": { "applicationId": "amzn1.ask.skill.6161cf8f-19f9-4b38-bd38-3e81227f4767" }, "user": { "userId": "amzn1.ask.account.some user id" } }, "context": { "Extensions": { "available": { "aplext:backstack:10": {} } }, "System": { "application": { "applicationId": "amzn1.ask.skill.6161cf8f-19f9-4b38-bd38-3e81227f4767" }, "user": { "userId": "amzn1.ask.account.some user id" }, "device": { "deviceId": "amzn1.ask.device.some removed id", "supportedInterfaces": {} }, "apiEndpoint": "https://api.eu.amazonalexa.com", "apiAccessToken": "some removed token" } }, "request": { "type": "LaunchRequest", "requestId": "amzn1.echo-api.request.cfe0ec1e-0f5c-44bc-97ab-f589fdf5a63c", "timestamp": "2020-10-23T08:27:46Z", "locale": "de-DE", "shouldLinkResultBeReturned": false } } Greetings

ShenChen93 commented 3 years ago

Hi @Betatester777 ,

Thanks for providing the json input. Sorry, I just realized that you are using the EU endpiont, as "apiEndpoint": "https://api.eu.amazonalexa.com". However, as noted in the console output, local debug feature currently only available for invocations from customer in North America region. The EU and other region are not supported for now.

Sorry for the inconvenience. We are working on other region support right now and will try to ship it ASAP. We provide some workaround for skills in other regions: https://github.com/alexa/ask-toolkit-for-vscode/wiki/Setting-Up-Local-Debugging-in-Other-Regions. Could you please try and see if it works for you ?

Thanks, Shen

Betatester777 commented 3 years ago

Hi Shen, It works perfectly. Via web console as well as via local simulator and with German characters as well. Thank you very much for your help and support. Hopefully the debugging functionality will soon be available for EU accounts as well. But for now I'm making good progress thanks to your information and I'm happy.

One last question (Sorry, I have not yet managed to try it out) do i have to configure anything special for debugging to be able to use the alexa hosted s3 persistence?

Greetings, Ingo

ShenChen93 commented 3 years ago

Hi @Betatester777 ,

Sorry for responding late. For your last question, unfortunately the local skill have no access permission to Alexa hosted S3 bucket. There's a workaround I can think up to achieve it: 1. Configure alexa hosted skill to use your personal AWS resources. 2. Get the aws credential and config your local skill to access the s3 bucket.

Since Local debug is supposed to serve a local sandbox testing usecase, I don't think it's good to give local skill access to production data. Ideally, I think the best solution is to let our SDK to create mock s3 bucket at your local. But so far we haven't supported it yet.

Thanks, Shen

Betatester777 commented 3 years ago

Hello Shen, Thank you very much for your answer ;-) I also have an AWS account. So I will try to follow the tutorial above. Another option I thought about was to use https://github.com/localstack/localstack for local debugging. Regards, Ingo

sattpat commented 3 years ago

Hi Shen, It works perfectly. Via web console as well as via local simulator and with German characters as well. Thank you very much for your help and support. Hopefully the debugging functionality will soon be available for EU accounts as well. But for now I'm making good progress thanks to your information and I'm happy.

One last question (Sorry, I have not yet managed to try it out) do i have to configure anything special for debugging to be able to use the alexa hosted s3 persistence?

Greetings, Ingo

Local debugging is now available for EU regions as well. Follow the instructions here to configure your region input and get started