-3
{
  "sessionState": {
    "sessionAttributes": {},
    "dialogAction": {
      "type": "Close",
      "fulfillmentState": "Fulfilled"
    }
  },
  "messages": [
    {
      "contentType": "PlainText",
      "content": "I have flights from to"
    }
  ]
}

this is the response from Lambda function. Lexv2 bot is not accepting this response. It is saying invalid JSON response.

Arun
  • 1
  • 2
  • 1
    please *never* post code (including JSON) as screenshots. this makes it harder to read it, and much more complicated to help you, as people can not simply copy paste it and correct it. – Lux Jan 02 '22 at 18:09
  • 1
    Sorry, noted it. – Arun Jan 03 '22 at 04:56

2 Answers2

1

I took the liberty to write it out:

{
    "sessionState": {
        "sessionAttributes": {},
        "dialogAction": {
            "type": "Close",
            "fulfillmentState": "Fullfilled"
        }
    },
    "messages": [{
        "contentType": "PlainText",
        "content": "I have flights from to"
    }]
}

JSONLint says its valid.

Perhaps you aren't parsing it correctly?

andylib93
  • 133
  • 8
0

Your response format is incorrect, you need to pass back the SessionState from the request with the DialogAction type set to Close, and the state of the Intent set to Fulfilled. Here's an example:

{
  "sessionState": {
    "sessionAttributes": {},
    "activeContexts": [],
    "intent": {
      "confirmationState": "None",
      "name": "YourIntentName",
      "slots": {},
      "state": "Fulfilled"
    },
    "originatingRequestId": "xxx",
    "dialogAction": {
      "type": "Close"
    }
  },
  "messages": [
    {
      "contentType": "PlainText",
      "content": "I have flights from to"
    }
  ],
  "requestAttributes": {}
}

You can look at https://github.com/aws-samples/amazon-lex-v2-lambda-integration-examples for some helper code and examples.