I am writing an Alexa dialog with intent confirmation. When confirmation is denied I want to restart the same dialog again by delegating to this very dialog. I am proceeding like described in this stack overflow question. As described in the solution to this question I do the delegation when the dialogState
is still IN_PROGRESS
. In my case Alexa always responds with the not very meaningful message There was a problem with the requested skill's response. No error message in the application log.
My skill model and the lambda code are as follows:
{
"interactionModel": {
"languageModel": {
"invocationName": "hello",
"intents": [
{
"name": "UserIntent",
"slots": [
{
"name": "UserName",
"type": "AMAZON.FirstName",
"samples": [
"My name is {UserName}",
"I am {UserName}",
"{UserName}"
]
}
],
"samples": [
"My name is {UserName}",
"I am {UserName}"
]
}
],
"types": []
},
"dialog": {
"delegationStrategy": "SKILL_RESPONSE",
"intents": [
{
"name": "UserIntent",
"confirmationRequired": true,
"prompts": {
"confirmation": "Confirm.Intent.UserName"
},
"slots": [
{
"name": "UserName",
"type": "AMAZON.FirstName",
"confirmationRequired": false,
"elicitationRequired": true,
"prompts": {
"elicitation": "Elicit.Slot.UserName"
}
}
]
}
]
},
"prompts": [
{
"id": "Elicit.Slot.UserName",
"variations": [
{
"type": "PlainText",
"value": "What is your name?"
}
]
},
{
"id": "Confirm.Intent.UserName",
"variations": [
{
"type": "PlainText",
"value": "You are {UserName}. Is this right?"
}
]
}
]
}
}
const DeniedUserIntentHandler = {
canHandle(handlerInput) {
const request = handlerInput.requestEnvelope.request;
return request.type === 'IntentRequest' &&
request.intent.name === 'UserIntent' &&
request.dialogState === 'IN_PROGRESS' &&
request.intent.confirmationStatus === 'DENIED';
},
async handle(handlerInput) {
const request = handlerInput.requestEnvelope.request;
const currentIntent = request.intent;
const userName = Alexa.getSlotValue(handlerInput.requestEnvelope, 'UserName');
console.log(`DeniedUserIntentHandler:
request.dialogState=${request.dialogState}, request.intent.confirmationStatus=${request.intent.confirmationStatus}, userName=${userName}`);
return handlerInput.responseBuilder
.speak('Username was not confirmed. Please try again.')
.addDelegateDirective({
name: 'UserIntent',
confirmationStatus: 'NONE',
slots: {}
})
.getResponse();
}
};
What I am missing?