hermes-dingtalk-media

用于 Hermes Agent 的钉钉媒体推送功能开发:包括通过钉钉机器人发送图片或文件、修复媒体附件处理、调试钉钉机器人配置与 robotCode 问题、处理流式模式回调与上传 media_id 流程、区分群组与单聊机器人端点,以及验证原生钉钉图片/文件附件。

安装方式

先用 Prompt 核对来源与依赖。也可下载安装包。

用 AI 助手安装

复制提示词,让助手先核对固定版本和依赖。

查看 Prompt收起 Prompt
先检查当前 Agent 是否已安装 SkillPI Skill Finder。如果尚未安装,请按官方仓库的说明安装并启用:https://github.com/Findskills/skillpi。然后使用 Skill Finder 打开此 SkillPI 详情页并定位 "hermes-dingtalk-media":https://skillpi.com/zh/skills/deepskill-b53fc2fa1a27ff30f7e80b37a1ec7af8c71197175bc441d3218e4f88124f8726。安装前核对上游来源和版本:https://skillhub.cn/skills/user_9ab57f1a/hermes-dingtalk-media。来源不一致时停止并说明差异。核对通过后,用 Skill Finder 安装目标 Skill,并报告安装路径和来源版本。

来源与配置

skillhub.cn

配置方式待核实

请查看原始来源中的适用工具、依赖和权限要求。

安装实测待补充

用于 Hermes Agent 的钉钉媒体推送功能开发:包括通过钉钉机器人发送图片或文件、修复媒体附件处理、调试钉钉机器人配置与 robotCode 问题、处理流式模式回调与上传 media_id 流程、区分群组与单聊机器人端点,以及验证原生钉钉图片/文件附件。

0 下载

介绍来源: third_party · user_9ab57f1a · 1.0.2 参考来源

SkillPi 解读

能完成的任务
翻译待完成,请参阅来源文档。
实测状态
未测试

文件浏览

在原站浏览文件 ↗

原始 SKILL.md

打开原文 ↗
Frontmatter
name: "hermes-dingtalk-media"
description: "Use when working on Hermes Agent DingTalk media delivery: sending images or files from DingTalk bots, fixing MEDIA attachment handling, debugging dingtalk-bot profiles, robotCode issues, Stream Mode callbacks, upload media_id flow, group versus one-to-one robot endpoints, and validating native DingTalk photo/file attachments."

Hermes DingTalk Media

Use this skill when a Hermes DingTalk bot needs to send or receive native media attachments, especially when MEDIA:/absolute/path responses do not arrive as independent DingTalk images/files.

Bundled Files

This Hermes skill includes a non-Hermes-native helper script:

  • scripts/fix_dingtalk_media_support.py: validates that the Hermes source tree contains the DingTalk media implementation, checks required Python modules, runs syntax checks, and can restart a Hermes profile gateway.
  • scripts/send_dingtalk_file.py: sends a local image/file through DingTalk robot media APIs using credentials from a Hermes profile, without modifying Hermes core.

The helpers do not contain credentials. Run the validation helper from any location by passing the Hermes source repository root:

python /path/to/hermes-dingtalk-media/scripts/fix_dingtalk_media_support.py --repo-root "$HERMES_REPO"
python /path/to/hermes-dingtalk-media/scripts/fix_dingtalk_media_support.py --repo-root "$HERMES_REPO" --restart-profile <profile>

If HERMES_REPO points to the Hermes source tree, the --repo-root argument can be omitted.

To validate native DingTalk file delivery without changing Hermes source, send a local file from a configured Hermes profile:

python /path/to/hermes-dingtalk-media/scripts/send_dingtalk_file.py --profile <profile> --target-name "<group-name>" /tmp/example.txt

For one-to-one robot sends, pass a DingTalk staff/user id:

python /path/to/hermes-dingtalk-media/scripts/send_dingtalk_file.py --profile <profile> --user-id "<staff-id>" /tmp/example.txt

Core Flow

  1. Confirm the bot receives callbacks.

    • Look for DingTalk callback received and inbound message: platform=dingtalk.
    • If no callback appears, fix Stream Mode/connectivity first.
  2. Confirm Hermes parsed the media tag.

    • The assistant response should contain MEDIA:/absolute/path/to/file.
    • Gateway logs should show Sending DingTalk media via ... robot API.
  3. Upload the local file to DingTalk.

    • Endpoint: POST https://oapi.dingtalk.com/media/upload
    • Params: access_token, type=image for image extensions, otherwise type=file.
    • Multipart field: media.
    • Use returned media_id / mediaId.
  4. Send the uploaded media_id with the correct robot endpoint.

    • Group chat: POST https://api.dingtalk.com/v1.0/robot/groupMessages/send
    • One-to-one bot chat: POST https://api.dingtalk.com/v1.0/robot/oToMessages/batchSend

Important Routing Rules

  • Do not use privateChatMessages/send for Hermes bot one-to-one media replies. It can return resource.not.found even when upload succeeded.
  • For one-to-one bot media, use oToMessages/batchSend with userIds: [sender_staff_id].
  • For group media, use groupMessages/send with openConversationId.
  • Prefer message.robot_code from the incoming DingTalk callback over configured app/client id. Config fallback is acceptable only when there is no callback context.
  • Keep the incoming callback context by chat_id; it provides conversation_type, robot_code, and sender_staff_id.

Payloads

Group media:

payload = {
    "robotCode": robot_code,
    "openConversationId": chat_id,
    "msgKey": msg_key,
    "msgParam": json.dumps(msg_param, ensure_ascii=False),
}

One-to-one media:

payload = {
    "robotCode": robot_code,
    "userIds": [sender_staff_id],
    "msgKey": msg_key,
    "msgParam": json.dumps(msg_param, ensure_ascii=False),
}

Known media templates to try:

image_candidates = [
    ("sampleImageMsg", {"photoURL": media_id}),
    ("sampleImageMsg", {"mediaId": media_id}),
    ("sampleImage", {"mediaId": media_id}),
]

file_candidates = [
    ("sampleFile", {"mediaId": media_id, "fileName": file_name}),
    ("sampleFileMsg", {"mediaId": media_id, "fileName": file_name}),
]

Hermes Implementation Checklist

In gateway/platforms/dingtalk.py:

  • Implement send_image_file, send_document, and send_video.
  • Resolve inbound downloadCode to local cache files for images/audio/video/documents.
  • Use a cancellable Stream loop instead of dingtalk_stream.DingTalkStreamClient.start() if shutdown or reconnect gets stuck; the SDK can swallow cancellation.
  • Call self._stream_client.pre_start() before opening the Stream connection when replacing SDK start().
  • Log media routing without exposing secrets, for example: Sending DingTalk media via oto robot API; robot_code_source=callback recipient_source=sender_staff_id.

In tools/send_message_tool.py:

  • Support DingTalk MEDIA: extraction.
  • For direct sends without callback context, one-to-one media requires an explicit DingTalk user id/staff id; otherwise default to group sends.

In agent/prompt_builder.py:

  • Add a DingTalk platform hint that native media can be sent with MEDIA:/absolute/path/to/file.

Validation

Run:

cd "$HERMES_REPO"
python -m py_compile gateway/platforms/dingtalk.py tools/send_message_tool.py agent/prompt_builder.py
python /path/to/hermes-dingtalk-media/scripts/fix_dingtalk_media_support.py --repo-root "$HERMES_REPO"
git diff --check
python /path/to/hermes-dingtalk-media/scripts/fix_dingtalk_media_support.py --repo-root "$HERMES_REPO" --restart-profile <profile>

Test image and file delivery separately:

result = await adapter._send_robot_media(
    chat_id=chat_id,
    file_path="/tmp/example.png",
    media_kind="image",
)

result = await adapter._send_robot_media(
    chat_id=chat_id,
    file_path="/tmp/example.txt",
    media_kind="file",
    file_name="example.txt",
)

Expected success shape:

{"success": True, "error": None, "message_id": "..."}

Failure Signals

  • resource.not.found after media/upload: upload worked, but the send endpoint or robotCode/recipient is wrong.
  • robot 不存在: usually wrong robotCode; use callback message.robot_code.
  • private HTTP 400 ... resource.not.found in one-to-one chat: switch from privateChatMessages/send to oToMessages/batchSend.
  • No DingTalk callback received: Stream callback delivery is not reaching Hermes; check bot/app, Stream Mode, competing gateway processes, and profile credentials.

当前收录版本

1.0.2

核对来源版本 ↗

安全与评测信息

质量评测

满分100 · 来自 SkillPi LAB 实验室的评测报告。

场景价值85/100

亮点

  • 针对 Hermes Agent 钉钉机器人媒体传输的具体痛点提供解决方案
  • 涵盖 MEDIA 附件处理、robotCode 问题、Stream Mode 回调、media_id 上传流程等关键环节
  • 提供详细的实现流程、Payload 示例和故障排查指南
触发精准95/100

亮点

  • 触发词覆盖全面,包括发送图片/文件、MEDIA 附件处理、robotCode 问题、Stream Mode 回调等
  • 边界清晰,能有效引导用户在相关开发调试场景下触发
结构规范90/100

待提升项

  • 文档长度 原报告严重程度:轻微

    文档内容较丰富,总行数约 600 行,可能影响阅读体验

    改进建议:建议适当拆分章节或增加目录导航以提升可读性

亮点

  • 结构清晰,包含 Bundled Files、Core Flow、Routing Rules、Payloads、Checklist 等完整章节
  • 提供了端到端的示例和具体命令,frontmatter 完整
执行可靠88/100

亮点

  • 提供了两个辅助脚本用于验证和发送,脚本来源明确,参数说明清晰
  • 覆盖了主要异常场景并提供了解决方案,不可逆操作有明确参数控制
证据可验 (前四项均值)90/100

取前四项原始分值的算术平均,四舍五入取整。可通过收录报告核对各项评分与说明,运行记录需单独查证。

正文静态检测

100 / 100 · skillpi-20261123-no-r3-v1

正文未命中当前规则。

分数仅反映正文中的规则命中,供使用前参考。附件与运行行为不在此评分范围内。

权限与使用前检查

根据当前主文档自动整理,命中内容可能是示例或防护说明;不是实际权限声明,也未覆盖附件、外部依赖或运行行为。

文档引用的域名或地址

这些地址可能用于文档链接或示例,不是已批准的联网清单。使用前核对实际目的地及发送的数据。

  • api.dingtalk.com
  • oapi.dingtalk.com

本站展示提示不会授予权限。涉及文件改动、密钥、外部发送或费用时,仍由你使用的工具按需确认。

安全评级与访问范围

safe · 静态证据核验,不代表运行安全保证。

使用前请由宿主核对并授权实际文件读写、外部服务和联网目的地;本站的核验不会授予任何运行权限。