iT邦幫忙

2021 iThome 鐵人賽

DAY 18
0
Software Development

LINE機器人學習歷程系列 第 18

[DAY18]旋轉木馬(01)

  • 分享至 

  • xImage
  •  

TemplateSendMessage - CarouselTemplate

carousel_template_message = TemplateSendMessage(
    alt_text='Carousel template',
    template=CarouselTemplate(
最多只能有10個欄位
        columns=[
            CarouselColumn(
                thumbnail_image_url='https://example.com/item1.jpg',
                title='this is menu1',
                text='description1',
                actions=[
                    PostbackAction(
                        label='postback1',
                        display_text='postback text1',
                        data='action=buy&itemid=1'
                    ),
                    MessageAction(
                        label='message1',
                        text='message text1'
                    ),
                    URIAction(
                        label='uri1',
                        uri='http://example.com/1'
                    )
                ]
            ),
            CarouselColumn(
                thumbnail_image_url='https://example.com/item2.jpg',
                title='this is menu2',
                text='description2',
                actions=[
                    PostbackAction(
                        label='postback2',
                        display_text='postback text2',
                        data='action=buy&itemid=2'
                    ),
                    MessageAction(
                        label='message2',
                        text='message text2'
                    ),
                    URIAction(
                        label='uri2',
                        uri='http://example.com/2'
                    )
                ]
            )
        ]
    )
)

Template with multiple columns which can be cycled like a carousel. The columns are shown in order when scrolling horizontally.

type
String Required
carousel

columns
Array of column objects Required
Array of columns
Max columns: 10
圖片的比例默認為square
imageAspectRatio
String Optional
Aspect ratio of the image.
One of:
rectangle: 1.51:1
square: 1:1
Applies to all columns. Default: rectangle
圖片大小默認是cover
imageSize
String Optional
Size of the image.
One of:
圖像填滿整個圖像區域。
cover: The image fills the entire image area. Parts of the image that do not fit in the area are not displayed.
整個圖像顯示在圖像區域中。
contain: The entire image is displayed in the image area. A background is displayed in the unused areas to the left and right of vertical images and in the areas above and below horizontal images.
Applies to all columns. Default: cover.
以上是圖片的解釋明天再講欄位


上一篇
[DAY17]模板確認
下一篇
[DAY19]旋轉木馬(02)
系列文
LINE機器人學習歷程30
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言