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

Add support for the Dialogue directive #250

Merged
merged 8 commits into from
Jun 23, 2017
Merged

Conversation

sbonami
Copy link
Contributor

@sbonami sbonami commented Jun 22, 2017

So that intents can have additional context around schema (slots and utterances) as well as new functionality, an alexa.intent object was added. Additionally, an alexa.dialogue object was created to contain introspection logic. To benefit from the addition of the logic and ease development, auto-delegation was also added.

Scott BonAmi added 5 commits June 21, 2017 21:48
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.
@sbonami
Copy link
Contributor Author

sbonami commented Jun 22, 2017

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

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") {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

=== ?

@ericblade
Copy link

ericblade commented Jun 22, 2017

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

@sbonami
Copy link
Contributor Author

sbonami commented Jun 22, 2017

@ericblade Great feedback. I'll tweak the english, README, and equality check. As for the alexa.intent#slot question, the intent is now an object with a slot attribute. No more schema attribute on an intent. It also seems as though the schema and utterance functions are fully tested, but I can manually verify as well.

@dblock
Copy link
Collaborator

dblock commented Jun 22, 2017

This is great, much thanks @sbonami! Definitely lets make this US-EN because America first :)

@dblock
Copy link
Collaborator

dblock commented Jun 23, 2017

Missing file, check out the build pls and it's good to go.

@sbonami
Copy link
Contributor Author

sbonami commented Jun 23, 2017

@dblock Missed those in the rename. Fixed and ready to go!

@dblock dblock merged commit 91b784a into alexa-js:master Jun 23, 2017
@dblock
Copy link
Collaborator

dblock commented Jun 23, 2017

Merged, thanks.

@sbonami sbonami deleted the dialogue branch June 23, 2017 15:25
@sbonami
Copy link
Contributor Author

sbonami commented Jun 23, 2017

@dblock Actually, should this be under 4.1?

@dblock
Copy link
Collaborator

dblock commented Jun 23, 2017

Sure, lets increment.

@dblock dblock mentioned this pull request Jul 2, 2017
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 this pull request may close these issues.

3 participants