0

This is my sessionState object

{
"sessionAttributes": {},
"dialogAction": {
  "type": "ElicitSlot",
  "slotToElicit": "flowName"
},
"intent": {
  "name": "WelcomeIntent",
  "confirmationState": "None",
  "slots": {
    "flowName": null
  },
  "state": "Fulfilled"
}

this is messages array

[
{
  "contentType": "ImageResponseCard",
  "content": "Some content",
  "imageResponseCard": {
    "title": "Choose option",
    "subtitle": "options are",
    "buttons": [
      {
        "text": "option1",
        "value": "option1"
      },
      {
        "text": "option2",
        "value": "option2"
      },
      {
        "text": "option3",
        "value": "option3"
      },
      {
        "text": "option4",
        "value": "option4"
      },
      {
        "text": "option5",
        "value": "option5"
      },
      {
        "text": "option6",
        "value": "option6"
      },
      {
        "text": "option7",
        "value": "option7"
      }
    ]
  }
}

]

iam sending 7 buttons from lamda function, but lex is not accepting more than 5 buttons. It is giving error saying buttons should be between 0,5 index. Is there way to display more than 5 buttons in lex response.

John Rotenstein
  • 241,921
  • 22
  • 380
  • 470
Arun
  • 1
  • 2

3 Answers3

0

As per the developer guide, ImageResponseCard supports a maximum of 5 button objects.

Array Members: Minimum number of 0 items. Maximum number of 5 items.

ImageResponseCard - AWS Lex V2 Developer Guide

Reegz
  • 511
  • 1
  • 6
  • 13
0

I took the approach of conditionally eliciting different cards after a previous slot. In my case, choose a risk level (High, Medium, Low) and depending on which value, elicit either a High, Med, or low slot card prompt. Just a workaround.

Donnie Kerr
  • 334
  • 4
  • 18
0

By default, it will not allow more than 5 size but, we can manually edit the response logic to allow the more than 5 size.

Ref link can be used - https://github.com/aws-solutions/qnabot-on-aws/blob/main/lambda/fulfillment/lib/middleware/lex.js#L299:L315

It can be done by using above code and it worked for me. only concern is, it will not return list to LEX console, but works fine on the website(UI) where your LEX is integrated.