This is happening because all you're sending back is a String, whereas Lex expects replies in specific formats e.g.
"dialogAction": {
"type": "Close",
"fulfillmentState": "Fulfilled or Failed",
"message": {
"contentType": "PlainText or SSML",
"content": "Message to convey to the user. For example, Thanks, your pizza has been ordered."
},
"responseCard": {
"version": integer-value,
"contentType": "application/vnd.amazonaws.card.generic",
"genericAttachments": [
{
"title":"card-title",
"subTitle":"card-sub-title",
"imageUrl":"URL of the image to be shown",
"attachmentLinkUrl":"URL of the attachment to be associated with the card",
"buttons":[
{
"text":"button-text",
"value":"Value sent to server on button click"
}
]
}
]
}
}
This code will work:
function close(sessionAttributes, fulfillmentState, message, responseCard) {
return {
sessionAttributes,
dialogAction: {
type: 'Close',
fulfillmentState,
message,
responseCard,
},
};
}
function dispatch(intentRequest, callback) {
const outputSessionAttributes = intentRequest.sessionAttributes || {};
callback(close(outputSessionAttributes, 'Fulfilled', { contentType: 'PlainText',
content: 'Thank you and goodbye' }));
}
function loggingCallback(response, originalCallback) {
originalCallback(null, response);
}
exports.handler = (event, context, callback) => {
try {
console.log("event: " + JSON.stringify(event));
dispatch(event, (response) => loggingCallback(response, callback));
} catch (err) {
callback(err);
}
};
It simply sends back "Thank you and goodbye" in the required format, in this case with a "dialogAction" type of "Close" - which informs Lex not to expect a response from the user.
There are other types - this and more are all explained in the Lex documentation.