企业微信消息模板 card_type: NEWS_NOTICE 的 proto3 定义
{
"chatid":"xxxxx",
"msgtype":"template_card",
"template_card":{
"card_type":"news_notice",
"source":{
"icon_url":"https://wework.qpic.cn/wwpic/252813_jOfDHtcISzuodLa_1629280209/0",
"desc":"企业微信",
"desc_color":0
},
"action_menu":{
"desc":"消息气泡副交互辅助文本说明",
"action_list":[
{
"text":"接收推送",
"key":"action_key1"
},
{
"text":"不再推送",
"key":"action_key2"
}
]
},
"main_title":{
"title":"欢迎使用企业微信",
"desc":"您的好友正在邀请您加入企业微信"
},
"card_image":{
"url":"https://wework.qpic.cn/wwpic/354393_4zpkKXd7SrGMvfg_1629280616/0",
"aspect_ratio":2.25
},
"image_text_area":{
"type":1,
"url":"https://work.weixin.qq.com",
"title":"欢迎使用企业微信",
"desc":"您的好友正在邀请您加入企业微信",
"image_url":"https://wework.qpic.cn/wwpic/354393_4zpkKXd7SrGMvfg_1629280616/0"
},
"quote_area":{
"type":1,
"url":"https://work.weixin.qq.com/?from=openApi",
"appid":"APPID",
"pagepath":"PAGEPATH",
"title":"引用文本标题",
"quote_text":"Jack:企业微信真的很好用~
Balian:超级好的一款软件!"
},
"vertical_content_list":[
{
"title":"惊喜红包等你来拿",
"desc":"下载企业微信还能抢红包!"
}
],
"horizontal_content_list":[
{
"keyname":"邀请人",
"value":"张三"
},
{
"keyname":"企微官网",
"value":"点击访问",
"type":1,
"url":"https://work.weixin.qq.com/?from=openApi"
},
{
"keyname":"企微下载",
"value":"企业微信.apk",
"type":2,
"media_id":"MEDIAID"
}
],
"jump_list":[
{
"type":1,
"url":"https://work.weixin.qq.com/?from=openApi",
"title":"企业微信官网"
},
{
"type":2,
"appid":"APPID",
"pagepath":"PAGEPATH",
"title":"跳转小程序"
}
],
"card_action":{
"type":1,
"url":"https://work.weixin.qq.com/?from=openApi",
"appid":"APPID",
"pagepath":"PAGEPATH"
},
"task_id":"task_id"
}
}
syntax = 'proto3';
message TemplateCard { enum CardType { NEWS_NOTICE = 0; }
message Source {
string icon_url = 1;
string desc = 2;
int32 desc_color = 3;
}
message Action {
string text = 1;
string key = 2;
}
message ActionMenu {
string desc = 1;
repeated Action action_list = 2;
}
message MainTitle {
string title = 1;
string desc = 2;
}
message CardImage {
string url = 1;
float aspect_ratio = 2;
}
message ImageTextArea {
enum Type {
UNKNOWN = 0;
URL = 1;
}
Type type = 1;
string url = 2;
string title = 3;
string desc = 4;
string image_url = 5;
}
message QuoteArea {
enum Type {
UNKNOWN = 0;
URL = 1;
}
Type type = 1;
string url = 2;
string appid = 3;
string pagepath = 4;
string title = 5;
string quote_text = 6;
}
message VerticalContent {
string title = 1;
string desc = 2;
}
message HorizontalContent {
enum Type {
UNKNOWN = 0;
URL = 1;
MEDIA_ID = 2;
}
string keyname = 1;
string value = 2;
Type type = 3;
string url = 4;
string media_id = 5;
}
message Jump {
enum Type {
UNKNOWN = 0;
URL = 1;
APPID = 2;
}
Type type = 1;
string url = 2;
string appid = 3;
string pagepath = 4;
string title = 5;
}
message CardAction {
enum Type {
UNKNOWN = 0;
URL = 1;
APPID = 2;
}
Type type = 1;
string url = 2;
string appid = 3;
string pagepath = 4;
}
string chatid = 1;
string msgtype = 2;
CardType card_type = 3;
Source source = 4;
ActionMenu action_menu = 5;
MainTitle main_title = 6;
CardImage card_image = 7;
ImageTextArea image_text_area = 8;
QuoteArea quote_area = 9;
repeated VerticalContent vertical_content_list = 10;
repeated HorizontalContent horizontal_content_list = 11;
repeated Jump jump_list = 12;
CardAction card_action = 13;
string task_id = 14;
}
**字段说明**
* chatid: 消息接收者用户ID
* msgtype: 消息类型,固定为 template_card
* template_card: 消息模板内容
* card_type: 消息卡片类型,固定为 NEWS_NOTICE
* source: 消息来源
* icon_url: 消息来源图标URL
* desc: 消息来源描述
* desc_color: 消息来源描述颜色
* action_menu: 消息气泡交互菜单
* desc: 消息气泡副交互辅助文本说明
* action_list: 消息气泡交互按钮列表
* text: 按钮文本
* key: 按钮点击事件标识
* main_title: 主标题
* title: 主标题文本
* desc: 主标题描述
* card_image: 卡片图片
* url: 图片URL
* aspect_ratio: 图片长宽比
* image_text_area: 图片文本区域
* type: 类型,固定为 URL
* url: 跳转链接
* title: 标题文本
* desc: 描述文本
* image_url: 图片URL
* quote_area: 引用文本区域
* type: 类型,固定为 URL
* url: 跳转链接
* appid: 小程序APPID
* pagepath: 小程序页面路径
* title: 标题文本
* quote_text: 引用文本内容
* vertical_content_list: 垂直内容列表
* title: 标题文本
* desc: 描述文本
* horizontal_content_list: 水平内容列表
* keyname: 内容键值
* value: 内容值
* type: 类型,可选 URL 或 MEDIA_ID
* URL: 跳转链接
* MEDIA_ID: 媒体ID
* url: 跳转链接
* media_id: 媒体ID
* jump_list: 跳转列表
* type: 类型,可选 URL 或 APPID
* URL: 跳转链接
* APPID: 小程序APPID
* url: 跳转链接
* appid: 小程序APPID
* pagepath: 小程序页面路径
* title: 标题文本
* card_action: 卡片点击事件
* type: 类型,可选 URL 或 APPID
* URL: 跳转链接
* APPID: 小程序APPID
* url: 跳转链接
* appid: 小程序APPID
* pagepath: 小程序页面路径
* task_id: 任务ID
**proto3 定义**
```proto
syntax = 'proto3';
message TemplateCard {
enum CardType {
NEWS_NOTICE = 0;
}
message Source {
string icon_url = 1;
string desc = 2;
int32 desc_color = 3;
}
message Action {
string text = 1;
string key = 2;
}
message ActionMenu {
string desc = 1;
repeated Action action_list = 2;
}
message MainTitle {
string title = 1;
string desc = 2;
}
message CardImage {
string url = 1;
float aspect_ratio = 2;
}
message ImageTextArea {
enum Type {
UNKNOWN = 0;
URL = 1;
}
Type type = 1;
string url = 2;
string title = 3;
string desc = 4;
string image_url = 5;
}
message QuoteArea {
enum Type {
UNKNOWN = 0;
URL = 1;
}
Type type = 1;
string url = 2;
string appid = 3;
string pagepath = 4;
string title = 5;
string quote_text = 6;
}
message VerticalContent {
string title = 1;
string desc = 2;
}
message HorizontalContent {
enum Type {
UNKNOWN = 0;
URL = 1;
MEDIA_ID = 2;
}
string keyname = 1;
string value = 2;
Type type = 3;
string url = 4;
string media_id = 5;
}
message Jump {
enum Type {
UNKNOWN = 0;
URL = 1;
APPID = 2;
}
Type type = 1;
string url = 2;
string appid = 3;
string pagepath = 4;
string title = 5;
}
message CardAction {
enum Type {
UNKNOWN = 0;
URL = 1;
APPID = 2;
}
Type type = 1;
string url = 2;
string appid = 3;
string pagepath = 4;
}
string chatid = 1;
string msgtype = 2;
CardType card_type = 3;
Source source = 4;
ActionMenu action_menu = 5;
MainTitle main_title = 6;
CardImage card_image = 7;
ImageTextArea image_text_area = 8;
QuoteArea quote_area = 9;
repeated VerticalContent vertical_content_list = 10;
repeated HorizontalContent horizontal_content_list = 11;
repeated Jump jump_list = 12;
CardAction card_action = 13;
string task_id = 14;
}
使用示例
message TemplateCard {
enum CardType {
NEWS_NOTICE = 0;
}
message Source {
string icon_url = 1;
string desc = 2;
int32 desc_color = 3;
}
message Action {
string text = 1;
string key = 2;
}
message ActionMenu {
string desc = 1;
repeated Action action_list = 2;
}
message MainTitle {
string title = 1;
string desc = 2;
}
message CardImage {
string url = 1;
float aspect_ratio = 2;
}
message ImageTextArea {
enum Type {
UNKNOWN = 0;
URL = 1;
}
Type type = 1;
string url = 2;
string title = 3;
string desc = 4;
string image_url = 5;
}
message QuoteArea {
enum Type {
UNKNOWN = 0;
URL = 1;
}
Type type = 1;
string url = 2;
string appid = 3;
string pagepath = 4;
string title = 5;
string quote_text = 6;
}
message VerticalContent {
string title = 1;
string desc = 2;
}
message HorizontalContent {
enum Type {
UNKNOWN = 0;
URL = 1;
MEDIA_ID = 2;
}
string keyname = 1;
string value = 2;
Type type = 3;
string url = 4;
string media_id = 5;
}
message Jump {
enum Type {
UNKNOWN = 0;
URL = 1;
APPID = 2;
}
Type type = 1;
string url = 2;
string appid = 3;
string pagepath = 4;
string title = 5;
}
message CardAction {
enum Type {
UNKNOWN = 0;
URL = 1;
APPID = 2;
}
Type type = 1;
string url = 2;
string appid = 3;
string pagepath = 4;
}
string chatid = 1;
string msgtype = 2;
CardType card_type = 3;
Source source = 4;
ActionMenu action_menu = 5;
MainTitle main_title = 6;
CardImage card_image = 7;
ImageTextArea image_text_area = 8;
QuoteArea quote_area = 9;
repeated VerticalContent vertical_content_list = 10;
repeated HorizontalContent horizontal_content_list = 11;
repeated Jump jump_list = 12;
CardAction card_action = 13;
string task_id = 14;
}
// 创建消息模板
TemplateCard template_card = new TemplateCard();
template_card.chatid = 'xxxxx';
template_card.msgtype = 'template_card';
template_card.card_type = TemplateCard.CardType.NEWS_NOTICE;
template_card.source.icon_url = 'https://wework.qpic.cn/wwpic/252813_jOfDHtcISzuodLa_1629280209/0';
template_card.source.desc = '企业微信';
template_card.source.desc_color = 0;
template_card.action_menu.desc = '消息气泡副交互辅助文本说明';
// 添加消息气泡交互按钮
template_card.action_menu.action_list.add(new TemplateCard.Action());
template_card.action_menu.action_list[0].text = '接收推送';
template_card.action_menu.action_list[0].key = 'action_key1';
template_card.action_menu.action_list.add(new TemplateCard.Action());
template_card.action_menu.action_list[1].text = '不再推送';
template_card.action_menu.action_list[1].key = 'action_key2';
template_card.main_title.title = '欢迎使用企业微信';
template_card.main_title.desc = '您的好友正在邀请您加入企业微信';
template_card.card_image.url = 'https://wework.qpic.cn/wwpic/354393_4zpkKXd7SrGMvfg_1629280616/0';
template_card.card_image.aspect_ratio = 2.25;
// 添加垂直内容
template_card.vertical_content_list.add(new TemplateCard.VerticalContent());
template_card.vertical_content_list[0].title = '惊喜红包等你来拿';
template_card.vertical_content_list[0].desc = '下载企业微信还能抢红包!';
// 添加水平内容
template_card.horizontal_content_list.add(new TemplateCard.HorizontalContent());
template_card.horizontal_content_list[0].keyname = '邀请人';
template_card.horizontal_content_list[0].value = '张三';
template_card.horizontal_content_list.add(new TemplateCard.HorizontalContent());
template_card.horizontal_content_list[1].keyname = '企微官网';
template_card.horizontal_content_list[1].value = '点击访问';
template_card.horizontal_content_list[1].type = TemplateCard.HorizontalContent.Type.URL;
template_card.horizontal_content_list[1].url = 'https://work.weixin.qq.com/?from=openApi';
template_card.horizontal_content_list.add(new TemplateCard.HorizontalContent());
template_card.horizontal_content_list[2].keyname = '企微下载';
template_card.horizontal_content_list[2].value = '企业微信.apk';
template_card.horizontal_content_list[2].type = TemplateCard.HorizontalContent.Type.MEDIA_ID;
template_card.horizontal_content_list[2].media_id = 'MEDIAID';
// 添加跳转
template_card.jump_list.add(new TemplateCard.Jump());
template_card.jump_list[0].type = TemplateCard.Jump.Type.URL;
template_card.jump_list[0].url = 'https://work.weixin.qq.com/?from=openApi';
template_card.jump_list[0].title = '企业微信官网';
template_card.jump_list.add(new TemplateCard.Jump());
template_card.jump_list[1].type = TemplateCard.Jump.Type.APPID;
template_card.jump_list[1].appid = 'APPID';
template_card.jump_list[1].pagepath = 'PAGEPATH';
template_card.jump_list[1].title = '跳转小程序';
template_card.card_action.type = TemplateCard.CardAction.Type.URL;
template_card.card_action.url = 'https://work.weixin.qq.com/?from=openApi';
template_card.card_action.appid = 'APPID';
template_card.card_action.pagepath = 'PAGEPATH';
template_card.task_id = 'task_id';
// 将消息模板序列化为字节流
byte[] messageBytes = template_card.ToByteArray();
原文地址: https://www.cveoy.top/t/topic/mw1W 著作权归作者所有。请勿转载和采集!