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

toIntent() improvement #55

Closed
terloon opened this issue Jan 9, 2018 · 7 comments
Closed

toIntent() improvement #55

terloon opened this issue Jan 9, 2018 · 7 comments

Comments

@terloon
Copy link

terloon commented Jan 9, 2018

On my initial use of toIntent(), I made a horrible assumption that it would also automatically route the inputs. So what I had to do was:

app.toIntent(app.getIntentName(), _.values(app.getInputs()));

Could we add something like:

toIntentWithInputs(intent) {
    toIntent(intent, _.values(this.inputs));
}
@jankoenig
Copy link
Member

Hi @terloon, thanks!

Is writing toIntentWithInputs (+ toStateIntentWithInputs, toStatelessIntentWithInputs) really that much of a timesaver compared to just adding the input as a parameter? Or are you dealing with a large amount of different inputs? Can you further elaborate why you're using _.values(app.getInputs())instead of justapp.getInputs()`?

I would do it like this:

const handlers = {
    'FirstIntent': function(name, age) {
        app.toIntent('SecondIntent', name, age);
    },
    'SecondIntent': function(name, age) {
        app.tell('Hi, your name is ' + name + ', and you are ' + age + ' years old.');
    },
}

Am I missing something?

@terloon
Copy link
Author

terloon commented Jan 10, 2018

So my use case was:

const handlers = {
    'NEW_SESSION': function() {
        // do some prep code required by all intents...
        app.toIntent(app.getIntentName(), _values(app.getInputs());
    },
    'FirstIntent': function(one, two) {
        
    },
    'SecondIntent': function(one) {
        
    }
}

But you're right, it doesn't really save much since this is done once and in NEW_SESSION would probably where this would likely be used.

Also, new to node.js (or at least its been a while since I did javascript), but I thought doing this:

app.toIntent(app.getIntentName(), app.getInputs());

would just make the first argument (or arguments[1]) be an object like:

{
    "one": "value",
    "two": "anotherValue"
}

Closing this issue. Thanks for the feedback.

@terloon terloon closed this as completed Jan 10, 2018
@jankoenig
Copy link
Member

Hi @terloon, ah I get it, you want to use it inside NEW_SESSION, this is why the number of inputs is variable.

So, you have tried just using app.toIntent(app.getIntentName()) without passing a parameter, and then accessing it, like so?

const handlers = {
    'NEW_SESSION': function() {
        // do some prep code required by all intents...
        app.toIntent(app.getIntentName());
    },
    'FirstIntent': function(one, two) {
        
    },
    'SecondIntent': function(one) {
        
    }
}

Because actually this should work (cc @aswetlow). We'll look into it

@jankoenig jankoenig reopened this Jan 11, 2018
@terloon
Copy link
Author

terloon commented Jan 24, 2018

I think I narrowed down the case where I had to do this. On the Alexa Test Simulator, if I don't pass in the input, when I perform an invocation of the voice app with a command, the input is lost.

So if my invocation is "hello world" with a skill like "start thing with number 1", if I say:

"ask hello world start thing with number 1", it would lose the slot input parameter.

@jankoenig
Copy link
Member

Hey yes, this is due to the 'NEW_SESSION' handler.
@aswetlow and I have recently run into the same problem and will think about a way to fix this in the upcoming version

@terloon
Copy link
Author

terloon commented Jan 25, 2018

Gotcha. Right now I am getting around it by doing what I initially mentioned:

app.toIntent(app.getIntentName(), _.values(inputs));

@jankoenig
Copy link
Member

This got resolved some time ago

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

No branches or pull requests

2 participants