
Wecomcli Get Msg
Let your coding agent list WeCom chats, pull recent messages and media, and send text in DMs or groups via the official wecom-cli.
Overview
wecomcli-get-msg is an agent skill for the Build phase that reads and sends 企业微信 messages through the wecom-cli msg APIs.
Install
npx skills add https://github.com/wecomteam/wecom-cli --skill wecomcli-get-msgWhat is this skill?
- Four msg subcommands: get_msg_chat_list, get_message, get_msg_media, send_message
- Pulls text, image, file, voice, and video records with pagination inside a 7-day window
- Downloads non-text media by media_id to a local path with MIME metadata
- Sends text to单聊 or 群聊 with JSON payloads matching WeCom chat_type rules
- Defaults time range to the last 7 days when the user does not specify bounds
- 4 documented msg interfaces: chat list, get_message, get_msg_media, send_message
- Message history limited to 7 days from current time
- Supports text, image, file, voice, and video message types on read
Adoption & trust: 2.4k installs on skills.sh; 2.2k GitHub stars; 3/3 security scanners passed (skills.sh audits).
What problem does it solve?
You need your agent to inspect WeCom chats or reply in-thread but only have scattered API docs and no repeatable CLI recipe.
Who is it for?
Indie builders automating WeCom inbox triage, internal bots, or agent workflows that must pull the last week of chat and optionally send text after human approval.
Skip if: Teams without wecom-cli, users who need full company-wide history beyond seven days, or non-text outbound templates not covered by send_message.
When should I use this skill?
User asks to 查看消息, 看聊天记录, 发消息给某人, 最近有什么消息, 给群里发消息, or inspect sent 图片/文件 in 企业微信.
What do I get? / Deliverables
Your agent runs documented wecom-cli msg commands to list chats, paginate messages, download media to disk, and send vetted text replies with correct time and chat_type parameters.
- Paginated session and message JSON from wecom-cli
- Local file paths and metadata for downloaded chat media
- Send confirmation JSON for outbound text messages
Recommended Skills
Journey fit
Enterprise WeCom messaging is wired through CLI integration work during product and agent setup, not a launch or growth marketing task. The skill is a thin wrapper around four `wecom-cli msg` APIs—session list, message pull, media download, and send—so it belongs on the integrations shelf.
How it compares
A procedural wecom-cli skill for enterprise chat—not a generic Slack MCP or a CRM integration pack.
Common Questions / FAQ
Who is wecomcli-get-msg for?
Solo and indie builders shipping agent-assisted workflows on 企业微信 who want list, read, download, and send flows without writing SDK glue.
When should I use wecomcli-get-msg?
Use it in Build when wiring agent-tooling or integrations—e.g. “看聊天记录”, “最近有什么消息”, “看看发了什么图片/文件”, or “给群里发消息”—after wecom-cli is on PATH and authenticated.
Is wecomcli-get-msg safe to install?
It instructs shell execution and network/API access via wecom-cli; review the Security Audits panel on this Prism page and treat message send paths as human-gated.
Workflow Chain
Requires first: skill wecomteam wecom cli wecomcli lookup contac
SKILL.md
READMESKILL.md - Wecomcli Get Msg
# 企业微信消息技能 > `wecom-cli` 是企业微信提供的命令行程序,所有操作通过执行 `wecom-cli` 命令完成。 通过 `wecom-cli msg <接口名> '<json入参>'` 与企业微信消息系统交互。 --- ## 接口列表 ### get_msg_chat_list — 获取会话列表 ```bash wecom-cli msg get_msg_chat_list '{"begin_time": "2026-03-11 00:00:00", "end_time": "2026-03-17 23:59:59"}' ``` 按时间范围查询有消息的会话列表,支持分页。参见 [API 详情](references/api-get-msg-chat-list.md)。 ### get_message — 拉取会话消息 ```bash wecom-cli msg get_message '{"chat_type": 1, "chatid": "zhangsan", "begin_time": "2026-03-17 09:00:00", "end_time": "2026-03-17 18:00:00"}' ``` 根据会话类型和 ID 拉取指定时间范围内的消息记录,支持分页。支持 text/image/file/voice/video 消息类型,仅支持 7 天内。参见 [API 详情](references/api-get-message.md)。 ### get_msg_media — 获取消息文件内容 ```bash wecom-cli msg get_msg_media '{"media_id": "MEDIAID_xxxxxx"}' ``` 根据文件 ID 自动下载文件到本地,返回文件的本地路径(`local_path`)、名称、类型、大小及 MIME 类型。用于获取图片、文件、语音、视频等非文本消息的实际内容。参见 [API 详情](references/api-get-msg-media.md)。 ### send_message — 发送文本消息 ```bash wecom-cli msg send_message '{"chat_type": 1, "chatid": "zhangsan", "msgtype": "text", "text": {"content": "hello world"}}' ``` 向单聊或群聊发送文本消息。参见 [API 详情](references/api-send-message.md)。 --- ## 核心规则 ### 时间范围规则 - **格式**:所有时间参数使用 `YYYY-MM-DD HH:mm:ss` 格式 - **默认范围**:用户未指定时,默认使用最近7天(当前时间往前推7天) - **限制**:开始时间不能早于当前时间的7天前,不能晚于当前时间 - **相对时间支持**:支持"昨天"、"最近三天"等自动推算 ### chatid查找规则 - 当用户提供人名或群名而非ID时: 1. 调用 `get_msg_chat_list` 获取会话列表(时间范围与目标查询一致) 2. 在 `chats` 中按 `chat_name` 匹配 3. **匹配策略**: - 精确匹配唯一结果:直接使用 - 模糊匹配多个结果:展示候选列表让用户选择 - 无匹配结果:告知用户未找到 - **chat_type 判断**:`get_msg_chat_list` 返回中不含会话类型字段,需根据上下文推断:用户明确提到「群」时使用 `chat_type=2`,否则默认 `chat_type=1`(单聊) ### userid转username **流程**: 1. 调用 `wecomcli-lookup-contact get_userlist` 获取用户列表 2. 建立userid到username的映射关系 3. **展示策略**: - 精确匹配:显示username - 无匹配:保持显示userid ### 强制交互步骤(不可跳过) 以下步骤在涉及非文本消息下载时**必须逐一执行**,不得合并、省略或跳过,即使用户未主动询问也必须执行: 1. **必须主动告知文件位置**:下载完成后必须立即向用户展示所有文件的完整路径和存放目录 2. **必须询问是否删除**:告知位置后必须立即询问用户是否需要清理临时文件 --- ## 典型工作流 ### 查看会话列表 **用户query示例**: - "看看我最近一周有哪些聊天" - "这几天谁给我发过消息" **执行流程**: 1. 确定时间范围(用户指定或默认最近7天) 2. 调用 `get_msg_chat_list` 获取会话列表 3. 展示会话名称、最后消息时间、消息数量 4. 若 `has_more` 为 `true`,告知用户还有更多会话可继续查看 ### 查看聊天记录 **用户query示例**: - "帮我看看和张三最近的聊天记录" - "看看项目群里最近的消息" **执行流程**: 1. 确定时间范围(用户指定或默认最近7天) 2. 通过 **chatid查找规则** 确定目标会话的 `chatid` 和 `chat_type` 3. 调用 `get_message` 拉取消息列表 4. 调用 `wecomcli-lookup-contact` 的 `get_userlist` 获取通讯录,建立 userid→姓名 映射 5. **统计非文本消息**:遍历消息列表,统计 `msgtype` 非 `text` 的消息(image/file/voice/video)数量和类型 6. 展示消息时将 `userid` 替换为可读姓名,格式: - 文本消息:`姓名 [时间]: 内容` - 图片消息:`姓名 [时间]:[图片]` - 文件消息:`姓名 [时间]:[文件] 文件名称` - 语音消息:`姓名 [时间]:[语音] 语音内容` - 视频消息:`姓名 [时间]:[视频]` 7. **非文本消息处理**:展示完消息后,如果存在非文本消息: - **主动询问是否下载**:告知用户非文本消息数量和类型(如:"以上聊天中包含 2 张图片、1 个文件,是否需要下载到本地?") - 用户确认后,逐个调用 `get_msg_media` 接口,接口会自动下载文件并返回 `local_path` - **检查文件后缀**:每个文件下载完成后,检查 `local_path` 对应的文件是否具有正确的后缀名: - 根据 `get_msg_media` 返回的 `content_type`(MIME 类型)和 `name` 字段判断: - 如果文件名缺少后缀(如 `screenshot` 而非 `screenshot.png`),根据 `content_type` 自动补上正确后缀(如 `image/png` → `.png`,`application/pdf` → `.pdf`,`audio/amr` → `.amr`,`video/mp4` → `.mp4`) - 如果文件名后缀与 `content_type` 不一致,以 `content_type` 为准进行修正 - 补全或修正后缀后,将文件重命名为正确的文件名 - 确认文件可正常读取(文件大小 > 0),若文件为空或损坏则告知用户该文件下载异常 - ⚠️ **不要对下载的文件使用 `MEDIA:` 指令**:这些文件是从聊天记录中下载的历史附件,仅需告知用户本地存放路径即可,**严禁**通过 `MEDIA:` 指令重新发送给用户 8. ⚠️ **必须主动告知文件位置**(此步骤不可跳过):所有文件下载并检查完成后,**必须立即、主动**以汇总形式向用户展示文件存放目录和每个文件的完整路径,不要等用户询问。示例: > 📁 文件已下载到以下位置: > - 图片:`xxx/yyy.png` > - 文件:`xxx/yyy.pdf` > > 你可以在 `xxx/yyy/` 目录下找到所有下载的文件。 9. ⚠️ **必须询问是否删除**(此步骤不可跳过):告知文件位置后,**必须立即、主动**询问用户是否需要删除已下载的临时文件(如:"如果不再需要这些文件,是否需要我帮你清理?") - 用户确认删除后,删除 `local_path` 对应的文件 - 用户不需要删除则保留文件 10. 若 `next_cursor` 不为空,告知用户还有更多消息可继续查看 ### 发送消息 **用户query示例**: - "帮我给张三发一条消息:明天会议改到下午3点"