用戶訊息
本教學將說明如何透過 API 來取得一個機器人下的用戶訊息紀錄。
get
https://api.botbonnie.com
/v1/api/message/history
Get Message history
Name | Type | Description |
res | Object | |
status | Number | HTTP Status |
Name | Type | Description |
messages | Array[Message] | |
desc | Boolean | 是否為降冪排序 |
Name | Type | Description |
category | String | 紀錄分類 |
type | String | 紀錄類型 |
data | Object | |
timestamp | Integer | 紀錄發生時間,13 碼 timestamp |
operatorId | Number | 回覆的操作者 ID,只有在後台即時訊息單獨回覆使用者時才會存在 |
senderId | Number | 使用者 ID |
Name | Type | Description |
type | String | 訊息類型 |
text | String | 訊息文字 |
payload | String | 訊息內容 |
quickReplies | Array[quickReply] | |
buttons | Array[button] | |
link | String | url |
cards | Array[card] |
Name | Type | Description |
title | String | 按鈕文字 |
type | String | 按鈕類型 |
Name | Type | Description |
title | String | 按鈕文字 |
type | String | 按鈕類型 |
Name | Type | Description |
title | String | 標題 |
subtitle | String | 描述文字 |
imageUrl | String | 圖片網址 |
imageClickShortUrl | String | 圖片點擊的縮址 url |
imageClickOrignUrl | String | 圖片點擊設定的 url |
buttons | Array[button] |
使用者行為的紀錄類別包含 click, text, image, video, audio, file, sticker, follow, unfollow, open_url
reply 則為機器人回覆紀錄,push 為推播紀錄
reply/push 會包含的訊息種類有 text, image, video, audio, gallery (輪播訊息), imagemap (圖文訊息)
為使用者點擊按鈕時產生的事件紀錄
{
"category": "conversation",
"type": "click",
"timestamp": 1623046482461,
"senderId": "xxxxxxx",
"data": {
"type": "click",
"title": "被點擊的按鈕文字"
}
}
使用者發送文字訊息時的事件紀錄
{
"category": "conversation",
"type": "text",
"timestamp": 1623907684961,
"senderId": "xxxxxxx",
"data": {
"type": "text",
"payload": "使用者輸入的文字"
}
}
使用者傳送圖片影片音訊檔案的類型的訊息時的事件紀錄
{
"category": "conversation",
"type": "audio/video/image/file",
"timestamp": 1623907089811,
"senderId": "xxxxxx",
"data": {
"type": "audio/video/image/file",
"payload": "xxxxxx" // content message id
},
"mid": "14239393100682"
}
使用者傳送貼圖訊息時的事件紀錄
{
"category": "conversation",
"type": "sticker",
"timestamp": 1615965080838,
"senderId": "xxxxxx",
"data": {
"type": "sticker",
"payload": {
"packageId": "xxxx",
"stickerId": "xxxxxx"
}
}
}
使用者追蹤官方帳號或封鎖時的事件紀錄
{
"category": "system",
"type": "follow/unfollow",
"timestamp": 1622626402433
}
使用者開啟 url 時的事件紀錄
{
"category": "system",
"type": "open_url",
"timestamp": 1620206520431,
"data": {
"type": "open_url",
"link": "https://www.botbonnie.com"
}
}
回覆文字訊息的紀錄
{
"category": "conversation",
"type": "reply/push",
"data": {
"quickReplies": [
{
"title": "快速回覆",
"type": "text",
"payload": "{\"fm\":\"module-xxxxxx\",\"to\":\"module-xxxxx\",\"id\":\"qr_0\",\"bid\":\"bot-xxxxxxx\",\"bv\":\"PROD\",\"ti\":\"快速回覆\"}"
}
],
"type": "text",
"text": "文字訊息內容"
},
"timestamp": 1622198735278,
"mid": "0_0_92d674b9-cdd0-4357-a8de-dd6b58d9b021",
"operatorId": "xxxxxxx"
}
回覆影像/影片/音訊的訊息紀錄
{
"category": "conversation",
"type": "reply",
"data": {
"type": "video",
"videoUrl": "https://xxxxxxx", // exist in video
"imageUrl": "https://xxxxxxx", // exist in image
"audioUrl": "https://xxxxxxx" // exist in audio
},
"timestamp": 1623907690653,
"mid": "3_3_857803a6-de80-4def-a2e3-56134db79b1f"
}
回覆圖 文訊息的紀錄
{
"category": "conversation",
"type": "reply",
"data": {
"baseUrl": "https://xxxxx", //image
"quickReplies": [],
"buttons": [
{
"area": {
"x": 0,
"width": 1040,
"y": 0,
"height": 1040
},
"type": "web_url",
"value": "https://xxxxxx",
"shortUrl": "https://xxxxxxxxxxx",
"originUrl": "https://xxxxxxxx"
}
],
"size": {
"width": 1040,
"height": 1040
},
"text": "圖文訊息",
"type": "imagemap"
},
"timestamp": 1623915747419,
"mid": "4_4_00a3323f-4a1e-4d3a-a8ec-593969091c4a"
}
回覆輪播訊息的紀錄
{
"category": "conversation",
"type": "reply",
"data": {
"cards": [
{
"imageClickShortUrl": "https://xxxxxx",
"buttons": [],
"imageClickUrl": "https://xxxxxx",
"subtitle": "描述",
"imageUrl": "https://xxxxx",
"title": "卡片 1 標題",
"imageClickOriginUrl": "https://xxxxxx"
},
{
"imageClickShortUrl": "https://xxxxxx",
"buttons": [],
"imageClickUrl": "https://xxxxxx",
"subtitle": "描述",
"imageUrl": "https://xxxxx",
"title": "卡片 2 標題",
"imageClickOriginUrl": "https://xxxxxx"
}
],
"type": "gallery",
"imageStyle": "horizontal"
},
"timestamp": 1623907690652,
"mid": "2_2_857803a6-de80-4def-a2e3-56134db79b1f"
}
Last modified 2yr ago