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;
};
1 Risposta
1
Risposta accettata

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
ESPERTO
con risposta 2 mesi fa
profile picture
ESPERTO
verificato 2 mesi fa

Accesso non effettuato. Accedi per postare una risposta.

Una buona risposta soddisfa chiaramente la domanda, fornisce un feedback costruttivo e incoraggia la crescita professionale del richiedente.

Linee guida per rispondere alle domande