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달 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠