-
Notifications
You must be signed in to change notification settings - Fork 212
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
Add support for the Dialogue directive #250
Conversation
So that intents can have additional context around schema (slots and utterances) as well as new functionality, an `alexa.intent` object can encase this logic. This commit adds that object and incorporates the logic within.
This commit includes the addition of Dialogue logic for fetching and inflecting on dialogueState
So that we can retain configuration options for the dialogue logic, additional settings are added to the `alexa.intent` object.
To allow for simplicity surrounding dialogue, this commit adds logic to auto-respond to in-progress Dialogue intents with the Dialogue.Delegate directive.
@ericblade I believe you mentioned an interest in looking at this chunk of code. I'd welcome feedback! |
index.js
Outdated
alexa.intent = function(name, schema, handler) { | ||
this.name = name; | ||
this.handler = handler; | ||
this.slots = (schema && typeof schema["slots"] != "undefined") ? schema["slots"] : null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
!== ?
index.js
Outdated
@@ -460,8 +461,8 @@ alexa.app = function(name) { | |||
if (!response.resolved) { | |||
if ("IntentRequest" === requestType) { | |||
var intent = request_json.request.intent.name; | |||
if (typeof self.intents[intent] != "undefined" && typeof self.intents[intent]["function"] == "function") { | |||
return Promise.resolve(self.intents[intent]["function"](request, response)); | |||
if (typeof self.intents[intent] != "undefined" && typeof self.intents[intent].handler == "function") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
=== ?
OK, I think I need to brush up on the Amazon docs for both Dialog and Directives :-) So, I don't see any issues in the code, other than a couple of spots where I'd use === or !== without knowing the specifics of the Dialog and Directives APIs. In my opinion, it'd be good to switch to the American English form of "Dialog", as that is what is used in the Amazon docs as well. I'm a little confused, though, in the first commit how " for (key in intent.schema.slots) { " becomes " for (key in intent.slots) {" .. and still works, and we still have intent.schema. Not sure if it's lack of sleep, or if I'm blindly missing something. I assume you've tested the basic functionality. Have you also checked the ?schema and ?utterances functions? Otherwise, I'd just like to see a link in the docs pointing to the pages for Dialog and Directive, and perhaps an example of how to use them (i think the docs have extensive examples of the basics) ... and then i need to re-write all my code, because I basically wrote Amazon's entire Dialog system in my own skill code, about 3 weeks before Amazon came out with it :-D |
@ericblade Great feedback. I'll tweak the english, README, and equality check. As for the |
This is great, much thanks @sbonami! Definitely lets make this US-EN because America first :) |
Missing file, check out the build pls and it's good to go. |
@dblock Missed those in the rename. Fixed and ready to go! |
Merged, thanks. |
@dblock Actually, should this be under |
Sure, lets increment. |
So that intents can have additional context around schema (slots and utterances) as well as new functionality, an
alexa.intent
object was added. Additionally, analexa.dialogue
object was created to contain introspection logic. To benefit from the addition of the logic and ease development, auto-delegation was also added.