接收私信消息事件收藏我的收藏
收藏
我的收藏概述
需要申请权限:
- ◦通过小程序试运营期后自动开通权限
- ◦在开发者后台-设置-关联设置-抖音号管理为小程序经营者申请小程序私信能力
接收私信消息事件包括事件如下:
事件名 | 事件介绍 |
im_receive_msg | 接收私信,用户收到私信触发 |
im_send_msg | 发送私信,用户发送私信触发 |
使用限制
针对用户在会话中发送的本地图片、视频(msg_type 对应 user_local_image, user_local_video),支持通过获取消息中的多媒体资源接口,获取具体的 URL。
事件参数
参数 | | | 类型 | 含义 |
event | | | string | 事件名,唯一标识
|
from_user_id | | | string | 发送方 open_id |
to_user_id | | | string | 接收方 open_id |
client_key | | | string | 开发者唯一标识 |
log_id | | | string | 事件推送log_id,用于抖音内部排查问题使用 |
content | | | struct | 具体内容,类型:结构体 |
| conversation_short_id | | string | 会话 ID |
| server_message_id | | string | 消息 ID |
| conversation_type | | int | 会话类型(1:私聊) |
| message_type | | string | 消息类型(不同类型消息参数见下方介绍)
|
| source | | string | 区分发出应用
|
| create_time | | int | 消息创建时间,13位毫秒时间戳 |
| user_infos | | list<struct> | 用户基本信息,包括:昵称和头像 |
| | open_id | string | 用户 open_id |
| | nick_name | string | 昵称 |
| | avatar | string | 头像链接 |
文本消息
{ "event": "im_receive_msg", "client_key": "asdfavetgbvasf", "from_user_id": "ac6479a5-d7a6-4018-84be-c29bfc00000", "to_user_id": "aaa-7ae0-4399-914a-5eb1df5861ba", "log_id":"2023429834752345783", "content": { "conversation_short_id": "@c29bfc000+MNggFhRkwGuX1ntuc0QfA0VnmRejrzWUBwDdDYrU9MpJSYEVV6/2hKU0il5iay8J99+0t5j3zrbA==", "server_message_id": "@c29bfc000+MNggFhRkwGuX1ntuc0RPc0VHKefj/yWEJ8DtjUrU9MpJSYEVV6/2hKrOcqY1gIxctCXW23v4oW/Q==", "conversation_type": 2, "create_time": 1656571939562, "message_type": "text", "text": "你好,抖音" } }
参数 | 含义 |
message_type | 消息类型,text |
text | 消息文本 |
表情消息
{ "event": "im_receive_msg", "client_key": "asdfavetgbvasf", "from_user_id": "eeb0ea9b-bed4-4b70-913d-c29bfc00000", "to_user_id": "aaa-7ae0-4399-914a-5eb1df5861ba", "content": { "conversation_short_id": "@c29bfc000+MNggFhRkwGuX1ntucyQ/A1Wn+VfTX3Vk9xDdDQrU9MpJSYEVV6/2hK6gbUC8gjaV/y3CS18WtfMw==", "server_message_id": "@c29bfc000+MNggFhRkwGuX1ntuc1RPw2VXmSfjn/VE9zCtHSrU9MpJSYEVV6/2hKk8cLQDaYzbQpImhvw1Y4FQ==", "conversation_type": 1, "create_time": 1656671771668, "message_type": "emoji", "resource_type": "gif", "resource_width": 450, "resource_height": 450, "resource_url": "" } }
参数 | 含义 |
message_type | 消息类型,emoji:表情消息 |
resource_type | 资源类型 |
resource_height | 资源高度 |
resource_width | 资源宽度 |
resource_url | 资源链接 |
图片消息
{ "event": "im_receive_msg", "client_key": "asdfavetgbvasf", "from_user_id": "ac6479a5-d7a6-4018-84be-c29bfc00000", "to_user_id": "8067f050-f8cf-4fa3-9357-c29bfc00000", "content": { "conversation_short_id": "@c29bfc000+MNggFhRkwGuX1ntuc0QfA0VnmRejrzWUBwDdDYrU9MpJSYEVV6/2hKU0il5iay8J99+0t5j3zrbA==", "server_message_id": "@c29bfc000+MNggFhRkwGuX1ntuc0RPc0VHKefj/yWEJ8DtjUrU9MpJSYEVV6/2hKrOcqY1gIxctCXW23v4oW/Q==", "conversation_type": 1, "create_time": 1656571939562, "message_type": "image" } }
参数 | 含义 |
message_type | 消息类型,image:图片消息 |
本地图片消息
{ "event": "im_receive_msg", "client_key": "asdfavetgbvasf", "from_user_id": "ac6479a5-d7a6-4018-84be-c29bfc00000", "to_user_id": "8067f050-f8cf-4fa3-9357-c29bfc00000", "content": { "conversation_short_id": "@c29bfc000+MNggFhRkwGuX1ntuc0QfA0VnmRejrzWUBwDdDYrU9MpJSYEVV6/2hKU0il5iay8J99+0t5j3zrbA==", "server_message_id": "@c29bfc000+MNggFhRkwGuX1ntuc0RPc0VHKefj/yWEJ8DtjUrU9MpJSYEVV6/2hKrOcqY1gIxctCXW23v4oW/Q==", "conversation_type": 1, "create_time": 1656571939562, "message_type": "user_local_image" } }
参数 | 含义 |
message_type | 消息类型,user_local_image 用户本地图片消息,即通过抖音端内聊天页 -> + -> 相册路径发送的图片 |
视频分享消息
{ "event": "im_receive_msg", "client_key": "asdfavetgbvasf", "from_user_id": "eeb0ea9b-bed4-4b70-913d-c29bfc00000", "to_user_id": "8067f050-f8cf-4fa3-9357-c29bfc00000", "content": { "conversation_short_id": "@c29bfc000+MNggFhRkwGuX1ntucyQ/A1Wn+VfTX3Vk9xDdDQrU9MpJSYEVV6/2hK6gbUC8gjaV/y3CS18WtfMw==", "server_message_id": "@c29bfc000+MNggFhRkwGuX1ntuc1RPw2VXmSfjn/VE9zCtHSrU9MpJSYEVV6/2hKk8cLQDaYzbQpImhvw1Y4FQ==", "conversation_type": 1, "create_time": 1656671771668, "message_type": "video", "item_id": "@72NwHyW53+MNggFhRkwGuX1ntuc2RfUyVnKfdTzwU0F0CtjUrU9MpJSYEVV6/2hKy3NMVbBhh6BW27IsDFieLg==" } }
参数 | 含义 |
message_type | 消息类型,video:视频分享消息 |
item_id | 加密后的视频ID |
本地视频消息
{ "event": "im_receive_msg", "client_key": "asdfavetgbvasf", "from_user_id": "ac6479a5-d7a6-4018-84be-c29bfc00000", "to_user_id": "8067f050-f8cf-4fa3-9357-c29bfc00000", "content": { "conversation_short_id": "@c29bfc000+MNggFhRkwGuX1ntuc0QfA0VnmRejrzWUBwDdDYrU9MpJSYEVV6/2hKU0il5iay8J99+0t5j3zrbA==", "server_message_id": "@c29bfc000+MNggFhRkwGuX1ntuc0RPc0VHKefj/yWEJ8DtjUrU9MpJSYEVV6/2hKrOcqY1gIxctCXW23v4oW/Q==", "conversation_type": 1, "create_time": 1656571939562, "message_type": "user_local_video" } }
参数 | 含义 |
message_type | 消息类型,user_local_video:用户本地图片消息 通过抖音端内聊天页 -> + -> 相册路径发送的视频 |
留资卡片消息(包含空白态和完成态)
空白态
{ "event": "im_receive_msg", "client_key": "asdfavetgbvasf", "from_user_id": "ac6479a5-d7a6-4018-84be-c29bfc00000", "to_user_id": "8067f050-f8cf-4fa3-9357-c29bfc00000", "content": { "conversation_short_id": "@c29bfc000+MNggFhRkwGuX1ntuc0QfA0VnmRejrzWUBwDdDYrU9MpJSYEVV6/2hKU0il5iay8J99+0t5j3zrbA==", "server_message_id": "@c29bfc000+MNggFhRkwGuX1ntuc0RPc0VHKefj/yWEJ8DtjUrU9MpJSYEVV6/2hKrOcqY1gIxctCXW23v4oW/Q==", "conversation_type": 1, "create_time": 1656571939562, "message_type": "retain_consult_card", "card_id": "@72MqAjfymKYS1xNrB0sG4X1iidgOeMsMbUSpQwLJb3kYzJh7eXsSr5+aH2GTsvEv", "card_status": 1 //1:空白态;2:完成态 } }
完成态
{ "event": "im_receive_msg", "client_key": "asdfavetgbvasf", "from_user_id": "ac6479a5-d7a6-4018-84be-c29bfc00000", "to_user_id": "8067f050-f8cf-4fa3-9357-c29bfc00000", "content": { "conversation_short_id": "@c29bfc000+MNggFhRkwGuX1ntuc0QfA0VnmRejrzWUBwDdDYrU9MpJSYEVV6/2hKU0il5iay8J99+0t5j3zrbA==", "server_message_id": "@c29bfc000+MNggFhRkwGuX1ntuc0RPc0VHKefj/yWEJ8DtjUrU9MpJSYEVV6/2hKrOcqY1gIxctCXW23v4oW/Q==", "conversation_type": 1, "create_time": 1656571939562, "message_type": "retain_consult_card", "card_id": "@72MqAjfymKYS1xNrB0sG4X1iidgOeMsMbUSpQwLJb3kYzJh7eXsSr5+aH2GTsvEv", "card_status": 2, //1:空白态;2:完成态 "card_data": [ { "label": "姓名", "value": "Tonality" }, { "label": "手机号", "value": "12345678901" }, { "label": "城市", "value": "北京市北京市海淀区" } ] } }
参数 | 含义 |
message_type | 消息类型,retain_consult_card:留资卡片消息 |
其他消息
{ "event": "im_receive_msg", "client_key": "asdfavetgbvasf", "from_user_id": "ac6479a5-d7a6-4018-84be-c29bfc00000", "to_user_id": "8067f050-f8cf-4fa3-9357-c29bfc00000", "content": { "conversation_short_id": "@c29bfc000+MNggFhRkwGuX1ntuc0QfA0VnmRejrzWUBwDdDYrU9MpJSYEVV6/2hKU0il5iay8J99+0t5j3zrbA==", "server_message_id": "@c29bfc000+MNggFhRkwGuX1ntuc0RPc0VHKefj/yWEJ8DtjUrU9MpJSYEVV6/2hKrOcqY1gIxctCXW23v4oW/Q==", "conversation_type": 1, "create_time": 1656571939562, "message_type": "other", "text": "你收到一条新消息,请打开抖音app查看" } }
参数 | 含义 |
message_type | 消息类型,other:其他消息 |
事件参数示例
{ "event": "im_receive_msg", "client_key": "asdfavetgbvasf", "from_user_id": "aaa-ae9b-4dbf-add1-bf67e4093fab", "to_user_id": "aaa-7ae0-4399-914a-5eb1df5861ba", "content": { "conversation_short_id": "@9Vxc1/yDU8sqaS+gN4koEc7912foPPiLPZVyrQmgKVQabPH460zdRmYqig357zEBMaXjKvvhvwY02ISB7llsWQ==", "server_message_id": "@9Vxc1/yDU8sqaS+gN4koEc7912foPPyAPpF2rgykLFgbafb560zdRmYqig357zEBmWXVPshhwyd/y/7BQpXy/w==", "conversation_type": 1, "create_time": 1681303285997, "message_type": "text", "source": "", "text": "捷途70", "user_infos": [ { "open_id": "aaa-ae9b-4dbf-add1-bf67e4093fab", "nick_name": "刘东", "avatar": "https://p3.douyinpic.com/aweme/720x720/xxxxx-avatar/mosaic-legacy_3795_3047680722.jpeg?from=3782654143" }, { "open_id": "aaa-7ae0-4399-914a-5eb1df5861ba", "nick_name": "毕节--捷途万丰店", "avatar": "https://p3.douyinpic.com/aweme/720x720/xxxxxx-avatar/tos-cn-avt-0015_6c9ae9afb4e62e2263f98809e3dc5b6a.jpeg?from=3782654143" } ] } }