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ヶ月前

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ