接收消息
事件
基本 | |
---|---|
事件类型 | im.message.receive_v1 |
支持的应用类型 | 自建应用商店应用 |
权限要求 开启任一权限即可 | 获取用户在群组中@机器人的消息接收群聊中@机器人消息事件获取群组中所有消息读取用户发给机器人的单聊消息获取用户发给机器人的单聊消息获取群聊中所有的用户聊天消息历史版本仅自建应用 |
字段权限要求 | 该接口返回体中存在下列敏感字段,仅当开启对应的权限后才会返回;如果无需获取这些字段,则不建议申请获取用户 user ID仅自建应用 |
推送方式 | Webhook |
事件体
名称收起子列表 | 类型 | 描述 |
---|---|---|
schema | string | 事件模式 |
header | event_header | 事件头 |
event_id | string | 事件 ID |
event_type | string | 事件类型 |
create_time | string | 事件创建时间戳(单位:毫秒) |
token | string | 事件 Token |
app_id | string | 应用 ID |
tenant_key | string | 租户 Key |
event | - | - |
sender | event_sender | 事件的发送者 |
sender_id | user_id | 用户 ID |
union_id | string | 用户的 union id |
user_id | string | 用户的 user id字段权限要求:获取用户 user ID仅自建应用 |
open_id | string | 用户的 open id |
sender_type | string | 消息发送者类型。目前只支持用户(user)发送的消息。 |
tenant_key | string | tenant key,为租户在飞书上的唯一标识,用来换取对应的tenant_access_token,也可以用作租户在应用里面的唯一标识 |
message | event_message | 事件中包含的消息内容 |
message_id | string | 消息的open_message_id,说明参见:消息ID说明 |
root_id | string | 根消息id,用于回复消息场景,说明参见:消息ID说明 |
parent_id | string | 父消息的id,用于回复消息场景,说明参见:消息ID说明 |
create_time | string | 消息发送时间(毫秒) |
chat_id | string | 消息所在的群组 ID |
chat_type | string | 消息所在的群组类型可选值有:p2p :单聊group : 群组topic_group :话题群 |
message_type | string | 消息类型 |
content | string | 消息内容, json 格式各类型消息Content |
mentions | mention_event[] | 被提及用户的信息 |
key | string | mention key |
id | user_id | 用户 ID |
union_id | string | 用户的 union id |
user_id | string | 用户的 user id字段权限要求:获取用户 user ID仅自建应用 |
open_id | string | 用户的 open id |
name | string | 用户姓名 |
tenant_key | string | tenant key,为租户在飞书上的唯一标识,用来换取对应的tenant_access_token,也可以用作租户在应用里面的唯一标识 |
事件体示例
{
"schema": "2.0",
"header": {
"event_id": "5e3702a84e847582be8db7fb73283c02",
"event_type": "im.message.receive_v1",
"create_time": "1608725989000",
"token": "rvaYgkND1GOiu5MM0E1rncYC6PLtF7JV",
"app_id": "cli_9f5343c580712544",
"tenant_key": "2ca1d211f64f6438"
},
"event": {
"sender": {
"sender_id": {
"union_id": "on_8ed6aa67826108097d9ee143816345",
"user_id": "e33ggbyz",
"open_id": "ou_84aad35d084aa403a838cf73ee18467"
},
"sender_type": "user",
"tenant_key": "736588c9260f175e"
},
"message": {
"message_id": "om_5ce6d572455d361153b7cb51da133945",
"root_id": "om_5ce6d572455d361153b7cb5xxfsdfsdfdsf",
"parent_id": "om_5ce6d572455d361153b7cb5xxfsdfsdfdsf",
"create_time": "1609073151345",
"chat_id": "oc_5ce6d572455d361153b7xx51da133945",
"chat_type": "group",
"message_type": "text",
"content": "{\"text\":\"@_user_1 hello\"}",
"mentions": [
{
"key": "@_user_1",
"id": {
"union_id": "on_8ed6aa67826108097d9ee143816345",
"user_id": "e33ggbyz",
"open_id": "ou_84aad35d084aa403a838cf73ee18467"
},
"name": "Tom",
"tenant_key": "736588c9260f175e"
}
]
}
}
}
修改于 2023-01-12 09:19:38