在 AWS Lex 中创建轮播卡 [英] Creating carousel card in AWS Lex

查看:22
本文介绍了在 AWS Lex 中创建轮播卡的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 lex 构建电子商务聊天机器人.

是否有任何解决方案可以在 Lex 中使用轮播卡或多响应卡?

例如:

谢谢..

解决方案

你可以在响应中显示多个响应卡片,它会像轮播一样显示.按照

动态方法(使用 Lambda):

'dialogAction': {'type': '关闭','fulfillmentState': '已完成','信息': {'contentType': '纯文本',内容":消息},'响应卡':{'版本':'0','contentType': 'application/vnd.amazonaws.card.generic','通用附件':[{'title': 'title1','subTitle': 'subtitle1','attachmentLinkUrl': 'link_that_will_open_on_click','imageUrl': 'link_of_image_to_display',纽扣":[{"text":"button_1","value":"value_to_be_sent_to_server_on_click"},{"text":"button_2","value":"value_to_be_sent_to_server_on_click"},{"text":"button_3","value":"value_to_be_sent_to_server_on_click"}]},{'title': 'title2','subTitle': 'subtitle2','attachmentLinkUrl': 'link_that_will_open_on_click','imageUrl': 'link_of_image_to_display',纽扣":[{"text":"button_1","value":"value_to_be_sent_to_server_on_click"},{"text":"button_2","value":"value_to_be_sent_to_server_on_click"},{"text":"button_3","value":"value_to_be_sent_to_server_on_click"}]},{'title': 'title3','subTitle': 'subtitle3','attachmentLinkUrl': 'link_that_will_open_on_click','imageUrl': 'link_of_image_to_display',纽扣":[{"text":"button_1","value":"value_to_be_sent_to_server_on_click"},{"text":"button_2","value":"value_to_be_sent_to_server_on_click"},{"text":"button_3","value":"value_to_be_sent_to_server_on_click"}]}]}}

注意 1:您可以在轮播中最多 10 个响应卡,在一个轮播中最多 3 个按钮.如果你有超过 10 张卡,你会得到错误.如果您有 3 个以上的按钮,则不会出现错误,但只会显示前 3 个.
注意 2:您需要在 Facebook 应用程序的信使设置中的 Webhooks 中检查 messaging_postbacks 事件,以使轮播按钮起作用.

我已按以下方式实施响应卡:


看卡如轮播,滑动查看更多卡片.

希望有帮助.

I am trying to build a ecommerce chatbot using lex.

Is there any solution to use a carousel card or multi response cards in Lex?

For example:

Thanks..

解决方案

You can display multiple response cards in the response and it will display like carousel. Follow this example to generate response card through console (you can also do it dynamically in code).

Console method:
In the below image, in Prompt response cards section, see in the rightmost part, there is little + button, click on that and you can add more cards.

Dynamic method (using Lambda):

'dialogAction': {
    'type': 'Close',
    'fulfillmentState': 'Fulfilled',
    'message': {
        'contentType': 'PlainText',
        'content': message
    },
    'responseCard': {
    'version': '0',
    'contentType': 'application/vnd.amazonaws.card.generic',
    'genericAttachments': [
        {
        'title': 'title1',
        'subTitle': 'subtitle1',
        'attachmentLinkUrl': 'link_that_will_open_on_click',
        'imageUrl': 'link_of_image_to_display',
        "buttons":[ 
             {
                "text":"button_1",
                "value":"value_to_be_sent_to_server_on_click"
             },
             {
                "text":"button_2",
                "value":"value_to_be_sent_to_server_on_click"
             },
             {
                "text":"button_3",
                "value":"value_to_be_sent_to_server_on_click"
             }
            ]
        },
        {
        'title': 'title2',
        'subTitle': 'subtitle2',
        'attachmentLinkUrl': 'link_that_will_open_on_click',
        'imageUrl': 'link_of_image_to_display',
        "buttons":[ 
             {
                "text":"button_1",
                "value":"value_to_be_sent_to_server_on_click"
             },
             {
                "text":"button_2",
                "value":"value_to_be_sent_to_server_on_click"
             },
             {
                "text":"button_3",
                "value":"value_to_be_sent_to_server_on_click"
             }
            ]
        },
        {
        'title': 'title3',
        'subTitle': 'subtitle3',
        'attachmentLinkUrl': 'link_that_will_open_on_click',
        'imageUrl': 'link_of_image_to_display',
        "buttons":[ 
             {
                "text":"button_1",
                "value":"value_to_be_sent_to_server_on_click"
             },
             {
                "text":"button_2",
                "value":"value_to_be_sent_to_server_on_click"
             },
             {
                "text":"button_3",
                "value":"value_to_be_sent_to_server_on_click"
             }
            ]
        }
    ]

    }
}

NOTE 1: You can have maximum of 10 response cards in the carousel, and maximum of 3 buttons in a single carousel. If you have more than 10 cards, you will get error. If you have more than 3 buttons, you won't get error but only first 3 will be shown.
NOTE 2: You need to check messaging_postbacks events in the Webhooks in messenger settings in the Facebook app to make buttons of carousel work.

I have implemented response cards in below manner:


See cards are coming like carousel, you can swipe to see more cards.

Hope it helps.

这篇关于在 AWS Lex 中创建轮播卡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆