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
已提問 2 個月前檢視次數 242 次
1 個回答
1
已接受的答案

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
專家
已回答 2 個月前
profile picture
專家
已審閱 2 個月前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南