2
votes

I am building an Alexa skill in node using the alexa-sdk. I am using a dialog model to handle the user interaction. I am having some trouble passing the flow along to new request types, such as from the launch request to an intent request.

Below is an example of my handlers and what I want ideally. My specific usecase is that I would like to ask some questions of the user and then send them to different intents based on what they answer. In the intents I would like to have access to the request objects, as if they entered that intent originally, so the dialog model can do its work.

const handlers = {
    'LaunchRequest': function () {
        this.emit('Entry'); // this does not do what I want
    },
    'Entry': function () {
        let request = this.event.request; // this is the launch request object.
        // I would like to get the request object for Entry, like if the user started here

        // ask some questions, potentially passing the torch to a new intent based on the answers
    }
};

So, is there any way to "call" an intent like the user originally made a request to that intent? Sorry if I missed something obvious in the documentation, I searched around pretty thoroughly I think, but there is A LOT of documentation. ps: I could manually construct the request object of course, but I really should not have to I feel.

1

1 Answers

3
votes

I am pretty sure there is no way yet to call on an intent as you are asking.

If you go through the syntax description of dialog directieves here, it says:

Note that you cannot change intents when returning a Dialog directive, so the intent name and set of slots must match the intent sent to your skill.

With returning a dialog directive you are able to 'elicit' or 'confirm' slots or intents, or even let a delegate handle your dialog for you, with prompts and reprompts set in the Skill Builder.

As far as i know, the only solution to trigger a specific intent is to make the user invoke it. You can guide the user into saying a specific utternace to trigger your intent.

As for saving older requests, you can use session attributes. Just build a response after your Launch with a session attribute containing the whole LaunchRequest.

"sessionAttributes": {
"oldRequest": this.event.request
}