0

I am deploying a Lex V2 bot with AWS CDK and want my bot to have buttons for eliciting slots, but for some reason I get an error:

DevBot Resource handler returned message: 

"Importing CDK-DevBot failed due to [There was an error importing the bot. 
Make sure that the imported bot and contents of the zip file are correct, then try your request again.]. 
The import could not be completed." 

(RequestToken: ebd3354f-6169-922a-d0f9-d14690671e25, HandlerErrorCode: InvalidRequest)

This error is not very informative. The relevant part of the CloudFormation template: "Message"

"MessageGroupsList: [{
  "Message": {
    "ImageResponseCard": {
      "Buttons": [
        {
          "Text": "1.0.3",
          "Value": "1.0.3"
        },
        {
          "Text": "1.0.5",
          "Value": "1.0.5"
        }
      ],
      "Title": "Title"
    },
    "PlainTextMessage": {
      "Value": "Please enter the issue number"
    }
  }
}]

If I remove "ImageResponseCard" then it deploys okay. Otherwise, I get the error.

Has anybody else had this problem and found a way to overcome it?

Wesley Cheek
  • 1,058
  • 12
  • 22

1 Answers1

1

The MessageGroupList is an array of Message elements. Every element must have a different type of Message that could be ImageResponseCard or PlainTextMessage. So in your case the template has an incorrect structure, it should be something like that:

{
    "MessageGroupsList": [
        {
            "Message": {
                "ImageResponseCard": {
                    "Buttons": [
                        {
                            "Text": "1.0.3",
                            "Value": "1.0.3"
                        },
                        {
                            "Text": "1.0.5",
                            "Value": "1.0.5"
                        }
                    ],
                    "Title": "Title"
                }
            }
        },
        {
            "Message": {
                "PlainTextMessage": {
                    "Value": "Please enter the issue number"
                }
            }
        }
    ]
}

Assumming that the missing tick in MessageGroupList is a typo.

fedeO
  • 46
  • 3