I am working on an Alexa skill where I would like to redirect user to one intent when he opens the skill via LaunchRequest.
- User says
Open xyz skill
- LaunchRequest receives this and forwards the request to another intent.
this.emit('AnotherIntent')
AnotherIntent
has a SLOT which is required for its functioning.- I have setup the SLOT as required and
AnotherIntent
does work perfectly fine when invoked on its own.
However when I Launch the skill and tries to call AnotherIntent
from within it as mentioned in Step 2 above, Alexa skill fails to launch.
One more thing to note is when I Test the same Alexa skill from within the skill builder for this scenario, the output json correctly shows me the SLOT being elicited. Not sure what is happening when I am trying to run it from Echo device.
I am using NodeJS and Lambda to deploy my Alexa handlers.
Any help would be appreciated.
Further reference based on the comment -
Handlers -
var handlers = {
'LaunchRequest': function () {
console.log("LaunchRequest::" + JSON.stringify(this.event.request));
this.emit('fooIntent');
},
'SessionEndedRequest': function () {
console.log('session ended!');
},
'fooIntent': function () {
const intentObj = this.event.request.intent;
if (!intentObj || (intentObj && !intentObj.slots.WHEN.value)) {
console.log('fooIntent::UserId' + this.event.session.user.userId);
const slotToElicit = 'WHEN';
const speechOutput = 'Ask a question here ?';
const repromptSpeech = speechOutput;
console.log("emitting elict now");
this.emit(':elicitSlot', slotToElicit, speechOutput, repromptSpeech);
} else {
// SLOT is filled, let's query the database to get the value for the slot.
console.log("fooIntent intent:something is requested for " + this.event.request.intent.slots.WHEN.value);
// All the slots are filled (And confirmed if you choose to confirm slot/intent)
fooIntentFunction(this,this.event.request.intent.slots.WHEN.value);
}
},
'AMAZON.HelpIntent': function () {
var speechOutput = "Need to come up with one.";
var reprompt = "What can I help you with?";
this.emit(':ask', speechOutput, reprompt);
},
'AMAZON.CancelIntent': function () {
this.emit(':tell', 'Goodbye!');
},
'AMAZON.StopIntent': function () {
this.emit(':tell', 'Goodbye!');
}
};
JSON Request captured in LaunchRequest
{
"type": "LaunchRequest",
"requestId": "amzn1.echo-api.request.972bb705-d181-495e-bf60-991f2bd8fbb1",
"timestamp": "2017-12-30T21:35:21Z",
"locale": "en-US"
}
JSON Request captured in the Intent when invoked from LaunchRequest. It shows that intent
is not set then. I believe that is why it keeps failing when I try to emit elicit in the fooIntent implementation as shown above.
{
"type": "LaunchRequest",
"requestId": "amzn1.echo-api.request.972bb705-d181-495e-bf60-991f2bd8fbb1",
"timestamp": "2017-12-30T21:35:21Z",
"locale": "en-US"
}
- Amit