发送消息
https://member.bilibili.com/arcopen/fn/market/customer/conversation/send_msg
开放能力 / 经营号客服 / 接口文档
调用该接口可发送消息。
body 参数
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
| conversation_id | int | 否 | 会话id,来源于接收私信消息事件;主动联系时不传 |
| user_open_id | string | 否 | 用户open_id,主动联系时必填 |
| msg_type | int | 是 | 消息类型:1-文字、2-图片、10018-主动消息、10030-获客工具卡片 |
| msg | string | 是 | 消息内容,为JSON字符串,结构随消息类型变化 |
响应字段
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
| msg_key | string | 是 | 消息key |
调用方式
javascript
// 让 AI 直接调(需要开放平台凭据)
bili_api_call { "ref": "59", "query": {…}, "body": {…} }
// 只看将要发出的请求(不需要凭据)
bili_api_call { "ref": "59", "dryRun": true }
// 生成完整调用代码
bili_codegen { "ref": "59", "lang": "python" }官方请求示例
bash
curl --location --request POST 'https://member.bilibili.com/arcopen/fn/market/customer/conversation/send_msg' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--header 'x-bili-timestamp: <当前Unix秒级时间戳>' \
--header 'x-bili-signature-method: HMAC-SHA256' \
--header 'x-bili-signature-version: 2.0' \
--header 'Authorization: <按签名规范生成的签名>' \
--header 'x-bili-signature-nonce: <唯一随机字符串>' \
--header 'x-bili-accesskeyid: <应用client_id>' \
--header 'x-bili-content-md5: <实际请求体MD5>' \
--header 'access_token: <用户授权access_token>' \
--data-raw '{
"conversation_id": 254218,
"msg": "{\"content\":\"消息内容\"}",
"msg_type": 1
}'
{
"conversation_id": 8013103,
"msg": "{\"content\":\"1231231\"}",
"msg_type": 1
}
{
"conversation_id": 8013103,
"msg": "{\"url\":\"https://uat-i0.hdslb.com/bfs/mall/mall/02/b5/86e6963da220c8a9a2f1115db1f6de95.png\",\"imageType\":\"image/png\",\"size\":61528,\"width\":1080,\"height\":2340}",
"msg_type": 2
}
{
"conversation_id": 8013103,
"msg": "{\"id\":12345}",
"msg_type": 10030
}
{
"user_open_id": "<目标用户的user_open_id>",
"msg": "{\"id\":12345}",
"msg_type": 10030
}原始文档:059_发送消息.md(3513 字节)。用 bili_docs_get { "ref": "59" } 读全文,或用 bili_api_spec { "ref": "59" } 取结构化规格。