Search code examples
amazon-web-servicesaws-lambdaamazon-lex

Getting response from AWS Lambda function to AWS Lex bot is giving error?


I have created one AWS Lex bot and I am invoking one lambda function from that bot. When testing the lambda function I am getting proper response but at bot I am getting below error:

An error has occurred: Received invalid response from Lambda: Can not construct instance of IntentResponse: no String-argument constructor/factory method to deserialize from String value ('2017-06-22 10:23:55.0') at [Source: "2017-06-22 10:23:55.0"; line: 1, column: 1]

Not sure, what is wrong and where I am missing. Could anyone assist me please?


Solution

  • The solution to above problem is that we need to make sure response returned by lambda function, to be used at AWS lex chat bot should be in below format:

    {
    "sessionAttributes": {
    "key1": "value1",
    "key2": "value2"
    ...
     },
      "dialogAction": {
    "type": "ElicitIntent, ElicitSlot, ConfirmIntent, Delegate, or Close",
    Full structure based on the type field. See below for details.
    }
    }
    

    By this, chat bot expectd DialogAction and corresponding elements in order to process the message i.e. IntentResponse.

    Reference: http://docs.aws.amazon.com/lex/latest/dg/lambda-input-response-format.html