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

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();

}

}

}

结果

相关推荐
一颗小树x3 小时前
【机器人】复现 Aether 世界模型 | 几何感知统一 ICCV 2025
人工智能·机器人·世界模型·aether
Black_Rock_br3 小时前
语音交互新纪元:Hugging Face LeRobot如何让机器人真正“懂你”
人工智能·计算机视觉·机器人
hans汉斯8 小时前
【人工智能与机器人研究】基于力传感器坐标系预标定的重力补偿算法
人工智能·算法·机器人·信号处理·深度神经网络
想要成为计算机高手11 小时前
4. isaac sim4.2 教程-Core API-Hello robot
人工智能·python·机器人·英伟达·isaac sim·仿真环境
YFJ_mily11 小时前
2025第二届机电一体化、机器人与控制系统国际会议(MRCS2025)即将来袭
大数据·人工智能·机器人·机电一体化
weixin_446260851 天前
Isaac Lab:让机器人学习更简单的开源框架
学习·机器人
Mr.Winter`1 天前
轨迹优化 | 基于激光雷达的欧氏距离场ESDF地图构建(附ROS C++仿真)
c++·人工智能·机器人·自动驾驶·ros·ros2·具身智能
Blossom.1182 天前
机器学习在智能制造业中的应用:质量检测与设备故障预测
人工智能·深度学习·神经网络·机器学习·机器人·tensorflow·sklearn
MidJourney中文版2 天前
深度报告:中老年AI陪伴机器人需求分析
人工智能·机器人
沫儿笙3 天前
ABB焊接机器人智能节气仪
人工智能·机器人