I am new to AWS LAmbda, Chatbots, and Javascript.: Ultimately, I am trying to create a chatbot that will make a rest API call (POST) using the value in the slot when the lambda function fulfills the request from the chatbot. I have the lambda code that makes the rest API call working fine in a separate function currently.
I learning and am trying to get the lambda function to fullfill the chatbot request with my below test function:
When I do a test in the chatbot to the test lambda function, I am getting the following error: An error has occurred: The server encountered an error processing the Lambda response
when I tested the payload inside lambda it worked. however, it is not working when I test the chatbot with the same lambda function. I created the lambda function based on the info on this response format page, but I cannot figure out what I am missing in the code. https://docs.aws.amazon.com/lex/latest/dg/lambda-input-response-format.html
Here is the request:
{
"alternativeIntents": [],
"botVersion": "$LATEST",
"dialogState": "ConfirmIntent",
"intentName": "Hello",
"message": "are you sure your name is al?",
"messageFormat": "PlainText",
"responseCard": null,
"sentimentResponse": {
"sentimentLabel": "NEUTRAL",
"sentimentScore": "{Positive: 0.031974494,Negative: 0.023143388,Neutral: 0.8841075,Mixed: 0.06077461}"
},
"sessionAttributes": {},
"sessionId": "2021-07-25T14:18:31.085Z-OxCrkGGA",
"slotToElicit": null,
"slots": {
"name": "al"
}
}
Here is my lambda code for the test(Node JS):
exports.handler = function(event, context, callback) {
callback(null, {
"dialogAction":{
"type":"Close",
"fullfillmentState":"Fulfilled",
"message": {
"contentType":"PlainText",
"content":"Your request has been fulfilled"
}
}
});
};