AI LINE Bot練功坊-L7 Message Type (1)
Message Type
- Text Message 文字訊息
- Sticker Message 貼圖訊息
- Image Message 圖片訊息
- Video Message 影片訊息
- Audio Message 音訊訊息
- Location Message 地點訊息
- Imagemap Message 圖片地圖訊息
- Template Message 模板訊息
- Flex Message 彈性訊息
後面的課程再仔細介紹Imagemap Message、Template Message、Flex Message
匯入函式庫
1. Text message 文字訊息
最基本的Message API類型之一,只傳遞文字。
規則:
- Unicode 表情符號
- Line 表情符號
- 最多5000字
程式碼:
透過TextMessage(text="這是文字訊息")把特定文字傳入聊天室。
可以加入表情符號
emoji 對應的編號 : https://developers.line.biz/en/docs/messaging-api/emoji-list/#line-emoji-definitions
效果展示:
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 →
Reference:https://developers.line.biz/en/docs/messaging-api/message-types/#text-messages
2. Sticker message 貼圖訊息
最基本的Message API類型之一,只傳遞貼圖。
規則:
- 輸入貼圖的ID
程式碼:
package_id是貼圖包的編號,sticker_id是特定貼圖的編號。
連結是Line官方提供的貼圖包和特定貼圖的id,可以查詢想用的貼圖使用:
https://developers.line.biz/en/docs/messaging-api/sticker-list/#sticker-definitions
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 Developer官方網站
效果展示:
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 →
Reference: https://developers.line.biz/en/docs/messaging-api/message-types/#sticker-messages
3. Image message 圖片訊息
最基本的Message API類型之一,只傳遞圖片。
規則:
- 圖片 URL (最多字數: 2000)
- 前綴為HTTPS
- 圖片格式: JPEG 或 PNG
- 圖片檔案大小: 10 MB以內
程式碼:
original_content_url=url是要傳送的圖片的位置, preview_image_url=url是預覽圖片的位置。
效果展示:
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 →
url要提供想要傳送的圖片的位置,可以使用本地端的圖片或網路上的圖:
3-1 網路圖片
輸入圖片網址,例如:
url = "https://example.com/original.jpg"
3-2 本地圖片
抓取本地圖片到架設好的伺服器上。
Reference: https://developers.line.biz/en/docs/messaging-api/message-types/#image-messages
4. Video message 影片訊息
最基本的Message API類型之一,只傳遞影片。
規則:
- 影片 URL (最多字數: 2000)
- 前綴為HTTPS
- 影片格式: mp4
- 影片檔案大小: 200 MB以內
程式碼:
影片的程式內容和圖片相似,可參考<3. Image message 圖片訊息>
效果展示:
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 →
Reference: https://developers.line.biz/en/docs/messaging-api/message-types/#video-messages
5. Audio message 音訊訊息
最基本的Message API類型之一,只傳遞音訊。
規則:
- 音訊 URL (最多字數: 2000)
- 前綴為HTTPS
- 音訊格式: mp3 或 m4a
- 音訊檔案大小: 200 MB
程式碼:
音訊的程式內容和圖片相似,可參考<3. Image message 圖片訊息>
效果展示:
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 →
Reference: https://developers.line.biz/en/docs/messaging-api/message-types/#audio-messages
6. Location message 地點訊息
最基本的Message API類型之一,只傳遞地點。
規則:
- latitude、longitude,最多字數各100字
程式碼:
title是位置訊息的標題, address放你想說明的位置,latitude、longitude是位置的座標。
效果展示:

Reference: https://developers.line.biz/en/docs/messaging-api/message-types/#location-messages
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官方帳號
相關教材連結