跳到主要内容

发送群消息前的回调

功能说明

发送群聊消息前,业务服务端可拒绝此请求,或对请求做修改和干预。

注意事项

  • 为启用回调,必须配置回调 URL,并开启本条回调协议对应的开关。配置方法详见 回调说明 文档。
  • 回调的方向是 IMServer 向 业务服务端发起 HTTP/HTTPS POST 请求。
  • 业务服务端需在超时时间内响应此请求。

可能触发该回调的场景

  • 用户通过客户端或APP管理员通过REST API进行相应操作前

回调发生时机

  • 发送群聊消息之前。

接口说明

请求 URL 示例

此处CallbackCommand为:callbackBeforeSendGroupMsgCommand

{WEBHOOK_ADDRESS}/callbackBeforeSendGroupMsgCommand?contenttype=json

请求包示例

{
"sendID": "123456",
"callbackCommand": "callbackBeforeSendGroupMsgCommand",
"serverMsgID": "msg123",
"clientMsgID": "client123",
"operationID": "1646445464564",
"senderPlatformID": 1,
"senderNickname": "John",
"sessionType": 2,
"msgFrom": 1,
"contentType": 1,
"status": 0,
"sendTime": 1673048592000,
"createTime": 1673048592000,
"content": "Hello, this is a group message!",
"seq": 1,
"atUserList": ["user123", "user456"],
"faceURL": "http://example.com/user123.png",
"ex": "Extra data",
"groupID": "group567"
}

请求包字段说明

对象类型描述
sendIDstring发送的唯一标识符
callbackCommandstring回调命令,这里是发送群组消息之前的回调
serverMsgIDstring服务器端消息ID
clientMsgIDstring客户端消息ID
operationIDstringoperationID用于全局链路追踪
senderPlatformIDint32发送者的平台ID
senderNicknamestring发送者的昵称
sessionTypeint32会话类型
msgFromint32消息来源,1表示来自用户,2表示来自群组
contentTypeint32消息类型,1表示文本消息
statusint32消息状态
sendTimeint64消息发送的时间戳(毫秒)
createTimeint64消息创建的时间戳(毫秒)
contentstring消息内容
sequint32消息的序号
atUserListstring群成员ID列表
faceURLstring发送者的头像URL
exstring额外的数据字段
groupIDstring群组ID

应答包示例

允许发送

允许用户发送群组消息。

{
"actionCode": 0,
"errCode": 0,
"errMsg": "",
"errDlt": "",
"nextCode": 0
}

应答包字段说明

字段说明
actionCode0表示业务系统的回调是否正确执行。0表示操作成功。
errCode5001表示自定义错误码,范围在5000-9999之间。在 actionCode 不等于0时设置;在 nextCode 等于1时设置。
errMsg"An error message"自定义错误码对应的简单错误信息。
errDlt"Detailed error information"自定义错误码对应的详细错误信息。
nextCode1下一步执行指令,1表示拒绝继续执行,actionCode 等于0时设置。