钉钉群机器人-发送群消息

1、钉钉群创建机器人

添加完成后,要记住 Webhook 路径;

2、机器人接入文档网址

自定义机器人接入 - 钉钉开放平台

3、JAVA代码

import com.dingtalk.api.DefaultDingTalkClient;

import com.dingtalk.api.DingTalkClient;

import com.dingtalk.api.request.OapiRobotSendRequest;

import com.dingtalk.api.response.OapiRobotSendResponse;

import lombok.extern.slf4j.Slf4j;

@Slf4j

public class DingDingSendMsgUtils {

/**

* 超时时间

*/

private static final int timeout = 10000;

/**

* 每个群开通的自定义机器人有webhook,后期可更换或写在配置文件作为参数传入

*/

private static final String webhook = "";

/**

* 自定义关键词,安全设置,后期可更换或写在配置文件作为参数传入

*/

private static final String CUSTOM_KEYWORDS = "退款失败:";

/**

* 提示@所有人

* 文本

* @param msg 通知消息

*/

public static void sendMessageTextAtAll(String msg) {

try{

DingTalkClient client = new DefaultDingTalkClient(webhook);

OapiRobotSendRequest request = new OapiRobotSendRequest();

request.setMsgtype("text");

OapiRobotSendRequest.Text text = new OapiRobotSendRequest.Text();

text.setContent( CUSTOM_KEYWORDS + msg);

request.setText(text);

OapiRobotSendResponse response = client.execute(request);

log.info("response="+response);

}catch (Exception e){

e.printStackTrace();

}

}

/**

* 提示@所有人

* 图文

* @param msg 通知消息

* @param chargingNumber 订单编号

* @param userName 用户名称

* @param payMoney 支付金额

* @param refundMoney 退款金额

*/

public static void sendMessageMarkdownAtAll(String msg,String chargingNumber,String userName,String payMoney,String refundMoney) {

try{

DingTalkClient client = new DefaultDingTalkClient(webhook);

OapiRobotSendRequest request = new OapiRobotSendRequest();

request.setMsgtype("markdown");

OapiRobotSendRequest.Markdown markdown = new OapiRobotSendRequest.Markdown();

markdown.setTitle(CUSTOM_KEYWORDS);

markdown.setText("> ### "+msg+"\n" +

"> ###### 订单号:"+chargingNumber+" \n" +

"> ###### 用户名称:"+userName+" \n" +

"> ###### 支付金额:"+payMoney+"元 \n" +

"> ###### 退款金额:"+refundMoney+"元 \n ");

// "> ![screenshot](https://easycharg-station.oss-cn-shanghai.aliyuncs.com/2023/2023/07/05/24df5a45ed374a04a81d6035a6408f02.png)\n" +

// "> ###### \n");

request.setMarkdown(markdown);

OapiRobotSendResponse response = client.execute(request);

log.info("response="+response);

}catch (Exception e){

e.printStackTrace();

}

}

}

结果

相关推荐
万俟淋曦16 小时前
【论文速递】2025年第40周(Sep-28-Oct-04)(Robotics/Embodied AI/LLM)
人工智能·深度学习·ai·机器人·大模型·论文·具身智能
万俟淋曦17 小时前
【论文速递】2025年第38周(Sep-14-20)(Robotics/Embodied AI/LLM)
人工智能·深度学习·机器学习·机器人·大模型·论文·具身智能
诗远Yolanda19 小时前
【EI检索会议】第二届国际人工智能创新研讨会(IS-AII 2026)
图像处理·人工智能·深度学习·机器学习·计算机视觉·机器人
万俟淋曦20 小时前
【论文速递】2025年第37周(Sep-07-13)(Robotics/Embodied AI/LLM)
人工智能·ai·机器人·大模型·论文·robotics·具身智能
万俟淋曦20 小时前
【论文速递】2025年第42周(Oct-12-18)(Robotics/Embodied AI/LLM)
人工智能·ai·机器人·大模型·论文·robotics·具身智能
万俟淋曦1 天前
【论文速递】2025年第41周(Oct-05-11)(Robotics/Embodied AI/LLM)
人工智能·深度学习·机器人·大模型·论文·robotics·具身智能
AiTEN_Robot1 天前
内部物流自动化集成应用:效率与吞吐能力优化的关键技术突破
机器人·自动化·制造
min1811234561 天前
具身智能(Embodied AI)逼近:机器人如何更好地理解物理世界?
人工智能·机器人
PNP Robotics1 天前
聚焦具身智能,PNP机器人展出力反馈遥操作,VR动作捕捉等方案,获得中国科研贡献奖
大数据·人工智能·python·学习·机器人
数说星榆1811 天前
多代理系统(MAS):机器人集群如何实现知识共享与协同?
机器人