question

newuser-0a77b426-a9ae-44d8-a29c-25e5b9c78c32 avatar image

Debugging invalid responses for Dialogs

I have a Dialog-based intent that's been entirely configured via the Beta interaction builder.

My Lambda function is working correctly within the request, and returning a well-formed response (verified using an online JSON verifier), but the Alexa service is returning an error indicating "There was an error with the skill response."

It seems I'm probably not sending the exact structure or value for fields, but there's absolutely no way to see WHY the service is rejecting my response.

Because it's a Dialog-based intent, I cannot use the simulator to debug/validate responses from my Lambda method. So, questions:

1. How are we supposed to debug these kinds of errors?

2. Is there no library I can import into my Lambda code that does the same kind of verification done on the Alexa side (e.g. deeper than just JSON validation)? This would help a LOT.

For what it's worth, here's the response that's causing this error:

{

'version': '1.0',

'response': {

'outputSpeech': {

'text': 'Test question',

'type': 'PlainText'

},

'shouldEndSession': False,

'directives': [

{

'updatedIntent': {

'slots': {

'answer': {

'name': 'answer',

'value': 'NONE',

'confirmationStatus': 'NONE'

}

},

'name': 'PlayTriviaIntent',

'confirmationStatus': 'NONE'

},

'type': 'Dialog.Delegate'

}

]

},

'sessionAttributes': {

'correct_answer': 'C',

'played_intro': False

}

}

alexa skills kitskillintentsresponsedialog model
1 comment
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Hi,

I am not sure what you mean by dialog based.

But I wonder, wouldn't Cloud Watch logs serve as a good tool to debug. Once the exact line is determined there could be many parameters that could cause an issue.

One such example in my case, is that the card title that is mostly used in response builder was causing issue mostly due to size limit. May be some constraint in one of these parameters could be causing an issue. The error obtained is often misleading.

Thanks,

Amith

0 Likes 0 ·
newuser-0a77b426-a9ae-44d8-a29c-25e5b9c78c32 avatar image
newuser-0a77b426-a9ae-44d8-a29c-25e5b9c78c32 answered

Dialog-based means the intent leverages the Dialog interface for multi-turn prompting and utterances.

CloudWatch logs are great for when your Lambda handlers error out, but this is not what's happening. As noted, my Lambda code is completing successfully and returning a response.

The problem is that the Alexa service doesn't like my response. Something about it is not following the dialog interaction, although it looks good to me. But without any kind of meaningful error message, or debugging tool, I'm just left guessing what's wrong, which is a terrible experience for developers.

10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Andy Whitworth avatar image
Andy Whitworth answered

Your JSON structure looks incorrect.

You have the updatedIntent structure within a directives array. The Amazon Dialog API reference specified the structure it's expecting and there is no directives array.

https://developer.amazon.com/docs/custom-skills/dialog-interface-reference.html#delegate

Delegate Directive

Sends Alexa a command to handle the next turn in the dialog with the user. You can use this directive if the skill has a dialog model and the current status of the dialog (dialogState) is either STARTED or IN_PROGRESS. You cannot return this directive if the dialogState is COMPLETED.

Syntax

{"type":"Dialog.Delegate","updatedIntent":{"name":"string","confirmationStatus":"NONE","slots":{"string":{"name":"string","value":"string","confirmationStatus":"NONE"}}}}
1 comment
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Plus, you have outputSpeech in the response, this is a no-no for a Dialog.Delegate response.

Do not include outputSpeech or reprompt with the Dialog.Directive. Alexa uses the prompts defined in the the dialog model to ask the user for the slot values and confirmations.

0 Likes 0 ·
Jenn@amazon avatar image
Jenn@amazon answered

Alexa will send details with a 'SessionEndedRequest' event.

To see the details of the events in CloudWatch add the following line to the exports.handler:

console.log("===EVENT=== \n" + JSON.stringify(event));

Full function:

exports.handler = (event, context) => {
  console.log("===EVENT=== \n" + JSON.stringify(event));
  // standard Alexa Skill Kit initialization
  const alexa = Alexa.handler(event, context);
  alexa.appId = '';
  alexa.registerHandlers(main);
  alexa.execute();
};

This will print the full Event content in CloudWatch.

Look in the 'Request' object for the details:

...
"request": {
    "type": "SessionEndedRequest",
    "requestId": "amzn1.echo-api.request.0000000-0000-0000-0000-00000000000",
    "timestamp": "2015-05-13T12:34:56Z",
    "reason": "ERROR",
    "locale": "string",
    "error" : {
	"type": "INVALID_RESPONSE",
	"message": "<Details of Error>"
  	}
}
...
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.