Nâng cấp Customer Service API lên 202309
Ánh xạ
Ánh xạ đường dẫn (path)
| CS API v1.0 (cũ) | CS API v2.0 (mới) |
|---|---|
| [POST]/api/seller/im/send_message | [POST]/customer_service/202309/conversations/:conversation_id/messages |
| [GET]/api/seller/im/customer_service/status | [GET]/customer_service/202309/agents/settings |
| [POST]/api/seller/im/customer_service/status/update | [PUT]/customer_service/202309/agents/settings |
| [POST]/api/seller/im/list_conversations | [GET]/customer_service/202309/conversations |
| [POST]/api/seller/im/get_conversation_messages | [GET]/customer_service/202309/conversations/:conversation_id/messages |
| [POST]/api/seller/im/img/upload | [POST]/customer_service/202309/images/upload |
| [POST]/api/seller/im/mark_read | [POST]/customer_service/202309/conversations/:conversation_id/messages/read |
| [POST]/api/seller/im/create_conversation | [POST]/customer_service/202309/conversations |
Ánh xạ trường (field)
[POST]/api/seller/im/send_message
Đường dẫn mới: [POST]/customer_service/202309/conversations/:conversation_id/messages
Tham số request
| Old | Old type | New | New type | Mô tả |
|---|---|---|---|---|
| conv_short_id | string | conversation_id | string | Chuyển sang biến đường dẫn (path variable) |
| msg_type | string | type | string(enum) | Ánh xạ enum: |
| text->TEXT | ||||
| file_image->IMAGE | ||||
| goods_card->PRODUCT_CARD | ||||
| order_card->ORDER_CARD | ||||
| content | string | content | string | text: |
| cũ: | ||||
| { | ||||
| "content": "simple text" | ||||
| } |
mới: { "content": "simple text" }
file_image: cũ: { "imageHeight": "290", "imageUrl": "https://tosv.boei18n.byted.org/obj/temai-im/FszkJ53nSapYG6KDaJQmqR3jjoZGwww304-290", "imageWidth": "304" }
mới: { "height": 290, "url": "https://tosv.boei18n.byted.org/obj/temai-im/FszkJ53nSapYG6KDaJQmqR3jjoZGwww304-290", "width": 304 }
goods_card: cũ: { "goods_id": "7494560109732334267" }
mới: { "product_id": "7494560109732334267" }
order_card: cũ: { "order_id": "7494560109732334267" }
mới: { "order_id": "7494560109732334267" } |
Response
| Old | Old type | New | New type | Mô tả |
|---|---|---|---|---|
| msg_id | string | message_id | string |
[GET]/api/seller/im/customer_service/status
Đường dẫn mới: [GET]/customer_service/202309/agents/settings
Tham số request
không có
Response
| Old | Old type | New | New type | Mô tả |
|---|---|---|---|---|
| status | int | can_accept_chat | bool | Ánh xạ giá trị: |
| 1->true | ||||
| 0->false | ||||
| 2->false |
Các giá trị cũ 0 và 2 nghĩa là nhân viên customer service sẽ không tiếp nhận chat nào. |
[POST]/api/seller/im/customer_service/status/update
Đường dẫn mới: [PUT]/customer_service/202309/agents/settings
Tham số request
| Old | Old type | New | New type | Mô tả |
|---|---|---|---|---|
| status | int | can_accept_chat | bool | Ánh xạ giá trị: |
| 1->true | ||||
| 0->false |
Response
Không có
[POST]/api/seller/im/list_conversations
Đường dẫn mới: [GET]/customer_service/202309/conversations
Request
| Old | Old type | New | New type | Mô tả |
|---|---|---|---|---|
| cursor | string | page_token | string | |
| limit | int | page_size | int | |
| language | string | locale | string |
Response
| Old | Old type | New | New type | Mô tả |
|---|---|---|---|---|
| next_cursor | string | next_page_token | string | 2 trường cũ được gộp thành 1 trường mới. |
page_token rỗng nghĩa là has_more bằng false. | ||||
| has_more | bool | |||
| conv_with_last_msg | Object[] | conversations | Object[] | |
| conv_with_last_msg[].conv_info.conv_short_id | string | conversations[].id | string | |
| conv_with_last_msg[].conv_info.app_id | int | Deleted | ||
| conv_with_last_msg[].conv_info.member_count | int | conversations[].participant_count | int | |
| conv_with_last_msg[].conv_info.can_send_message | bool | conversations[].can_send_message | bool | |
| conv_with_last_msg[].conv_info.unread_count | int | conversations[].unread_count | int | |
| conv_with_last_msg[].conv_info.participants | Object[] | conversations[].participants | Object[] | |
| conv_with_last_msg[].conv_info.participants[].participant_id | string | conversations[].participants[].im_user_id | string | |
| conv_with_last_msg[].conv_info.participants[].role | int | conversations[].participants[].role | string(enum) | Ánh xạ enum: |
| 1->BUYER | ||||
| 2->SHOP | ||||
| 3->CUSTOMER_SERVICE | ||||
| conv_with_last_msg[].conv_info.participants[].nick | string | conversations[].participants[].nickname | string | |
| conv_with_last_msg[].conv_info.participants[].avatar | string | conversations[].participants[].avatar | string | |
| conv_with_last_msg[].conv_info.participants[].outer_id | string | conversations[].participants[].user_id | string | |
| conv_with_last_msg[].latest_msg | Object | conversations[].latest_message | Object | |
| conv_with_last_msg[].latest_msg.conv_short_id | string | Deleted | ||
| conv_with_last_msg[].latest_msg.msg_id | string | conversations[].latest_message.id | string | |
| Newly added | conversations[].latest_message.sender | Object | ||
| conv_with_last_msg[].latest_msg.sender_id | string | conversations[].latest_message.sender.im_user_id | string | |
| conv_with_last_msg[].latest_msg.sender_role | int | Deleted | ||
| conv_with_last_msg[].latest_msg.sender_role_v2 | int | conversations[].latest_message.sender.role | string(enum) | Ánh xạ enum: |
| 1->BUYER | ||||
| 2->SHOP | ||||
| 3->CUSTOMER_SERVICE | ||||
| 4(deprecated) | ||||
| 5->SYSTEM | ||||
| 6->ROBOT | ||||
| conv_with_last_msg[].latest_msg.sender_nick | string | conversations[].latest_message.sender.nickname | string | |
| conv_with_last_msg[].latest_msg.sender_avatar | string | conversations[].latest_message.sender.avatar | string | |
| conv_with_last_msg[].latest_msg.ref_msg_info | Object | Deleted | ||
| conv_with_last_msg[].latest_msg.msg_type | string(enum) | conversations[].latest_message.type | string(enum) | Ánh xạ enum: |
| text->TEXT | ||||
| file_image->IMAGE | ||||
| allocated_service->ALLOCATED_SERVICE | ||||
| notification->NOTIFICATION | ||||
| use_enter_from_transfer->BUYER_ENTER_FROM_TRANSFER | ||||
| user_enter_from_goods->BUYER_ENTER_FROM_PRODUCT | ||||
| user_enter_from_order->BUYER_ENTER_FROM_ORDER | ||||
| goods_card->PRODUCT_CARD | ||||
| order_card->ORDER_CARD | ||||
| emoticons->EMOTICONS | ||||
| video->VIDEO | ||||
| other->OTHER | ||||
| conv_with_last_msg[].latest_msg.content | string | conversations[].latest_message.content | string | text, allocated_service, notification, user_enter_from_transfer: |
| cũ: | ||||
| { | ||||
| "content": "simple text" | ||||
| } |
mới: { "content": "simple text" }
file_image: cũ: { "imageHeight": "290", "imageUrl": "https://tosv.boei18n.byted.org/obj/temai-im/FszkJ53nSapYG6KDaJQmqR3jjoZGwww304-290", "imageWidth": "304" }
mới: { "height": 290, "url": "https://tosv.boei18n.byted.org/obj/temai-im/FszkJ53nSapYG6KDaJQmqR3jjoZGwww304-290", "width": 304 }
goods_card, user_enter_from_goods: cũ: { "goods_id": "7494560109732334274" }
mới: { "product_id": "7494560109732334274" }
order_card, user_enter_from_orders: cũ: { "order_id": "7494560109732336829" }
mới: { "order_id": "7494560109732336829" }
mới: { "url": "https://v16m-default.akamaized.net/f4d97c4ca9018602e423366c40e9ccec/660fc8a9/video/tos/alisg/tos-alisg-v-2ea863-sg/okIEwc9EIW4OAJyZTiBOc6iIoB4xf3YEoQA2Po", "width": 1920, "height": 960, "duration": "127.254", "vid": "v10394g5000ccnk3m7fog65o44qog4cg", "expire_time": 1712310441, "format": "mp4", "size": 9309252, "bit_rate": 585239, "quality": "original", "codec_type": "h264" } | | conv_with_last_msg[].latest_msg.index_in_conversation | string | Deleted | | | | conv_with_last_msg[].latest_msg.is_visible | bool | conversations[].latest_message.is_visible | bool | | | conv_with_last_msg[].latest_msg.create_time | int | conversations[].latest_message.create_time | int | |
[POST]/api/seller/im/get_conversation_messages
Đường dẫn mới: [GET]/customer_service/202309/conversations/:conversation_id/messages
Tham số request
| Old | Old type | New | New type | Mô tả |
|---|---|---|---|---|
| conv_short_id | string | conversation_id | string | Chuyển sang biến đường dẫn (path variable) |
| pull_direction | int | sort_order | string(enum) | Ánh xạ enum: |
| 0->ASC | ||||
| 1->DESC |
Trong API cũ, tin nhắn luôn được sắp xếp từ cũ nhất đến mới nhất. Trong API mới, tin nhắn sẽ được sắp xếp từ cũ nhất đến mới nhất nếu "sort_order" là "ASC", và từ mới nhất đến cũ nhất nếu "sort_order" là "DESC". | | Newly added | | sort_field | string | Sắp xếp tin nhắn theo Giá trị khả dụng: create_time (mặc định) | | cursor | string | page_token | string | | | limit | int | page_size | int | | | language | string | locale | string | |
Response
| Old | Old type | New | New type | Mô tả |
|---|---|---|---|---|
| next_cursor | string | next_page_token | string | 2 trường cũ được gộp thành 1 trường mới. |
page_token rỗng nghĩa là has_more bằng false. | ||||
| has_more | bool | |||
| unsupport_msg_tips | string | unsupported_msg_tips | string | |
| msgs | Object[] | messages | Object[] | |
| msgs[].conv_short_id | string | Deleted | ||
| msgs[].msg_id | string | messages[].id | string | |
| Newly added | messages[].sender | Object | ||
| msgs[].sender_id | string | messages[].sender.im_user_id | string | |
| msgs[].sender_role | int | Deleted | ||
| msgs[].sender_role_v2 | int | messages[].sender.role | string(enum) | Ánh xạ enum: |
| 1->BUYER | ||||
| 2->SHOP | ||||
| 3->CUSTOMER_SERVICE | ||||
| 4(deprecated) | ||||
| 5->SYSTEM | ||||
| 6->ROBOT | ||||
| msgs[].sender_nick | string | messages[].sender.nickname | string | |
| msgs[].sender_avatar | string | messages[].sender.avatar | string | |
| msgs[].ref_msg_info | Object | Deleted | ||
| msgs[].msg_type | string(enum) | messages[].type | string(enum) | Ánh xạ enum: |
| text->TEXT | ||||
| file_image->IMAGE | ||||
| allocated_service->ALLOCATED_SERVICE | ||||
| notification->NOTIFICATION | ||||
| use_enter_from_transfer->BUYER_ENTER_FROM_TRANSFER | ||||
| user_enter_from_goods->BUYER_ENTER_FROM_PRODUCT | ||||
| user_enter_from_order->BUYER_ENTER_FROM_ORDER | ||||
| goods_card->PRODUCT_CARD | ||||
| order_card->ORDER_CARD | ||||
| emoticons->EMOTICONS | ||||
| video->VIDEO | ||||
| other->OTHER | ||||
| msgs[].content | string | messages[].content | string | text, allocated_service, notification, user_enter_from_transfer: |
| cũ: | ||||
| { | ||||
| "content": "simple text" | ||||
| } |
mới: { "content": "simple text" }
file_image: cũ: { "imageHeight": "290", "imageUrl": "https://tosv.boei18n.byted.org/obj/temai-im/FszkJ53nSapYG6KDaJQmqR3jjoZGwww304-290", "imageWidth": "304" }
mới: { "height": 290, "url": "https://tosv.boei18n.byted.org/obj/temai-im/FszkJ53nSapYG6KDaJQmqR3jjoZGwww304-290", "width": 304 }
goods_card, user_enter_from_goods: cũ: { "goods_id": "7494560175032334583" }
mới: { "product_id": "7494560175032334583" }
order_card, user_enter_from_orders: cũ: { "order_id": "7494560109732337395" }
mới: { "order_id": "7494560109732337395" }
mới: { "url": "https://v16m-default.akamaized.net/f4d97c4ca9018602e423366c40e9ccec/660fc8a9/video/tos/alisg/tos-alisg-v-2ea863-sg/okIEwc9EIW4OAJyZTiBOc6iIoB4xf3YEoQA2Po", "width": 1920, "height": 960, "duration": "127.254", "vid": "v10394g5000ccnk3m7fog65o44qog4cg", "expire_time": 1712310441, "format": "mp4", "size": 9309252, "bit_rate": 585239, "quality": "original", "codec_type": "h264" } | | msgs[].index_in_conversation | string | Deleted | | | | msgs[].is_visible | bool | messages[].is_visible | bool | | | msgs[].create_time | int | messages[].create_time | int | |
[POST]/api/seller/im/img/upload
Đường dẫn mới: [POST]/customer_service/202309/images/upload
Tham số request
| Old | Old type | New | New type | Mô tả |
|---|---|---|---|---|
| data | string | data | binary | Trong API cũ, bạn cần mã hóa hình ảnh thành chuỗi BASE64, sau đó đưa vào body của request dưới dạng JSON. |
Trong API mới, bạn cần đưa dữ liệu nhị phân (binary) của hình ảnh vào body của request, với "Content-Type=multipart/form-data" và một khóa form có tên "data". |
Response
| Old | Old type | New | New type | Mô tả |
|---|---|---|---|---|
| url | string | url | string | |
| width | int | width | int | |
| height | int | height | int |
[POST]/api/seller/im/mark_read
Đường dẫn mới: [POST]/customer_service/202309/conversations/:conversation_id/messages/read
Tham số request
| Old | Old type | New | New type | Mô tả |
|---|---|---|---|---|
| conv_short_id | string | conversation_id | string | Chuyển sang biến đường dẫn (path variable). |
Response
Không có
[POST]/api/seller/im/create_conversation
Đường dẫn mới: [POST]/customer_service/202309/conversations
Tham số request
| Old | Old type | New | New type | Mô tả |
|---|---|---|---|---|
| buyer_id | string | buyer_user_id | string |
Response
| Old | Old type | New | New type | Mô tả |
|---|---|---|---|---|
| conv_short_id | string | conversation_id | string |
Webhook
Ánh xạ loại (type)
| Sự kiện | Old type | New type |
|---|---|---|
| New conversation | 8 | 13 |
| New messages | 9 | 14 |
Ánh xạ trường (field)
New Conversation
| Old | Old type | New | New type | Mô tả |
|---|---|---|---|---|
| conv_short_id | string | conversation_id | string | |
| create_time | int | create_time | int |
New Messages
| Old | Old type | New | New type | Mô tả |
|---|---|---|---|---|
| message_id | string | message_id | string | |
| conv_short_id | string | conversation_id | string | |
| content | string | content | string | text, allocated_service, notification, user_enter_from_transfer: |
| cũ: | ||||
| { | ||||
| "content": "simple text" | ||||
| } |
mới: { "content": "simple text" }
file_image: cũ: { "imageHeight": "290", "imageUrl": "https://tosv.boei18n.byted.org/obj/temai-im/FszkJ53nSapYG6KDaJQmqR3jjoZGwww304-290", "imageWidth": "304" }
mới: { "height": 290, "url": "https://tosv.boei18n.byted.org/obj/temai-im/FszkJ53nSapYG6KDaJQmqR3jjoZGwww304-290", "width": 304 }
goods_card, user_enter_from_goods: cũ: { "goods_id": "7494560175032334583" }
mới: { "product_id": "7494560175032334583" }
order_card, user_enter_from_orders: cũ: { "order_id": "7494560109732337395" }
mới: { "order_id": "7494560109732337395" }
mới: { "url": "https://v16m-default.akamaized.net/f4d97c4ca9018602e423366c40e9ccec/660fc8a9/video/tos/alisg/tos-alisg-v-2ea863-sg/okIEwc9EIW4OAJyZTiBOc6iIoB4xf3YEoQA2Po", "width": 1920, "height": 960, "duration": "127.254", "vid": "v10394g5000ccnk3m7fog65o44qog4cg", "expire_time": 1712310441, "format": "mp4", "size": 9309252, "bit_rate": 585239, "quality": "original", "codec_type": "h264" } | | is_visible | bool | is_visible | bool | | | msg_type | string | type | string(enum) | Ánh xạ enum: text->TEXT file_image->IMAGE allocated_service->ALLOCATED_SERVICE notification->NOTIFICATION use_enter_from_transfer->BUYER_ENTER_FROM_TRANSFER user_enter_from_goods->BUYER_ENTER_FROM_PRODUCT user_enter_from_order->BUYER_ENTER_FROM_ORDER goods_card->PRODUCT_CARD order_card->ORDER_CARD emoticons->EMOTICONS video->VIDEO other->OTHER | | Newly added | | sender | Object | | | sender_id | string | sender.im_user_id | string | | | sender_role | int | Deleted | | | | sender_role_v2 | int | sender.role | string(enum) | Ánh xạ enum: 1->BUYER 2->SHOP 3->CUSTOMER_SERVICE 4(deprecated) 5->SYSTEM 6->ROBOT | | create_time | int | create_time | int | |