Skip to content

添加消息表情回复

给指定消息添加指定类型的表情回复。

前提条件

  • 应用需要开启机器人能力
  • 调用当前接口的机器人或者用户,需要在待添加表情回复的消息所属的会话内。

使用限制

请求

项目
HTTP URLhttps://open.feishu.cn/open-apis/im/v1/messages/:message_id/reactions
HTTP MethodPOST
接口频率限制1000 次/分钟、50 次/秒
支持的应用类型custom,isv
权限要求 调用该 API 所需的权限。开启其中任意一项权限即可调用 开启任一权限即可im:message 获取与发送单聊、群组消息 im:message.reactions:write_only 发送、删除消息表情回复

请求头

名称类型必填描述
Authorizationstringtenant_access_tokenuser_access_token 值格式:"Bearer access_token" 示例值:"Bearer u-7f1bcd13fc57d46bac21793a18e560" 了解更多:如何选择与获取 access token
Content-Typestring固定值:"application/json; charset=utf-8"

路径参数

名称类型描述
message_idstring待添加表情回复的消息 ID。ID 获取方式: - 调用发送消息接口后,从响应结果的 message_id 参数获取。 - 监听接收消息事件,当触发该事件后可以从事件体内获取消息的 message_id。 - 调用获取会话历史消息接口,从响应结果的 message_id 参数获取。
示例值:"om_a8f2294b************a1a38afaac9d"

请求体

名称类型必填描述
reaction_typeemoji表情类型
  └ emoji_typestringemoji 类型。支持的表情与对应的 emoji_type 值参见表情文案说明
示例值:"SMILE"

请求体示例

json
{
    "reaction_type": {
        "emoji_type": "SMILE"
    }
}

响应

响应体

名称类型描述
codeint错误码,非 0 表示失败
msgstring错误描述
datamessage.reaction-
  └ reaction_idstring表情回复 ID。为消息添加表情回复后,会获得该表情回复的唯一标识 ID,后续使用该 ID 可以删除消息表情回复
  └ operatoroperator添加消息表情回复的操作人。
    └ operator_idstring操作人 ID,具体的取值与 operator_type 相关: - 当 operator_type 取值 app 时返回机器人的应用 ID(app_id)。 - 当 operator_type 取值 user 时返回用户的 open_id。
    └ operator_typestring操作人身份。
可选值有
- app: 应用 - user: 用户
  └ action_timestring添加消息表情回复的时间。Unix 时间戳,单位:ms
  └ reaction_typeemoji表情类型
    └ emoji_typestringemoji 类型。emoji_type 值对应的表情参考表情文案说明

响应体示例

json
{
    "code": 0,
    "msg": "success",
    "data": {
        "reaction_id": "ZCaCIjUBVVWSrm5L-3ZTw****",
        "operator": {
            "operator_id": "ou_ff0b7ba35fb****",
            "operator_type": "user"
        },
        "action_time": "1663054162546",
        "reaction_type": {
            "emoji_type": "SMILE"
        }
    }
}

错误码

HTTP状态码错误码描述排查建议
400230110Action unavailable as the message has been deleted.消息被删除,无法进行操作。
400231001reaction type is invalid.表情类型不合法。请参考表情文案说明,设置正确的 emoji_type 值。
400231002The operator has no permission to react on the specific message.当前调用接口的机器人或用户,没有权限对目标消息添加或删除表情回复。通常是因为机器人或用户不在消息所属的会话内。
400231003The message is not found, maybe not exist or deleted.找不到目标消息,可能因为传入的消息 ID 有误或者消息已经被撤回。
400231004The chat in which the message exists is not found, maybe not exist, deleted or archived.目标消息所属会话不存在、已被解散或归档等,无法进行操作。
400231005The thread has been no-trace removed, cannot put reaction.目标消息是一个话题消息,该话题消息被无痕撤回,无法进行操作。
400231006The operator_id is invalid.operator_id 是非法值,不能有效指定一个机器人或用户。请重试,若问题仍未解决请咨询技术支持
400231008The operator has no access to the message.操作人对该消息没有访问权限,通常是因为操作人不在消息所在会话内。
400231012The request has an invalid pageToken.page_token 参数不合法。请根据 page_token 参数描述,设置正确的值。
400231013The request has an invalid AuthType.请求的授权方式不合法。没有使用 tenant_access_token 或者 user_access_token 进行授权。
400231014user_id_type is invalid.user_id_type 不合法。未使用 open_id,union_id,user_id 三者之一。
400231015Act on reaction failed, repeated request is processing.重复的表情回复请求正在处理中。
400231017This operation is not supported for this message type.该消息类型不支持本操作,详情参见消息与群组部分API增加不支持的消息类型校验
400231018The message is invisible to the operator.该消息对于操作者不可见,无法进行本操作。
400231019Due to the settings of this user, you are temporarily unable to perform this operation.由于目标用户(消息发送者)的设置(例如屏蔽消息),暂时无法执行此操作。
400231020Due to the configuration of the tenant administrator, you cannot perform this operation on the target user temporarily.由于租户管理员的配置,暂时无法对目标用户(消息发送者)执行此操作,请联系租户管理员协助排查。
400231021No permission to operate external chats.没有权限操作外部群。
400231022Bot has NO availability to this user.单聊用户(以群聊的 chat_id 指定的消息接收者,但 chat_id 对应的群聊类型为单聊 p2p)不在应用机器人的可用范围内,或者是在应用的禁用范围内。 解决方案: 1. 登录开发者后台,找到并进入指定应用详情页。 2. 在左侧导航栏进入 应用发布 > 版本管理与发布 页面,点击 创建版本。 3. 在 版本详情 页面,找到 可用范围 区域,点击 编辑。 4. 在弹出的对话框内,配置应用的可用范围,将用户添加至可用范围内。 5. 在页面底部点击 保存,并发布应用使配置生效。 6. (可选)如果以上配置完成后仍报错,则需要联系企业管理员登录管理后台,在 工作台 > 应用管理 中进入指定应用详情页,在 应用可用范围 内查看该用户是否被设置为了 禁用成员。 具体操作参见配置应用可用范围
400232009Your request specifies a chat which has already been dissolved.群组已被解散,无法执行操作。

更多错误码信息,参见通用错误码

内容来源:飞书开放平台 · 自动爬取整理