I am getting Error while displaying image as a response. I am getting this error :
An error has occurred: Invalid Lambda Response: Received invalid response from Lambda: Unrecognized field "responseCard" (class IntentResponse), not marked as ignorable at [Source: {"sessionAttributes":{},"dialogAction":{"type":"Close","fulfillmentState":"Fulfilled","message":{"contentType":"PlainText","content":"
function close(sessionAttributes, fulfillmentState, message) {
return {
sessionAttributes,
dialogAction: {
type: 'Close',
fulfillmentState,
message,
},
responseCard: {
version: '2',
contentType: "application/vnd.amazonaws.card.generic",
genericAttachments: [
{
imageUrl:"URL of the image to be shown",
}
]
}
};
}
exports.handler = (event, context, callback) => {
console.log( "EVENT= "+JSON.stringify(event) );
const intentName = event.currentIntent.name;
var sessionAttributes = event.sessionAttributes;
var responseMsg = "";
if (intentName == "greetings") {
var message = {
'contentType': 'PlainText',
'content': 'Hi! How can I help you?'
}
responseMsg = close( sessionAttributes, 'Fulfilled', message );
}
else {
console.log( "ERROR unhandled intent named= "+intentName );
responseMsg = close( sessionAttributes, 'Fulfilled', {"contentType":"PlainText", "content":"Sorry, I can't help with that yet."});
}
console.log( "RESPONSE= "+JSON.stringify(responseMsg) );
callback(null,responseMsg);
}
How should i display image on the chat box? What mistake i am doing here?