Closed adamcohenrose closed 6 years ago
Thanks a lot for filing this PR! Do you have an example project that I can use to verify your patch? At some point soon there'll be actual tests to verify parsing these responses, so it'll be helpful to at least grab the JSON response that is returned so that this won't be an issue going forward.
I've managed to reproduce this when Number Genie is exiting:
{
conversationToken: '[\"_actions_on_google\",\"game\",\"yes_no\"]',
finalResponse: {
richResponse: {
items: [
{
simpleResponse: {
textToSpeech: '<speak>OK, I\'m already thinking of a number for next time.</speak>',
displayText: 'OK, I\'m already thinking of a number for next time.',
},
},
],
},
},
responseMetadata: {
status: {
message: 'Success (200)',
},
queryMatchInfo: {
queryMatched: true,
intent: '2ae41bb5-5423-414d-9190-1b6dd460e12f',
},
},
userStorage: '{\"data\":{}}',
}
Do you think it would make more sense to make this a conditional, ie:
debugInfo.expectedInputs ?
debugInfo.expectedInputs[0].inputPrompt.richInitialPrompt :
debugInfo.finalResponse.richResponse
Sorry for taking so long to respond. Great that you've found an example!
Yes, I agree – it's clearer as a conditional.
A bunch of fixes have been published as part of the move to TypeScript, so this should be resolved now.
The finalResponse code was never reached since the
debugInfo.expectedInputs
wasundefined
and so indexing into the zeroth item resulted in an error