钉钉群机器人发送消息通知

钉钉开放平台
发送消息示例:https://developers.dingtalk.com/document/robots/custom-robot-access?spm=ding_open_doc.document.0.0.543c7b4bPbKqcx#topic-2026027

  1. 建立钉钉群,新建机器人
    群设置 --》 智能群助手
    image
    image

  2. 发送卡片

DingTalkClient client = new DefaultDingTalkClient(DingDing_URL);
        OapiRobotSendRequest request = new OapiRobotSendRequest();
        request.setMsgtype("actionCard");
        //卡片内容
        OapiRobotSendRequest.Actioncard actioncard = new OapiRobotSendRequest.Actioncard();
        actioncard.setTitle(DateUtils.getTodayDate() + "BD获客排名");
        actioncard.setText("### " + DateUtils.getTodayDate() + "BD获客排名");
        actioncard.setBtnOrientation("0");
        //按钮
        List<OapiRobotSendRequest.Btns> btns = Lists.newArrayList();
        OapiRobotSendRequest.Btns btn = new OapiRobotSendRequest.Btns();
        btn.setTitle("下载");
        btn.setActionURL(url.contains("http") ? url : "https://" + url);
        btns.add(btn);
        actioncard.setBtns(btns);
        request.setActionCard(actioncard);
        //at所有人
        OapiRobotSendRequest.At at = new OapiRobotSendRequest.At();
        at.setIsAtAll(true);
        request.setAt(at);
        //发送通知
        OapiRobotSendResponse response = client.execute(request);
        log.info("sendDingDing response = {}", JSON.toJSONString(response));
posted @ 2021-11-08 14:05  狻猊的主人  阅读(877)  评论(0编辑  收藏  举报