isdaviddong
9/26/2017 - 6:27 AM

VB版 push template message

VB版 push template message


        '建立Bot instance
        Dim bot As New isRock.LineBot.Bot(Token)
        '傳入Channel access token
        '建立actions,作為ButtonTemplate的用戶回覆行為
        Dim actions = New List(Of isRock.LineBot.TemplateActionBase)()
        actions.Add(New isRock.LineBot.MessageActon() With {
          .label = "標題-文字回覆",
           .text = "回覆文字"
        })
        actions.Add(New isRock.LineBot.UriActon() With {
           .label = "標題-開啟URL",
            .uri = New Uri("http://www.google.com")
        })
        actions.Add(New isRock.LineBot.PostbackActon() With {
            .label = "標題-發生postack",
            .data = "abc=aaa&def=111"
        })

        '單一Button Template Message
        '設定圖片
        '設定回覆動作
        Dim ButtonTemplate = New isRock.LineBot.ButtonsTemplate() With {
            .text = "ButtonsTemplate文字訊息",
            .title = "ButtonsTemplate標題",
            .thumbnailImageUrl = New Uri("https://arock.blob.core.windows.net/test3/testimage.png"),
            .actions = actions
        }
        '發送
        bot.PushMessage(ToUserId, ButtonTemplate)