你可以使用此接口指定用户在某个会话中进行消息发送。
你可以调用SendMessage接口,指定你所属的AppId和,发送者 UserId、会话 ID、消息类型和消息内容,进行消息发送。
用户需要在会话中才允许消息发送,且不会触发第三方回调。
发送消息前不会检查发送方是否禁言,也不会检查会话是否开启禁言。
关于调用接口的服务地址、通信协议、字符编码和签名机制,参看调用 OpenAPI。
QPS 不得超过 50。
使用 POST 方式发起请求。
| 参数名 | 类型 | 必填 | 示例值 | 描述 |
|---|---|---|---|---|
| Action | String | 是 | SendMessage | 接口名称,本接口取值:SendMessage |
| Version | String | 是 | 2020-12-01 | 接口版本,本接口取值:2020-12-01 |
| 参数名 | 类型 | 必填 | 示例值 | 描述 |
|---|---|---|---|---|
| AppId | Int | 是 | 000000 | 应用的唯一标志 |
| Sender | Int | 是 | 000010 | 消息发送人 UserId |
| ConversationShortId | Int | 是 | 000001 | 会话 ID |
| MsgType | Int | 是 | 10001 | 消息类型 |
| Content | String | 是 | Your_Content | 消息内容。当你给客户端发消息时,Content 内容需符合客户端格式,详细信息请参看消息格式。 |
| MentionedUsers | Array of Int | 否 | [111111,222222] | 会话中@的人 |
| VisibleUsers | Array of Int | 否 | [111111] | 消息可见会话成员列表 |
| InvisibleUsers | Array of Int | 否 | [111111] | 消息不可见会话成员列表。VisibleUsers 和 InvisibleUsers均为空时,代表对所有人可见。 |
| Ext | map-key(string)-value(string) | 否 | {"key":"value"} | 消息的扩展字段 |
| ClientMsgId | string | 否 | "unique-key" | 幂等id,如果创建时指定了此字段,并且数据库中存在此 id 对应的消息,不会重复发送。如果不指定,会随机生成一个。 |
| RefMsgInfo | RefMsgInfo | 否 | / | 引用消息。该接口中,该字段只需传入 ReferencedMessageId 和 Hint 参数 |
| CreateTime | Int | 否 | 1666613688658 | 消息对应时间戳,单位为毫秒。 |
| Priority | Int | 否 | 1 | 消息优先级。
|
注释 1:
为避免直播群中消息频率太多导致服务端压力过大,你可以设置消息的优先级。当前直播群下,普通优先级和低优先级消息共用频控阈值为 30 条/秒,超过部分会被服务端直接丢弃。高优消息频控阈值为 10 条/秒,超过部分服务端无法保证不丢失。
https://rtc.volcengineapi.com?Action=SendMessage&Version=2020-12-01
postscript{
"AppId":000000,
"Sender":000010,
"ConversationShortId":000001,
"MsgType":10001,
"Content":"Your_Content",
"MentionedUsers":[111111,222222],
"RefMsgInfo": {
"ReferencedMessageId": 7171391232210503710,
"Hint": "[图片]"
}
}
json返回结果参看 BaseResponse。
其中 Result 的结构如下:
| 参数名 | 类型 | 描述 |
|---|---|---|
| MessageId | Int | 10003 |
{
"ResponseMetadata": {
"RequestId": "Your_RequestId",
"Action": "SendMessage",
"Version": "2020-12-01",
"Service": "rtc",
"Region": "cn-north-1"
},
"Result": {
"MessageId": 10003
}
}
json