---
name: dingtalk-channel-connect-3845642c8421
description: "使用可视浏览器自动完成 CoPaw 的钉钉频道接入。适用于用户提到钉钉、DingTalk、开发者后台、Client ID、Client Secret、机器人、Stream 模式、绑定或配置 channel 的场景；支持遇到登录页时暂停，等待用户登录后继续。"
metadata:
  {
    "copaw":
      {
        "emoji": "🤖",
        "requires": {}
      }
  }
---

# 钉钉 Channel 自动连接（可视浏览器）

此 skill 用于通过可视浏览器自动化完成钉钉应用创建与 CoPaw channel 绑定。

## 强制规则

1. 必须使用可视浏览器模式启动：

```json
{"action": "start", "headed": true}
```

2. 遇到登录关卡必须暂停：
   - 若页面出现登录界面（如 `登录`、扫码登录、手机号/密码登录），立即停止自动操作。
   - 明确提示用户先手动登录，再等待用户回复“登录好了/继续”。
   - 未收到用户确认前，不得继续执行后续步骤。

3. 任何应用配置变更都必须新建版本并发布后才生效：
   - 配置完机器人相关信息后**一定要发布机器人**
   - 不论是新建应用还是修改应用信息（名称、描述、图标、机器人配置等），最终都**必须执行“创建新版本 + 发布”**。
   - 若未完成发布，不得宣称配置已生效。

## 执行前显著确认（必须先做）

在开始自动化点击前，先向用户发起一次“配置确认”，明确告知可自定义项、图片规范、默认值。建议使用如下结构化确认：

1. 让用户可自定义以下字段：
   - 应用名称
   - 应用描述
   - 机器人图标图片链接或本地路径
   - 机器人消息预览图链接或本地路径

2. 明确告知图片规范（显著提示）：
   - 机器人图标：仅支持 JPG/PNG，`240*240px` 以上，`1:1`，`2MB` 以内，无圆角。
   - 机器人消息预览图：格式 `png/jpeg/jpg`，不超过 `2MB`。

3. 明确告知默认值（用户不指定时自动采用）：
   - 应用名称：`CoPaw`
   - 应用描述：`Your personal assistant`
   - 机器人图标：`https://img.alicdn.com/imgextra/i4/O1CN01M0iyHF1FVNzM9qjC0_!!6000000000492-2-tps-254-254.png`
   - 机器人消息预览图：`https://img.alicdn.com/imgextra/i4/O1CN01M0iyHF1FVNzM9qjC0_!!6000000000492-2-tps-254-254.png`

4. 若用户未给任何自定义值，必须先明确回复：
   - “将全部采用默认设置（CoPaw / Your personal assistant / 默认图片）后继续执行。”

## 图片上传策略（link/path 都支持）

1. 若用户提供本地路径，直接用于上传。
2. 若用户提供图片 link，先下载到本地临时文件，再执行上传。
3. 上传动作顺序必须是：
   - 先点击页面上传入口（触发 chooser）
   - 再调用 `file_upload` 传入本地路径数组（`paths_json`）
4. 若上传报错且判断为图片规格不符合（尺寸、比例、大小、格式）：
   - 立即暂停自动化
   - 明确让用户手动上传符合规范的图片
   - 用户确认“已上传/继续”后，从当前步骤继续后续流程

### 上传动作实战经验

1. `file_upload` 的 `paths_json` 必须是“JSON 字符串数组”，注意转义：

```json
{
  "action": "file_upload",
  "paths_json": "[\"xxx.png\"]",
  "frame_selector": "iframe[src*=\"/fe/app?isHideOuterFrame=true\"]"
}
```

2. 若页面在 iframe 内，建议优先带上 `frame_selector`，否则可能出现找不到上传控件或 chooser 未触发。

3. 上传前必须先点击上传入口；若直接 `file_upload` 会报：
   - `No chooser. Click upload then file_upload.`

4. 机器人图标区域的常见结构特征可用于定位（示例）：
   - `text: "* 机器人图标"`
   - `button: "使用应用图标"`
   - `button: "avatar"`（通常内部有 `img "avatar"`）

5. 当 snapshot 中同时出现“使用应用图标”和“avatar”时，优先点击 `avatar` 按钮触发上传，再执行 `file_upload`。

## 自动化流程

### 步骤 1：打开钉钉开发者后台

1. 可视模式启动浏览器（`headed: true`）
2. 打开 `https://open-dev.dingtalk.com/`
3. 调用 `snapshot` 判断是否需要登录

若需要登录，使用如下话术暂停：

> 检测到需要登录钉钉开发者后台。我已暂停自动操作，请先在弹出的浏览器中完成登录。完成后回复“继续”，我再从当前页面接着执行。

### 步骤 2：创建企业内部应用

用户确认登录后继续：

1. 进入创建路径：
   - 应用开发 -> 企业内部应用 -> 钉钉应用 -> 创建应用
2. 填写应用信息（优先使用用户自定义，否则使用默认值）：
   - 应用名称：默认 `CoPaw`
   - 应用描述：默认 `Your personal assistant`
3. 保存并创建应用

若页面文案或结构与预期不一致，重新 `snapshot`，按可见文本语义重新定位元素。

### 步骤 3：添加机器人能力并发布

1. 点击**应用能力**中的**添加应用能力**，找到**机器人**并添加
2. 将**机器人配置**右侧的switch按钮切换为打开
3. 填写**机器人名称**，**机器人简介**和**机器人描述**
4. 上传**机器人图标**（用户自定义或默认图）：
   - 点击机器人图标下面的图片
   - 默认图链接：`https://img.alicdn.com/imgextra/i4/O1CN01M0iyHF1FVNzM9qjC0_!!6000000000492-2-tps-254-254.png`
   - 若为 link，先下载到本地再上传
   - 若提示图片不合规，暂停并让用户手动上传合规图片后继续
5. 上传**机器人消息预览图**（用户自定义或默认图）：
   - 点击机器人消息预览图下面的图片
   - 默认图链接：`https://img.alicdn.com/imgextra/i4/O1CN01M0iyHF1FVNzM9qjC0_!!6000000000492-2-tps-254-254.png`
   - 若为 link，先下载到本地再上传
   - 若提示图片不合规，暂停并让用户手动上传合规图片后继续
6. 确认消息接收模式设置为 `Stream 模式`
7. 选择**发布**，此时会有进一步弹出的确认页面，选择发布。注意：**一定要发布机器人**之后再进行下一步

### 步骤 4：创建版本并发布

1. 打开 `应用发布 -> 版本管理与发布`
2. 创建新版本（每次配置变更后都要创建）
3. 填写版本描述，应用可见范围选择全部员工
4. 按页面提示完成发布，此时会有新的弹窗出现，选择确认发布
5. 只有看到发布成功状态，才可继续执行后续步骤/给用户“已生效”结论

### 步骤 5：获取凭证

1. 打开 `基础信息 -> 凭证与基础信息`
2. 告知用户`Client ID`（AppKey）和`Client Secret`（AppSecret）在该页面上。不主动进行修改，引导用户自行绑定

## CoPaw 绑定方式

拿到凭证后，引导用户选择以下任一方式：

1. 控制台前端配置：
   - CoPaw console 中进入 `控制 -> 频道 -> DingTalk`
   - 填入 `Client ID` 与 `Client Secret`

2. 配置文件方式：

```json
"dingtalk": {
  "enabled": true,
  "bot_prefix": "[BOT]",
  "client_id": "你的 Client ID",
  "client_secret": "你的 Client Secret"
}
```

路径：`~/.copaw/config.json`，位于 `channels.dingtalk` 下。

### 凭证交付要求（强制）

1. agent 只负责引导用户进入凭证页、获取并展示 `Client ID` 与真实 `Client Secret`。
2. agent 不主动改 `console` 配置、不主动改 `~/.copaw/config.json`。
3. 必须提示用户按以下两种方式之一手动填写：
   - 控制台前端：`控制 -> 频道 -> DingTalk`
   - 配置文件：编辑 `~/.copaw/config.json` 的 `channels.dingtalk` 字段

## Browser 工具调用模式

默认按以下顺序执行：

1. `start` with `headed: true`
2. `open`
3. `snapshot`
4. `click` / `type` / `select_option` / `press_key` as needed
5. frequent `snapshot` after page transitions
6. `stop` when done

## 稳定性与恢复策略

- 优先使用最新 `snapshot` 的 `ref`；仅在必要时使用 `selector`。
- 每次关键点击或跳转后，使用短等待（`wait_for`）并立即重新 `snapshot`。
- 若中途会话失效或要求重新登录，必须再次暂停，待用户登录后从当前步骤继续。
- 若因租户权限、管理员审批等阻塞自动化，明确说明卡点，并请用户手动完成该步骤后再续跑。

---
Source attribution: Endsi3g
Original project: https://github.com/Endsi3g/M.Alfred-The-personal-assistant-of-Uprising-Studio-/blob/9d41adf0685abd7f610d931920fe1e9e96e590a1/modules/copaw_lib/src/copaw/agents/skills/dingtalk_channel/SKILL.md
License: Apache-2.0
License information: https://www.apache.org/licenses/LICENSE-2.0
Original upstream instructions; downloaded from Mega AI Hub.

## Upstream license notice

                                 Apache License
                           Version 2.0, January 2004
                        http://www.apache.org/licenses/

   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION

   1. Definitions.

      "License" shall mean the terms and conditions for use, reproduction,
      and distribution as defined by Sections 1 through 9 of this document.

      "Licensor" shall mean the copyright owner or entity authorized by
      the copyright owner that is granting the License.

      "Legal Entity" shall mean the union of the acting entity and all
      other entities that control, are controlled by, or are under common
      control with that entity. For the purposes of this definition,
      "control" means (i) the power, direct or indirect, to cause the
      direction or management of such entity, whether by contract or
      otherwise, or (ii) ownership of fifty percent (50%) or more of the
      outstanding shares, or (iii) beneficial ownership of such entity.

      "You" (or "Your") shall mean an individual or Legal Entity
      exercising permissions granted by this License.

      "Source" form shall mean the preferred form for making modifications,
      including but not limited to software source code, documentation
      source, and configuration files.

      "Object" form shall mean any form resulting from mechanical
      transformation or translation of a Source form, including but
      not limited to compiled object code, generated documentation,
      and conversions to other media types.

      "Work" shall mean the work of authorship, whether in Source or
      Object form, made available under the License, as indicated by a
      copyright notice that is included in or attached to the work
      (an example is provided in the Appendix below).

      "Derivative Works" shall mean any work, whether in Source or Object
      form, that is based on (or derived from) the Work and for which the
      editorial revisions, annotations, elaborations, or other modifications
      represent, as a whole, an original work of authorship. For the purposes
      of this License, Derivative Works shall not include works that remain
      separable from, or merely link (or bind by name) to the interfaces of,
      the Work and Derivative Works thereof.

      "Contribution" shall mean any work of authorship, including
      the original version of the Work and any modifications or additions
      to that Work or Derivative Works thereof, that is intentionally
      submitted to the Licensor for inclusion in the Work by the copyright owner
      or by an individual or Legal Entity authorized to submit on behalf of
      the copyright owner. For the purposes of this definition, "submitted"
      means any form of electronic, verbal, or written communication sent
      to the Licensor or its representatives, including but not limited to
      communication on electronic mailing lists, source code control systems,
      and issue tracking systems that are managed by, or on behalf of, the
      Licensor for the purpose of discussing and improving the Work, but
      excluding communication that is conspicuously marked or otherwise
      designated in writing by the copyright owner as "Not a Contribution."

      "Contributor" shall mean Licensor and any individual or Legal Entity
      on behalf of whom a Contribution has been received by Licensor and
      subsequently incorporated within the Work.

   2. Grant of Copyright License. Subject to the terms and conditions of
      this License, each Contributor hereby grants to You a perpetual,
      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
      copyright license to reproduce, prepare Derivative Works of,
      publicly display, publicly perform, sublicense, and distribute the
      Work and such Derivative Works in Source or Object form.

   3. Grant of Patent License. Subject to the terms and conditions of
      this License, each Contributor hereby grants to You a perpetual,
      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
      (except as stated in this section) patent license to make, have made,
      use, offer to sell, sell, import, and otherwise transfer the Work,
      where such license applies only to those patent claims licensable
      by such Contributor that are necessarily infringed by their
      Contribution(s) alone or by combination of their Contribution(s)
      with the Work to which such Contribution(s) was submitted. If You
      institute patent litigation against any entity (including a
      cross-claim or counterclaim in a lawsuit) alleging that the Work
      or a Contribution incorporated within the Work constitutes direct
      or contributory patent infringement, then any patent licenses
      granted to You under this License for that Work shall terminate
      as of the date such litigation is filed.

   4. Redistribution. You may reproduce and distribute copies of the
      Work or Derivative Works thereof in any medium, with or without
      modifications, and in Source or Object form, provided that You
      meet the following conditions:

      (a) You must give any other recipients of the Work or
          Derivative Works a copy of this License; and

      (b) You must cause any modified files to carry prominent notices
          stating that You changed the files; and

      (c) You must retain, in the Source form of any Derivative Works
          that You distribute, all copyright, patent, trademark, and
          attribution notices from the Source form of the Work,
          excluding those notices that do not pertain to any part of
          the Derivative Works; and

      (d) If the Work includes a "NOTICE" text file as part of its
          distribution, then any Derivative Works that You distribute must
          include a readable copy of the attribution notices contained
          within such NOTICE file, excluding those notices that do not
          pertain to any part of the Derivative Works, in at least one
          of the following places: within a NOTICE text file distributed
          as part of the Derivative Works; within the Source form or
          documentation, if provided along with the Derivative Works; or,
          within a display generated by the Derivative Works, if and
          wherever such third-party notices normally appear. The contents
          of the NOTICE file are for informational purposes only and
          do not modify the License. You may add Your own attribution
          notices within Derivative Works that You distribute, alongside
          or as an addendum to the NOTICE text from the Work, provided
          that such additional attribution notices cannot be construed
          as modifying the License.

      You may add Your own copyright statement to Your modifications and
      may provide additional or different license terms and conditions
      for use, reproduction, or distribution of Your modifications, or
      for any such Derivative Works as a whole, provided Your use,
      reproduction, and distribution of the Work otherwise complies with
      the conditions stated in this License.

   5. Submission of Contributions. Unless You explicitly state otherwise,
      any Contribution intentionally submitted for inclusion in the Work
      by You to the Licensor shall be under the terms and conditions of
      this License, without any additional terms or conditions.
      Notwithstanding the above, nothing herein shall supersede or modify
      the terms of any separate license agreement you may have executed
      with Licensor regarding such Contributions.

   6. Trademarks. This License does not grant permission to use the trade
      names, trademarks, service marks, or product names of the Licensor,
      except as required for reasonable and customary use in describing the
      origin of the Work and reproducing the content of the NOTICE file.

   7. Disclaimer of Warranty. Unless required by applicable law or
      agreed to in writing, Licensor provides the Work (and each
      Contributor provides its Contributions) on an "AS IS" BASIS,
      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
      implied, including, without limitation, any warranties or conditions
      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
      PARTICULAR PURPOSE. You are solely responsible for determining the
      appropriateness of using or redistributing the Work and assume any
      risks associated with Your exercise of permissions under this License.

   8. Limitation of Liability. In no event and under no legal theory,
      whether in tort (including negligence), contract, or otherwise,
      unless required by applicable law (such as deliberate and grossly
      negligent acts) or agreed to in writing, shall any Contributor be
      liable to You for damages, including any direct, indirect, special,
      incidental, or consequential damages of any character arising as a
      result of this License or out of the use or inability to use the
      Work (including but not limited to damages for loss of goodwill,
      work stoppage, computer failure or malfunction, or any and all
      other commercial damages or losses), even if such Contributor
      has been advised of the possibility of such damages.

   9. Accepting Warranty or Additional Liability. While redistributing
      the Work or Derivative Works thereof, You may choose to offer,
      and charge a fee for, acceptance of support, warranty, indemnity,
      or other liability obligations and/or rights consistent with this
      License. However, in accepting such obligations, You may act only
      on Your own behalf and on Your sole responsibility, not on behalf
      of any other Contributor, and only if You agree to indemnify,
      defend, and hold each Contributor harmless for any liability
      incurred by, or claims asserted against, such Contributor by reason
      of your accepting any such warranty or additional liability.

   END OF TERMS AND CONDITIONS

   Copyright 2025 The CoPaw Authors

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.



# Mega AI Hub resource metadata

Creator / publisher: Endsi3g
Original project: https://github.com/Endsi3g/M.Alfred-The-personal-assistant-of-Uprising-Studio-/blob/9d41adf0685abd7f610d931920fe1e9e96e590a1/modules/copaw_lib/src/copaw/agents/skills/dingtalk_channel/SKILL.md
Attribution basis: Source repository record

Fields of work: Marketing, Sales
Roles: Customer Success Manager, Growth Marketer, Product Marketer
Specialties: API
Tools: Dingtalk
Country applicability: Country not specified
Classification basis: Source catalog labels
Instruction SHA-256: c2f44a60f2e195076426c1ffb0bfb5b8dab6c3ed13019342db7b314ea962c131
