Skip to content
On this page

机器人发送消息

请求URL

https://chat-go.jwzhd.com/open-apis/v1/bot/send?token=xxxxxxxxxx

请求示例

curl --location --request POST 'https://chat-go.jwzhd.com/open-apis/v1/bot/send?token=xxxxxxxxxx' \
--header 'Content-Type: application/json' \
--data-raw '{
    "recvId": "7058262",
    "recvType": "user",
    "contentType": "text",
    "content": {
        "text": "这里是消息内容"
    }
}'

请求头

Content-Type: "application/json; charset=utf-8"

请求参数

字段名类型是否必填说明
recvIdstring接收消息对象ID,用户为userId,群组为groupId
recvTypestring接收对象类型,用户为user,群组为group
contentTypestring消息类型,取值包括text、image、file、markdown
contentContent对象消息内容对象

Content对象

contentType为text

字段名类型是否必填说明
textstring消息正文
buttonsButton对象列表消息中包括button

contentType为image

字段名类型是否必填说明
imageUrlstring图片URL
buttonsButton对象列表消息中包括button

contentType为markdown

字段名类型是否必填说明
textstringmarkdown字符串
buttonsButton对象列表消息中包括button

contentType为file

字段名类型是否必填说明
fileNamestring文件名
fileUrlstring文件URL
buttonsButton对象列表消息中包括button

Button对象

字段名类型是否必填说明
textstring按钮上的文字
actionTypeint动作类型,取值为1、2、3,分别表示跳转URL、复制、点击汇报
urlstring当actionType为1时使用,表示跳转的URL
valuestring当actionType为2时使用,该值会被复制到剪贴板;当actionType为3时使用,该值会被发送给订阅端

响应内容

字段名类型说明
codeint响应代码
messagestring响应信息,包括异常信息
dataObject返回数据

完整示例

发送文本消息请求示例

json
{
  "recvId": "7058262",
  "recvType": "user",
  "contentType": "text",
  "content": {
    "text": "这里是消息内容",
    "buttons": [
      [
        {
          "text": "复制",
          "actionType": 2,
          "value": "xxxx"
        },
        {
          "text": "点击跳转",
          "actionType": 1,
          "url": "http://www.baidu.com"
        }
      ]
    ]
  }
}