[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report
[ ] Performance issue
[ ] Feature request
[ ] Documentation issue or request
[x ] Other... Please describe:
I think I may just be misunderstanding how it works. I can use it just fine to delegate the conversation to my Alexa skill until she fills all the slot for my current intent. That's fantastic, and I love that feature.
But I can't get it to change intents.
I thought the optional parameter "updatedIntent" would allow me to return to a different intent handler. Am i just thinking about this the wrong way?
Alexa says "There was a problem with the requested skill's response" when I uncomment the
.addDelegateDirective in the response builder at the end of the handle function in my FoodHandler.
Using states to reach my YesNoIntentHandler, but the documentation on states for SDK 2.0 has eluded me thus far.
the arrays i check for food type and sentence fragments are just in the same directory as my index.js
const FoodIntentHandler = {
canHandle(handlerInput){
return handlerInput.requestEnvelope.request.type === 'IntentRequest'
&& handlerInput.requestEnvelope.request.intent.name === 'FoodIntent';
},
async handle(handlerInput){
let speechText = FoodPrefixes[Math.floor(Math.random() * FoodPrefixes.length)];
let currentIntent = handlerInput.requestEnvelope.request.intent;
let slots = currentIntent.slots;
if(!(slots.foodType.value)){
return handlerInput.responseBuilder
.addDelegateDirective(currentIntent)
.getResponse()
} else {
let typeOfFood = await slots.foodType.value;
//Only have two types of food right now so an if-else is sufficient
//Reall want to find a way to use the slot instead of hardcoding the type of food, cause then i wouldn't need if-elseif-elseif-else...
// const randomFood = Foods.typeOfFood[Math.floor(Math.random() * Foods.typeOfFood.length)];
if(typeOfFood === "Puerto Rican") {
let randomFood = Foods.PuertoRican[Math.floor(Math.random() * Foods.PuertoRican.length)];
speechText += randomFood;
}
else{
let randomFood = Foods.Italian[Math.floor(Math.random() * Foods.Italian.length)];
speechText += randomFood;
}
speechText += FoodSuffixes[Math.floor(Math.random() * FoodSuffixes.length)];
return handlerInput.responseBuilder
.speak(speechText)
.withSimpleCard('Cheer Up - Food', speechText)
//.addDelegateDirective('YesNoIntent')
.getResponse();
}
},
};
I'm trying to learn compelx dialog management for my new job.
Hey @dillonharlessNHRMC , please fill in the issue with the exact problem you are facing and a code snippet, so that we can investigate and help you in a better fashion.
Thanks, sorry @nikhilym. I hit submit too soon originally.
@nikhilym Maybe this is what I am looking for --> https://ask-sdk-for-nodejs.readthedocs.io/en/latest/Managing-Attributes.html#request-attributes
That talks about storing sessionAttributes. Now I'm thinking I could store a slot's value in the session attributes in my FoodHandler, and then just .getResponse().
Then in my YesNoHandler's canHandle() function, check for that value, and if exists then use logic in the handle() function to act accordingly to a YES or NO. I'll try it and confirm.
Still at a loss here...
You can't use the addDelegateDirective to force the next intent (handler). With the alexa sdk v1 you could simply use: this.emit('newIntent') to delegate the current request to another intent, starting with v2 you can't do this anymore.
If you would like the user to confirm his input just use the "confirmIntent" / "confirmSlot" directive.
https://developer.amazon.com/de/docs/custom-skills/dialog-interface-reference.html#confirmintent
https://developer.amazon.com/de/docs/custom-skills/dialog-interface-reference.html#confirmslot
with an individual prompt like: would you like to eat xxxx?
alexa then calls the same intent but you're able to ask for the confirmationstatus (see links / Examples above)
hope this helps.
@xeladotbe thanks for the reply! It wasn't exactly what I was looking for, but I appreciate the response.
Turns out the link I posted in my comment was actually the solution I was looking for, but Alexa was just going silent because I did not add .withShouldEndSession(false) originally... So I was able to achieve my goal of switching intents by setting the state in attributes equal to a string before returning responseBuilder, and then checking for that state in the canHandle() function of my desired intent.
Thank you both for your help.