# 消息服务接口

# 接口定义

# 发送消息

请求方式:POST

请求地址:./nepoch-msgc/msgc/send

# 文本消息

请求示例:

{
   "touser" : "LiuLeiLei",
   "toparty" : "",
   "totag" : "",
   "msgtype" : "TEXT",
   "terminalId": "1509445909715894272",
   "text" : {
        "content" : "$userName=LiuLeiLei$你的快递已到,请携带工卡前往邮件中心领取。\n出发前可查看<a href=\"http://work.weixin.qq.com\">邮件中心视频实况</a>,聪明避开排队。"
   },
   "safe":"0"
}
1
2
3
4
5
6
7
8
9
10
11

参数说明:

参数 是否必须 说明
touser 指定接收消息的成员,成员ID列表(多个接收者用‘|’分隔,最多支持1000个)。 特殊情况:指定为"@all",则向该企业应用的全部成员发送
toparty 指定接收消息的部门,部门ID列表,多个接收者用‘|’分隔,最多支持100个。 当touser为"@all"时忽略本参数
totag 指定接收消息的标签,标签ID列表,多个接收者用‘|’分隔,最多支持100个。 当touser为"@all"时忽略本参数
msgtype 消息类型,此时固定为:TEXT
terminalId 指定接收消息的终端,不指定发送到默认终端
content 消息内容,最长不超过2048个字节,超过将截断**(支持id转译)**
safe 表示是否是保密消息,0表示可对外分享,1表示不能分享且内容显示水印,默认为0

返回示例:

{
  	"uuid":"3f85197e-7c25-4d68-98c6-dd59b6f98ebe",
  	"code":"000000",
  	"msg":"成功",
  	"data":"5bb53729-bf7d-45ad-b67e-ed5605bc0bb9",
  	"ok":true
}
1
2
3
4
5
6
7

消息效果展示:

image-20220308181152530

# 按钮交互型卡片消息

请求示例:

{
   "touser" : "LiuLeiLei",
   "msgtype" : "TEMPLATE_CARD",
   "terminalId": "1509445909715894272",
   "template_card" : {
       "card_type" : "button_interaction",
        "main_title" : {
            "title" : "流程审批通知",
            "desc" : "$userName=LiuLeiLei$ 您好:您有待办需要审批办理"
        },
        "horizontal_content_list" : [
            {
                "type": 0,
                "keyname": "标题",
                "value": "张三-转正"
            },
            {
                "type": 0,
                "keyname": "流程号",
                "value": "2111150026"
            },
            {
                "type": 0,
                "keyname": "备注",
                "value": "无"
            }
        ],
        "button_list": [
            {
                "type": 1,
                "text": "审批办理",
                "style": 1,
                "key": "shenpibanli",
                "url": "www.qq.com"
            }
        ]
   },
   "safe":"0"
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39

参数说明:

参数 是否必须 说明
touser 成员ID列表(消息接收者,多个接收者用‘|’分隔,最多支持1000个)。特殊情况:指定为@all,则向关注该企业应用的全部成员发送
toparty 部门ID列表,多个接收者用‘|’分隔,最多支持100个。当touser为@all时忽略本参数
totag 标签ID列表,多个接收者用‘|’分隔,最多支持100个。当touser为@all时忽略本参数
msgtype 消息类型,此时固定为:TEMPLATE_CARD
terminalId 指定接收消息的终端,不指定发送到默认终端
card_type 模板卡片类型,按钮交互型卡片填写"button_interaction"
main_title.title 一级标题,建议不超过36个字,(支持id转译)
main_title.desc 标题辅助信息,建议不超过44个字,(支持id转译)
horizontal_content_list 二级标题+文本列表,该字段可为空数组,但有数据的话需确认对应字段是否必填,列表长度不超过6
horizontal_content_list.type 链接类型,0或不填代表不是链接,1 代表跳转url,3 代表点击跳转成员详情
horizontal_content_list.keyname 二级标题,建议不超过5个字
horizontal_content_list.value 二级文本,如果horizontal_content_list.type是2,该字段代表文件名称(要包含文件类型),建议不超过30个字,(支持id转译)
horizontal_content_list.url 链接跳转的url,horizontal_content_list.type是1时必填
horizontal_content_list.userid 成员详情的userid,horizontal_content_list.type是3时必填
button_list 按钮列表,列表长度不超过6
button_list.type 按钮点击事件类型,0 或不填代表回调点击事件,1 代表跳转url
button_list.text 按钮文案,建议不超过10个字
button_list.style 按钮样式,目前可填1~4,不填或错填默认1
button_list.key 按钮key值,用户点击后,会产生回调事件将本参数作为EventKey返回,回调事件会带上该key值,最长支持1024字节,不可重复,button_list.type是0时必填
button_list.url 跳转事件的url,button_list.type是1时必填

返回示例:

{
  	"uuid":"3f85197e-7c25-4d68-98c6-dd59b6f98ebe",
  	"code":"000000",
  	"msg":"成功",
  	"data":"5bb53729-bf7d-45ad-b67e-ed5605bc0bb9",
  	"ok":true
}
1
2
3
4
5
6
7

消息效果展示:

image-20220308183401441

# 自定义模版消息

请求示例:

{
  
  "touser" : "31390",
  "toparty" : "",
  "totag" : "",
  "msgtype": "TEMPLATE""terminalId": "1513431591417298944",
	"templateCode": "QYWXTEXT",
	"templateId": "1513761032462942208",
	"templateParams": {
		"userId": "31390"
	},
	"safe": "0"
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14

参数说明:

参数 是否必须 说明
touser 指定接收消息的成员,成员ID列表(多个接收者用‘|’分隔,最多支持1000个)。 特殊情况:指定为"@all",则向该企业应用的全部成员发送
toparty 指定接收消息的部门,部门ID列表,多个接收者用‘|’分隔,最多支持100个。 当touser为"@all"时忽略本参数
totag 指定接收消息的标签,标签ID列表,多个接收者用‘|’分隔,最多支持100个。 当touser为"@all"时忽略本参数
msgtype 消息类型,此时固定为:TEMPLATE
terminalId 指定接收消息的终端,不指定发送到默认终端
templateCode 自定义模版分类code
templateId 自定义模版消息id,默认发送templateCode指定的模版分类下的默认模版
templateParams 模版中自定义的参数,以键值对的形式传入
safe 表示是否是保密消息,0表示可对外分享,1表示不能分享且内容显示水印,默认为0

返回示例:

{
  	"uuid":"3f85197e-7c25-4d68-98c6-dd59b6f98ebe",
  	"code":"000000",
  	"msg":"成功",
  	"data":"5bb53729-bf7d-45ad-b67e-ed5605bc0bb9",
  	"ok":true
}
1
2
3
4
5
6
7

消息效果展示:

image-20220308181152530

# 撤回消息

请求方式:POST

请求地址:./nepoch-msgc/msgc/revoke

请求示例:

./nepoch-msgc/msgc/revoke?sysNo=9ac66803-90d4-476b-8bf5-7f6a115d52bc
1

请求参数:

参数 是否必须 说明
sysNo 消息主键,发送消息是返回值中的 data 字段

返回示例:

{
    "uuid": "e1c54d3a-6149-4e52-ac47-98a07a3f9048",
    "code": "000000",
    "msg": "成功",
    "data": null,
    "ok": true
}
1
2
3
4
5
6
7

# 更新消息

请求方式:POST

请求地址:./nepoch-msgc/msgc/update

# 更新按钮为不可点击状态

请求示例:

{
    "sysNo": "859efcd5-4984-4ce7-ba52-aca8f766d6fb",
    "userids" : ["ZhangSan"],
  	"partyids" : [],
    "tagids" : [],
    "button": {
        "replace_name": "已办理"
    }
}
1
2
3
4
5
6
7
8
9

参数说明:

参数 是否必须 说明
userids 企业的成员ID列表(最多支持1000个)
partyids 企业的部门ID列表(最多支持100个)
tagids 企业的标签ID列表(最多支持100个)
atall 更新整个任务接收人员
replace_name 需要更新的按钮的文案

返回示例:

{
    "uuid": "e1c54d3a-6149-4e52-ac47-98a07a3f9048",
    "code": "000000",
    "msg": "成功",
    "data": null,
    "ok": true
}
1
2
3
4
5
6
7

效果展示:

image-20220322102358207