AI LINE Bot練功坊-L5 Webhook Event Type
Webhook Event
常見的通用基本屬性
- type : 識別事件的類型
- mode : channel的狀態
- timestamp : 事件發生的時間(以毫秒為單位)
- source : 包含有關事件來源的資訊
- webhookeventID : 標示webhook event的ID
- deliveryContext.isRedelivery : Webhook event是否是重新傳遞的event。
Reference:https://developers.line.biz/en/reference/messaging-api/#common-properties
Webhook Event的類型
基本的Webhook Event有以下幾種
Webhook Event |
說明 |
一對一聊天室 |
群組聊天室 |
Message event |
表示使用者發送一則訊息(可以回覆的事件) |
✔ |
✔ |
Unsend event |
表示使用者收回一則訊息 |
✔ |
✔ |
Follow event |
表示你的Line官方帳號被加入好友或者是解除封鎖(可以回覆的事件) |
✔ |
❌ |
Unfollow event |
表示你的Line官方帳號被封鎖或被刪除好友 |
✔ |
❌ |
Join event |
表示你的帳號被加入群組(可以回覆的事件) |
❌ |
✔ |
Leave event |
表示你的帳號被從群組中移除 |
❌ |
✔ |
Member join event |
在您的帳號存在的群組中有人加入的事件(可以回覆的事件) |
❌ |
✔ |
Member leave event |
在您的帳號存在的群組中有人退出的事件 |
❌ |
✔ |
Postback event |
配合Postback action的訊息事件(可以回覆的事件) |
✔ |
✔ |
Video viewing complete event |
用戶觀看完從LINE官方帳號發送的指定TrackingId的影片訊息(可以回覆的事件) |
✔ |
❌ |
✔ Your bot server receives this event ❌ Your bot server doesn't receive this event
Reference : https://developers.line.biz/en/docs/messaging-api/receiving-messages/#webhook-event-in-one-on-one-talk-or-group-chat
Message Event
表示使用者發送一則訊息,官方帳號可以根據這則訊息進行應對的回覆
Message Object包括以下幾種 :
- Text
- Image
- Video
- Audio
- File
- Location
- Sticker
引用套件
程式碼
message的type(指要接收到的的訊息類型)有:
- TextMessageContent
- LocationMessageContent
- StickerMessageContent
- ImageMessageContent
- VideoMessageContent
- AudioMessageContent
- FileMessageContent
Reference : https://developers.line.biz/en/reference/messaging-api/#message-event
Follow Event
表示你的Line官方帳號被加入好友或者是解除封鎖
引用套件
程式碼
加入好友後會傳送一則"Got Follow Event"的訊息
Reference : https://developers.line.biz/en/reference/messaging-api/#follow-event
Postback Event
配合Postback action的訊息事件
當有action type為postback發生時,則會透過messaging API回傳event給Webhook URL
引用套件
程式碼
觸發postback action的前置作業(建立一個選單訊息)
其中action有下列幾種 :
- MessageAction
- URIAction
- PostbackAction
- DatetimePickerAction
- CameraAction
- CameraRollAction
- LocationAction
程式碼
觸發action後的動作
按下名為Postback Action的按鈕後,回應一個postback action且值為"postback"
當postback action傳送的值為"postback"時,會回覆一則訊息"Postback Action Button Clicked!"
在伺服器則會輸出一段訊息"Postback event is triggered"
Reference:https://developers.line.biz/en/reference/messaging-api/#postback-event
Youtube 課程影片
關於我們
國立臺北教育大學 教育大數據微學程
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
Facebook
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
Instagram
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
Threads
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
YouTube
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
Line官方帳號
相關教材連結