Multiple response cards unable to be shown for Amazon lex chatbot

杀马特。学长 韩版系。学妹 提交于 2021-01-28 19:00:45

问题


I am currently using Amazon lex to create a chatbot and want to be able to post multiple response cards at once. The question asked by the chatbot will be "Do you have an integrated Shield Plan currently?" and followed will be multiple response cards where it will show a list of plans from different brands. But if the user does not have a plan, there will be an option called "No" on the response card.

But if I publish the chatbot let's say on Slack, not even one response card is shown. How do I fix this problem?


回答1:


You have not specified the Card Image URL, this is why there is no card.
I have just now tested it, without Image Card URL ResponseCard will not be shown on Facebook or Slack if we are setting it using console.

However if you are setting Response Cards in Lambda function, then we can choose not to have an image. You can check that slot is filled or not in the DialogCodeHook and display the ResponseCard accordingly.

Below is sample code to display ResponseCard without an image:

{
    'dialogAction': {
        'type': 'Close',
        'fulfillmentState': 'Fulfilled',
        'message': {
            'contentType': 'PlainText',
            'content': message
        },
        'responseCard': {
        'version': '0',
        'contentType': 'application/vnd.amazonaws.card.generic',
        'genericAttachments': [
            {
            'title': 'title1',
            'subTitle': 'subtitle',
            "buttons":[ 
             {
                "text":"button 1",
                "value":"value 1"
             },
             {
                "text":"button 2",
                "value":"value 2"
             },
             {
                "text":"button 3",
                "value":"value 3"
             }
                ]
            }
        }
    }
}

Hope it helps.



来源:https://stackoverflow.com/questions/47884467/multiple-response-cards-unable-to-be-shown-for-amazon-lex-chatbot

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!