iT邦幫忙

2021 iThome 鐵人賽

DAY 16
0

TemplateSendMessage - ButtonsTemplate

buttons_template_message = TemplateSendMessage(
    alt_text='Buttons template',
    template=ButtonsTemplate(
        按鈕上方的圖片
        thumbnail_image_url='https://example.com/image.jpg',
        粗體字
        title='Menu',
        解釋此按鈕的目的
        text='Please select',
        actions=[
        按鈕的三種類型,控制使用者說出我們開發者希望其說出的話
            PostbackAction(
                label='postback',
                display_text='postback text',
                data='action=buy&itemid=1'
            ),
        讓機器人回復開發者希望機器人回復的訊息
            MessageAction(
                label='message',
                text='message text'
            ),
        按下去後到開發者希望使用者抵達的網站
            URIAction(
                label='uri',
                uri='http://example.com/'
            )
        ]
    )
)

Template with an image, title, text, and multiple action buttons.

type
String Required
buttons
圖片、標題是可以選擇是否要放
thumbnailImageUrl
String Optional
Image URL (Max character limit: 2,000)
HTTPS over TLS 1.2 or later
JPEG or PNG
Max width: 1024px
Max file size: 10 MB

imageAspectRatio
String Optional
Aspect ratio of the image. One of:

rectangle: 1.51:1
square: 1:1
Default: rectangle

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.
Default: cover

imageBackgroundColor
String Optional
Background color of the image. Specify a RGB color value. Default: #FFFFFF (white)

title
String Optional
Title
Max character limit: 40

text
String Required
Message text
Max character limit: 160 (no image or title)
Max character limit: 60 (message with an image or title)
當主體被按後的動作
defaultAction
Action object Optional
Action when image, title or text area is tapped.
按鈕最多只能有4個
actions
Array of action objects Required
Action when tapped
Max objects: 4
下圖基本上就是用Maso老師給的檔案,基本沒有更改
https://ithelp.ithome.com.tw/upload/images/20210930/20140159ymtUJCkKbL.png


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

尚未有邦友留言

立即登入留言