PHPackages                             dreamcoders/laravel-dingbot - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Mail &amp; Notifications](/categories/mail)
4. /
5. dreamcoders/laravel-dingbot

ActiveLibrary[Mail &amp; Notifications](/categories/mail)

dreamcoders/laravel-dingbot
===========================

a dingtalk robot message handle for send message

v1.0.1(2y ago)1246MITPHPPHP &gt;=7.0

Since Sep 1Pushed 2y ago1 watchersCompare

[ Source](https://github.com/iGaoWei/laravel-dingbot)[ Packagist](https://packagist.org/packages/dreamcoders/laravel-dingbot)[ RSS](/packages/dreamcoders-laravel-dingbot/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (1)Versions (3)Used By (0)

钉钉机器人消息发送
=========

[](#钉钉机器人消息发送)

介绍
==

[](#介绍)

企业内部有较多系统支撑着公司的核心业务流程，譬如CRM系统、交易系统、监控报警系统等等。通过钉钉的自定义机器人，可以将这些系统事件同步到钉钉的聊天群。 laravel-dingbot 是一款钉钉机器人消息推送的Laravel扩展，您可以通过此扩展简单高效的推送消息通知到钉钉，进行监控和提醒操作。

### [钉钉官方文档](https://open.dingtalk.com/document/robots/custom-robot-access)

[](#钉钉官方文档)

安装
==

[](#安装)

```
composer require dreamcoders/laravel-dingbot
```

在laravel项目中使用
=============

[](#在laravel项目中使用)

安装成功后执行

```
php artisan vendor:publish --provider="DreamCoders\DingBot\DingBotServiceProvider"
```

会自动将`dingbot.php`添加到您项目的config配置文件当中

相关配置
====

[](#相关配置)

```
return [
    'webhookUrl' => env('DING_ROBOT_URL', 'https://oapi.dingtalk.com/robot/send'),

    'default' => [
        // 机器人的access_token default
        'access_token' => env('DING_TOKEN','4c8ed2083bcd5cc9d38343211900ea29ef7bbef9156ad0892'),
        // 加签 （不开启加签则为空）
        'secret' => env('DING_SECRET',''),
    ],
    'bot1' => [
        // 机器人的access_token  bot1
        'access_token' => env('DING_TOKEN1',''),
        // 加签 （不开启加签则为空）
        'secret' => env('DING_SECRET1',''),
    ],
    'bot2' => [
        // 机器人的access_token  bot2
        'access_token' => env('DING_TOKEN2',''),
        // 加签 （不开启加签则为空）
        'secret' => env('DING_SECRET2',''),
    ],
];
```

### 钉钉推送access\_token

[](#钉钉推送access_token)

- 钉钉推送链接Webhook:[https://oapi.dingtalk.com/robot/send?access\_token=you-push-token](https://oapi.dingtalk.com/robot/send?access_token=you-push-token)
- 发送钉钉机器人的token，即在您创建机器人Webhook之后的access\_token

.env配置

```
DING_TOKEN=you-push-token
```

### 多机器人配置

[](#多机器人配置)

如果想要添加多个机器人，则在`dingbot.php`当中添加机器人名字和对应的token配置即可

```
    'default' => [
        // 机器人的access_token default
        'access_token' => env('DING_TOKEN','4c8ed2083bcd5cc9d38343211900ea29ef7bbef9156ad0892'),
        // 加签 （不开启加签则留空）
        'secret' => env('DING_SECRET',''),
    ],
    'bot1' => [
        // 机器人的access_token  bot1
        'access_token' => env('DING_TOKEN1',''),
        // 加签 （不开启加签则留空）
        'secret' => env('DING_SECRET1',''),
    ],
    'bot2' => [
        // 机器人的access_token  bot2
        'access_token' => env('DING_TOKEN2',''),
        // 加签 （不开启加签则留空）
        'secret' => env('DING_SECRET2',''),
    ]
```

.env配置

```
DING_TOKEN=you-push-token
DING_TOKEN1=you-push-token
```

安全配置
====

[](#安全配置)

### 自定义关键词

[](#自定义关键词)

最多可以设置10个关键词，消息中至少包含其中1个关键词才可以发送成功。 例如添加了一个自定义关键词：监控报警，则这个机器人所发送的消息，必须包含监控报警这个词，才能发送成功。

### 加签

[](#加签)

钉钉创建机器人时选择加签，将`secret`复制到对应配置文件中即可，如果开启加签方式，则必须填写`secret`,否则留空即可

```
DING_SECRET=you-bot-secret
DING_SECRET1=you-bot-secret
DING_SECRET2=you-bot-secret
```

### IP地址（段）

[](#ip地址段)

设定后，只有来自IP地址范围内的请求才会被正常处理。支持两种设置方式：IP地址和IP地址段，暂不支持IPv6地址白名单

使用示例
====

[](#使用示例)

发送纯文字消息
-------

[](#发送纯文字消息)

```
Ding()->text("服务器通知报警,请紧急处理")->send();
```

or

```
(new DingBot())->text('服务器通知报警,请紧急处理')->send();
```

发送消息@指定人员

```
Ding()->text("服务器通知报警,请紧急处理")
->setAtMobiles(['13218899188'])
->send();
```

发送消息@所有人

```
Ding()->text("服务器通知报警,请紧急处理")
->setAtAll()
->send();
```

发送markdown类型的消息
---------------

[](#发送markdown类型的消息)

```
$title = '杭州天气';
$markdown = "#### 杭州天气  \n ".
            "> 9度，@1825718XXXX 西北风1级，空气良89，相对温度73%\n\n ".
            "> ![screenshot](http://i01.lw.aliimg.com/media/lALPBbCc1ZhJGIvNAkzNBLA_1200_588.png)\n".
            "> ###### 10点20分发布 [天气](http://www.thinkpage.cn/) ";

Ding()->markdown($title,$markdown)->send();
```

发送消息@指定人员/所有人 同上

发送链接类型的消息
---------

[](#发送链接类型的消息)

```

$title = "自定义机器人协议";
$text = "群机器人是钉钉群的高级扩展功能。群机器人可以将第三方服务的信息聚合到群聊中，实现自动化的信息同步。例如：通过聚合GitHub，GitLab等源码管理服务，实现源码更新同步；通过聚合Trello，JIRA等项目协调服务，实现项目信息同步。不仅如此，群机器人支持Webhook协议的自定义接入，支持更多可能性，例如：你可将运维报警提醒通过自定义机器人聚合到钉钉群。";
$picUrl = "";
$messageUrl = "https://open-doc.dingtalk.com/docs/doc.htm?spm=a219a.7629140.0.0.Rqyvqo&treeId=257&articleId=105735&docType=1";

Ding()->link($title,$text,$messageUrl,$picUrl)->send();
```

发送ActionCard类型的消息
-----------------

[](#发送actioncard类型的消息)

### 无跳转链接

[](#无跳转链接)

```
$title = "乔布斯 20 年前想打造一间苹果咖啡厅，而它正是 Apple Store 的前身";
$text = "![screenshot](@lADOpwk3K80C0M0FoA) \n".
    " #### 乔布斯 20 年前想打造的苹果咖啡厅 \n\n".
    " Apple Store 的设计正从原来满满的科技感走向生活化，而其生活化的走向其实可以追溯到 20 年前苹果一个建立咖啡馆的计划";

Ding()->actionCard($title,$text,1)->send();
```

### 整体跳转ActionCard类型(single)

[](#整体跳转actioncard类型single)

```
$title = "乔布斯 20 年前想打造一间苹果咖啡厅，而它正是 Apple Store 的前身";
$text = "![screenshot](@lADOpwk3K80C0M0FoA) \n".
    " #### 乔布斯 20 年前想打造的苹果咖啡厅 \n\n".
    " Apple Store 的设计正从原来满满的科技感走向生活化，而其生活化的走向其实可以追溯到 20 年前苹果一个建立咖啡馆的计划";

Ding()->actionCard($title,$text,1)
    ->single("阅读全文","https://www.dingtalk.com/")
    ->send();
```

### 独立跳转ActionCard类型(btns)

[](#独立跳转actioncard类型btns)

```
$title = "乔布斯 20 年前想打造一间苹果咖啡厅，而它正是 Apple Store 的前身";
$text = "![screenshot](@lADOpwk3K80C0M0FoA) \n".
    " #### 乔布斯 20 年前想打造的苹果咖啡厅 \n\n".
    " Apple Store 的设计正从原来满满的科技感走向生活化，而其生活化的走向其实可以追溯到 20 年前苹果一个建立咖啡馆的计划";

Ding()->actionCard($title,$text,1)
    ->addButtons("内容不错","https://www.dingtalk.com/")
    ->addButtons("不感兴趣","https://www.dingtalk.com/")
    ->send();
```

发送FeedCard类型的消息
---------------

[](#发送feedcard类型的消息)

```
       $linksArray = [
            [
                "title"=> "时代的火车向前开1通知",
                "messageURL"=> "https://www.dingtalk.com/",
                "picURL"=> "https://img.alicdn.com/tfs/TB1NwmBEL9TBuNjy1zbXXXpepXa-2400-1218.png"
            ],
            [
                "title"=> "时代的火车向前开2",
                "messageURL"=> "https://www.dingtalk.com/",
                "picURL"=> "https://img.alicdn.com/tfs/TB1NwmBEL9TBuNjy1zbXXXpepXa-2400-1218.png"
            ],
            [
                "title"=> "时代的火车向前开3",
                "messageURL"=> "https://www.dingtalk.com/",
                "picURL"=> "https://img.alicdn.com/tfs/TB1NwmBEL9TBuNjy1zbXXXpepXa-2400-1218.png"
            ],
            [
                "title"=> "时代的火车向前开4",
                "messageURL"=> "https://www.dingtalk.com/",
                "picURL"=> "https://img.alicdn.com/tfs/TB1NwmBEL9TBuNjy1zbXXXpepXa-2400-1218.png"
            ]
        ];
        (new DingBot())->feedCard($linksArray)->send();
        Ding()->feedCard($linksArray)->send();
```

多机器人消息发送
--------

[](#多机器人消息发送)

```
Ding('bot1')->text("服务器通知报警,请紧急处理")->send();
```

or

```
(new DingBot('bot1'))->text('服务器通知报警,请紧急处理')->send();
```

其他消息类型同上

enjoy :)

- 效果 [![file](https://camo.githubusercontent.com/328573a53e17f81cee70581590ad65d1c7f87bf9170164d295031f1106899a31/68747470733a2f2f6c6363646e2e7068706875622e6f72672f75706c6f6164732f696d616765732f3230313830352f32332f363933322f71336e4c434f5062526a2e706e673f696d61676556696577322f322f772f313234302f682f30)](https://camo.githubusercontent.com/328573a53e17f81cee70581590ad65d1c7f87bf9170164d295031f1106899a31/68747470733a2f2f6c6363646e2e7068706875622e6f72672f75706c6f6164732f696d616765732f3230313830352f32332f363933322f71336e4c434f5062526a2e706e673f696d61676556696577322f322f772f313234302f682f30)

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance26

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity39

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

981d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/a0b1f0972b2ba4bf075ef065f72388a40a32c17ab149e3e0b62bb924153cd35e?d=identicon)[iGaoWei](/maintainers/iGaoWei)

---

Top Contributors

[![iGaoWei](https://avatars.githubusercontent.com/u/29043313?v=4)](https://github.com/iGaoWei "iGaoWei (8 commits)")

---

Tags

ding-noticedingbotdingtalkdingtalk-robotlaravellaravelding talkding noticeding bot

### Embed Badge

![Health badge](/badges/dreamcoders-laravel-dingbot/health.svg)

```
[![Health](https://phpackages.com/badges/dreamcoders-laravel-dingbot/health.svg)](https://phpackages.com/packages/dreamcoders-laravel-dingbot)
```

###  Alternatives

[laravel-notification-channels/telegram

Telegram Notifications Channel for Laravel

1.1k3.4M35](/packages/laravel-notification-channels-telegram)[wangju/ding-notice

a dingtalk robot message handle for send message

191182.0k8](/packages/wangju-ding-notice)[s-ichikawa/laravel-sendgrid-driver

This library adds a 'sendgrid' mail driver to Laravel.

4139.3M1](/packages/s-ichikawa-laravel-sendgrid-driver)[laravel-notification-channels/discord

Laravel notification driver for Discord.

2371.3M11](/packages/laravel-notification-channels-discord)[tzsk/sms

A robust and unified SMS gateway integration package for Laravel, supporting multiple providers.

320244.3k6](/packages/tzsk-sms)[erag/laravel-disposable-email

A Laravel package to detect and block disposable email addresses.

226102.4k](/packages/erag-laravel-disposable-email)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
