Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using non-alphanumerics in app name causes opaque errors #2

Open
goodmike opened this issue Dec 30, 2016 · 2 comments · May be fixed by #3
Open

Using non-alphanumerics in app name causes opaque errors #2

goodmike opened this issue Dec 30, 2016 · 2 comments · May be fixed by #3

Comments

@goodmike
Copy link

Hello, I'm working through your excellent book-in-progress, Building Voice-Enabled Apps with Alexa, and I encountered a strange error when working through the 'dragonhunt' skill in Chapter 2. When I went to run it with node index, I got this unhelpful error back in the terminal window:

/node_modules/chatskills/lib/chatskills.js:24
        this.sessions[this.sessionId].slots[key] = value;
                                     ^

TypeError: Cannot read property 'slots' of undefined

That's JavaScript for you, right?

After digging around a bit, I discovered I had named my skill dragon_hunt, with an underscore, and this had caused the regular expression in use in ChatSkillsManager#session to fail to match the input. The regex is defined thus: new RegExp(this.id + '[,\\-\\!\\? ]+ask ([a-zA-Z0-9]+)[,\\. ](.*)', 'i').

So, is the exclusion of non-alphanumerics from skill name intentional, or just accidental? If it's intentional, or seems like a good idea, then I could submit a pull request to check skill names at the beginning of execution against that requirement and throw an error if the skill name isn't going to fly. Otherwise, I could submit a PR expanding the characters allowed in the regex and probably also checking against that, since there will be some characters we don't want in the skill name. Either way, I'd be happy to contribute to your very helpful project.

@primaryobjects
Copy link
Owner

primaryobjects commented Dec 30, 2016

Thank you for reporting this! I really appreciate it!!

For now, I'd probably hold off on changing the regex. Maybe a warning message, if the name contains an invalid character, would be helpful?

Another item to consider is the Alexa skill Invocation Name Requirements.

For invocation names, Amazon states: "The invocation name must contain only lower-case alphabetic characters, spaces between words, possessive apostrophes, or periods used in abbreviations."

I guess this doesn't map one-for-one with the name you give your skill within the code, but it's something to consider as well. :)

@goodmike
Copy link
Author

The Invocation Name requirements is good information to have. I hadn't even thought about the distinction between namespace and invocation name. It's fun to dig into something relatively new, like Alexa.

I will put together a PR for screening the namespace for characters that don't match the regex. Thanks again for the library and the book.

@goodmike goodmike linked a pull request Dec 30, 2016 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants