群消息 Webhook

收藏
我的收藏

概述

Webhooks 说明文档可参考:Webhooks 概述
需要申请权限
    开发者后台-设置-关联设置-抖音号管理为小程序经营者申请粉丝群管理能力
接收群消息事件如下:​
事件名​
事件介绍​
im_group_receive_msg​
接收群消息事件,用户接收到群消息触发​
im_group_send_msg​
发送群消息事件,用户发送群消息触发​

使用限制​

    图片消息和视频分享消息不返回具体 URL,需到抖音端内 APP 内查看​
    目前只开放给粉丝群​

事件参数​

参数​
类型​
含义​
event​
string​
事件名,唯一标识​
    接收到的群消息:im_group_receive_msg​
    发送出去的群消息:im_group_send_msg​
from_user_id​
string​
发送方 open_id​
to_user_id​
string​
接收方 open_id​
client_key​
string​
开发者唯一标识​
content​
struct​
具体内容,类型:结构体​
conversation_short_id​
string​
群 ID,群唯一标识​
server_message_id​
string​
消息 ID​
conversation_type​
int​
会话类型(2:群聊)​
message_type​
string​
消息类型(不同类型消息参数见下方介绍)​
    text:文本​
    image:图片​
    emoji:表情​
    video:视频​
    retain_consult_card​
    other:其他 不同类型消息参数见下方介绍​
source​
string​
区分发出应用​
    通过发送群消息接口发送,会显示具体的 clientkey​
    通过端上主动发送,该字段默认为空​
scene_type​
int​
场景类型​
    1:关键词自动回复​
    2: 欢迎语​
    100:其他​
create_time​
int​
消息创建时间,13位毫秒时间戳​
user_infos​
list<struct>​
用户基本信息,包括:昵称和头像​
open_id​
string​
用户 open_id​
nick_name​
string​
昵称​
avatar​
string​
头像链接​
owner_id​
int​
群主ID​

文本消息​

{ "event": "im_group_receive_msg", "client_key": "asdfavetgbvasf", "from_user_id": "ac6479a5-d7a6-4018-84be-c29bfc00000", "to_user_id": "aaa-7ae0-4399-914a-5eb1df5861ba", "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_group_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": 2, "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_group_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": 2, "create_time": 1656571939562, "message_type": "image" } }
参数​
含义​
message_type​
消息类型​
    image: 通过抖开发送群消息 OpenAPI 或其他平台发送的图片消息​

视频分享消息​

{ "event": "im_group_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": 2, "create_time": 1656671771668, "message_type": "video", "item_id": "@72NwHyW53+MNggFhRkwGuX1ntuc2RfUyVnKfdTzwU0F0CtjUrU9MpJSYEVV6/2hKy3NMVbBhh6BW27IsDFieLg==" } }
参数​
含义​
message_type​
消息类型​
    video: 视频分享消息,即用户在抖音首页相关视频点击右下角分享按钮 - 选择分享的用户 - 分享的视频消息​
item_id​
加密后的视频ID​

本地图片消息​

{ "event": "im_group_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": 1723994885174, "message_type": "user_local_image" } }
参数​
含义​
message_type​
消息类型​
    user_local_image: 用户本地图片消息,即用户在聊天框中点击右下角+号 - 选择相册 - 勾选具体需要发送的图片 - 点击发送按钮,发送给另一用户的图片消息。可以通过获取消息中的多媒体资源接口获取用户本地图片消息中的图片资源 URL​

本地视频消息​

{ "event": "im_group_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": 1723995366187, "message_type": "user_local_video" } }
参数​
含义​
message_type​
消息类型​
    user_local_video: 用户本地视频消息,即用户在聊天框中点击右下角 + 号 - 选择相册 - 勾选具体需要发送的视频 - 点击发送按钮,发送给另一用户的视频消息。可以通过获取消息中的多媒体资源接口获取用户本地视频消息中的视频资源 URL​

留资卡片消息(包含空白态和完成态)​

注:通过抖音开放平台创建/更新留资卡片接口创建的留资卡片才能收到事件回调。​

空白态​

{ "event": "im_group_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": 2, "create_time": 1656571939562, "message_type": "retain_consult_card", "card_id": "@72MqAjfymKYS1xNrB0sG4X1iidgOeMsMbUSpQwLJb3kYzJh7eXsSr5+aH2GTsvEv", "card_status": 1 //1:空白态;2:完成态 } }

完成态​

{ "event": "im_group_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": 2, "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_group_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": 2, "create_time": 1656571939562, "message_type": "other", "text": "你收到一条新消息,请打开抖音app查看" } }