While invoking Lambda function through AWS Lex we generally get below error.
An error has occurred: Received error response from Lambda: Handled
There could be many reasons for this error to occur.
Suppose lambda has following callback response function in node.js:
exports.handler = (event, context, callback) => { callback(null, { "dialogAction": { "type": "ConfirmIntent", "fulfillmentState": "Fulfilled or failed", "message": { "contentType": "PlainText or SSML", "content": "message to convey to the user, i.e. Are you sure you want a large pizza?" } } });
Now according to the AWS docs here the fullfilmentState is a mandatory key field also it should be assigned a single value either “Fullfilled” or “failed“.
Similarly for contentType also assign only a single value, either “Plaintext” or “SSML”
Like the code below:
exports.handler = (event, context, callback) => { callback(null, { "dialogAction": { "type": "ConfirmIntent", "fulfillmentState": "Fulfilled", // <-- Required "message": { "contentType": "PlainText", "content": "message to convey to the user, i.e. Are you sure you want a large pizza?" } } });
So this is one of the reasons why Lex gets this response from Lambda.
However, if you see the req-res in the network tab you would receive HTTP Error 424 which says DependencyFailedException which says “Amazon Lex does not have sufficient permissions to call a Lambda function” which is very misleading.