Lex V2 Test Bot responseCard not showing

0

Hi, I have created below given Lambda function to display responseCard. Message is displayed but responseCards buttons are not showing on test Bot also on CloudFormation. Please suggest:

export const handler = async (event) => {
    // Create the response
    const response = {
        "sessionState": {
            "intent": {
                "name": "intentName",
                "slots": {
                    "slotName": null
                }
            },
            "dialogAction": {
                "type": "ElicitSlot",
                "slotToElicit": "slotName"
            }
        },
        "messages": [
            {
                "content": "Please select an option",
                "contentType": "PlainText"
            }
        ],
        "responseCard": {
            "version": 1,
            "contentType": "application/vnd.amazonaws.card.generic",
            "genericAttachments": [
                {
                    "title": "Title",
                    "subTitle": "Please select",
                    "imageUrl": null,
                    "buttons": [
                        {
                            "text": "Text 1",
                            "value": "Value 1"
                        }
                    ]
                }
            ]
        }
    };
    return response;
};
profile picture
asked a month ago224 views
1 Answer
1
Accepted Answer

Ensure your Lambda function follows the structure required by Lex V2, including the session state, messages, and response card formats. In particular, make sure the response includes the sessionState, messages, and responseCard elements as outlined in AWS documentation. The sessionState must contain the dialog action and intent information. The messages section should specify the content type and content

Your response format should match the Lex V2 requirements, where the responseCard should be part of the array of messages. This is a common format change from Lex V1 to Lex V2 that can lead to issues if not updated properly. Ensure that the contentType for your message is set to ImageResponseCard if you are using response cards​

If you are integrating with LexWebUi, ensure that it is configured correctly for Lex V2. This involves using the LexV2BotId, LexV2BotAliasId, and LexV2BotLocaleId. If you are mistakenly using the botName parameter, it indicates that your setup might still be targeting Lex V1, which could be why you are not seeing the expected results. LexWebUi should be set up to target only one version of Lex at a time

profile picture
EXPERT
answered a month ago
profile picture
EXPERT
reviewed a month ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions