当前位置: 首页 > Skill >

hermes-dingtalk-media

hermes-dingtalk-media

hermes-dingtalk-media

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.

1.0.2 2026.11.12 163
获取Skill文件查看使用说明
作 者:林宁 许可证: 更新时间:2026.11.12
本文目录收起

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.

推荐文章

更多
PHP时间戳与日期字符串相互转换方法详解

本文介绍PHP中时间数值(Unix时间戳)与日期字符串之间的相互转换方法。通过strtotime和date函数,实现将当前时间、指定日期转换为时间戳,以及将时间戳格式化为可读的日期时间字符串,并提供相关在线计算工具推荐。

2025.11.30 1,034
PHP日期转时间戳时区偏差怎么解决

在 PHP 中将日期字符串转换为时间戳时,若未显式指定时区,默认使用脚本配置的 date.timezone 或系统时区。当服务器时区与业务逻辑预期(如 UTC )不一致时,会产生偏差。解决核心是确保输入字符串携带明确时区信息,或在转换前统一设置时区上下文。

2026.10.24 1,031
PHP跨域配置:怎么安全地允许指定域名而非使用通配符

在 PHP 中安全地允许指定域名跨域,核心是解析请求头中的 Origin ,验证其是否在白名单内,然后动态设置 Access-Control-Allow-Origin 响应头。不要使用通配符 * ,也不要硬编码单一域名。

2025.03.29 1,018
JavaScript中利用replace结合正则实现replaceAll效果

JavaScript原生仅支持replace()进行单次或全局替换,缺乏类似Java的replaceAll()便捷方法。本文总结四种在JS中实现全量替换的方案:使用带g标志的正则、带gm标志的正则、扩展String原型以及split后join。通过对比代码示例,展示各方法的实现细节与适用场景,帮助开发者根据需求选择最优解。

2025.04.29 1,017
OpenAI的Jalapeno芯片未落地,教你分辨300兆瓦算力消息

OpenAI计划在SB Energy租赁的数据中心部署约300兆瓦自研Jalapeno推理芯片,但目前双方仍处于洽谈阶段,交易细节与上线时间表均未公布。本文带你按报道原文核实项目所处阶段,厘清芯片发布、电力功率与实际推理算力的边界,并将融资意向与签约、开工、投运节点分开追踪,避免误将规划容量计入现有算力。

2026.12.02 1,013
PHP实现基础文件上传:HTML表单与$_FILES处理流程

在 HTML 表单中设置 enctype="multipart/form-data" ,并在 PHP 后端通过 $_FILES 数组接收文件,调用 move_uploaded_file() 将临时文件移动到目标目录即可完成上传。

2026.09.07 1,013
Skill 文件
  • SKILL.md
    • Hermes DingTalk Media
    • Bundled Files
    • Core Flow
    • Important Routing Rules
    • Payloads
    • Hermes Implementation Checklist
    • Validation
    • Failure Signals
  • 项目或源文件

相关 Skill

更多
Hermes Deployer Hermes Deployer 在 Linux 服务器上安装、配置、部署和运维 Hermes Agent(Nous Research 出品的自我改进 AI Agent),触发词:hermes、hermes agent、部署 hermes、安装 hermes、hermes gateway、hermes 运维、hermes 排障、hermes 配置。
Hermes Feishu Guide Hermes Feishu Guide Hermes Agent 飞书 Bot 本地部署指南(WebSocket 模式)。包含 Kimi API 配置、WebSocket vs Webhook 对比、环境变量配置等完整步骤。适合本地机器部署,不需要公网域名。
Deepin 侧边栏 SMB 共享书签 Deepin 侧边栏 SMB 共享书签 Deepin 侧边栏 SMB 共享书签 Deepin/UOS 文件管理器一键添加 Windows SMB 共享文件夹侧边栏书签 —— 开机自动重连,无需每次手动挂载。 解决什么问题 你在 Deepin 文件管理器里每次访问 Windows 共享文件夹都要: - 地址栏敲 smb://192.168.x.x/xxx? - 或者每次开机都要 sudo mount -a 手动挂载? 这个 skill 让 Hermes Agent 一步步引导你走完整个配置流程(Windows 端 + Linux 端),最终在文件管理器侧边栏生成一个永久书签。Windows 关机再开机后,点一下侧边栏自动重连,全程零命令行操作。 核心特点 - 交互式引导:加载 skill 后 Hermes Agent 会先问你 Windows 端是否已配好共享,然后收集 IP/用户名/密码,自动完成 Linux 端全部配置 - 开机自动挂载:基于 systemd.automount,访问时按需挂载
Hermes Self Audit Hermes Self Audit 定期审计 Hermes Agent 的自改进行为 - skill 变更、curator 状态、记忆库健康度。防止 Agent 在用户不知情的情况下悄悄进化。建议配合 cronjob 每周运行一次。
Hermes超级开发专家技能 Hermes超级开发专家技能 Comprehensive engineering skill for building large-scale software projects with Hermes Agent. Enables rapid project scaffolding, intelligent subagent orchestration, architecture pattern enforcement, test-driven development, and continuous skill evolution. Use when: (1) Starting a new software project or service, (2) Refactoring or extending existing codebases with 5+ files, (3) Building full-stack applications with frontend+backend+database, (4) Creating microservices or modular architectures, (