wecomcli-message
Original:🇨🇳 Chinese
Translated
Query the scope of chat sessions where messages can be sent currently, and send text, Markdown, image, file, voice, and video messages to one-on-one chats or group chats in the session list. Use this when the user requests "send a message to someone", "notify in a certain group", "send a message to recent sessions", or "send images/files/voice/video to WeCom".
11installs
Sourcewecomteam/wecom-cli
Added on
NPX Install
npx skill4agent add wecomteam/wecom-cli wecomcli-messageTags
Translated version includes tags in frontmatterSKILL.md Content (Chinese)
View Translation Comparison →WeCom Message Sending
Before executing anycommand, you must first read and complete the public pre-checks of thewecom-cliskill.wecomcli-shared
- You can send messages to the authorized user.
- You can send messages to chat sessions (one-on-one chats and group chats) that the robot has recently exchanged messages with, excluding the authorized user.
Scope of Application
Applicable Scenarios
- Applicable for sending messages to the authorized user: Use to obtain the authorized user ID, which can be used as
wecom-cli identity whoamiwithout callingchat_id.sessions list - Applicable for querying the scope of chat sessions where you have permission to send messages, and sending Markdown messages, images, files, AMR voice or videos to members or group chats within these scopes
Inapplicable Scenarios
- The recipient is not the authorized user and not in the result returned by this → Inform the user that currently messages can only be sent to recent active sessions or the authorized user
sessions list
Skill Dependencies
Before calling dependent skills, you must fully read the corresponding .
SKILL.md| Dependent Skill | Trigger Scenario | Data Flow |
|---|---|---|
| When sending images, files, voice or videos, only the local file path is available and there is no reusable | Includes media upload interfaces. If there is no existing |
Get the List of Sessions Where Messages Can Be Sent
Command
bash
wecom-cli message aibot sessions listReturn Value
| Field | Type | Description |
|---|---|---|
| array | Session list, sorted by the time of the last message from newest to oldest. The specific quantity is subject to the actual response |
| string | Session ID |
| string | Group name or one-on-one chat name |
| string | |
| string | Time of the last message, format |
| integer | Number of elements in the |
Source of chat_id
chat_idWhen sending messages to users other than the authorized user, before calling , you need to call first, then select the target item from the returned this time, and copy the of that item to as is.
wecom-cli message aibot sendsessions listsessions[]chat_idsend.chat_idThe following values cannot be directly used as :
send.chat_id- ID entered by the user
- saved in previous rounds or historical context
chat_id - returned by
useridwecomcli-contact - Values constructed by yourself based on names, group names or other fields
These values can only be used as matching clues at most; the final sending parameters must be re-obtained from the matching items of this .
sessions listTarget Session Matching
- Chat Name: Exact match by non-empty in this
chat_name; if exact match is not possible, ask the user to confirm the sending target. Copysessions[]from the matching item when there is a unique hit.chat_id - First Recent/Recent Session: Select the item explicitly specified by the user according to the original order of .
sessions[] - User-provided ID: Only perform exact equality check with this ; after hitting, still copy
sessions[].chat_idfrom the matching item, do not directly reuse the user-input value.chat_id
Processing of Matching Results:
- Proceed to send when there is a unique match.
- When there are multiple chat session candidates, display the chat names and last message times in the returned order and let the user choose.
- After the user completes the selection, you must re-call , then match the selected object with the current return value.
sessions list - Stop sending when there is no match, and truthfully inform the user that the target is not in the recent 10 sessions; do not accept external to bypass restrictions.
chat_id - Stop sending when , and inform the user that there are no recent sessions available for sending.
sessions_count=0 - Keep the original order of the interface when displaying the session list; display the name and time, do not show the internal .
chat_id
Send Messages
Preconditions
Before calling this interface, you must complete the following steps:
- Choose to call to obtain
wecom-cli message aibot sessions listorchat_idto obtain the authorized user ID according to the recipient.wecom-cli identity whoami - Uniquely match the target in this list.
- If sending to an object other than the authorized user, copy from the matching item in the list as is.
sessions[].chat_id - Prepare the corresponding when sending media messages.
media_id
Do not upload media or call before the target session is successfully matched.
sendCommand
bash
wecom-cli message aibot send --json '<JSON Parameters>'Public Parameters
| Field | Type | Required | Description |
|---|---|---|---|
| string | Yes | Must be obtained from |
| string | Yes | |
| object | Conditionally Required | Only pass when |
| object | Conditionally Required | Only pass when |
| object | Conditionally Required | Only pass when |
| object | Conditionally Required | Only pass when |
| object | Conditionally Required | Only pass when |
Each request must carry exactly one content object with the same name as . Do not pass empty objects, and do not pass multiple message objects at the same time.
msg_typeMarkdown Messages
markdown.contentbash
wecom-cli message aibot send --json '{
"chat_id": "<Current sessions[].chat_id>",
"msg_type": "markdown",
"markdown": {
"content": "<Markdown Message Content>"
}
}'Image Messages
image.media_idtype=imagebash
wecom-cli message aibot send --json '{
"chat_id": "<Current sessions[].chat_id>",
"msg_type": "image",
"image": {
"media_id": "<media_id>"
}
}'File Messages
file.media_idtype=filebash
wecom-cli message aibot send --json '{
"chat_id": "<Current sessions[].chat_id>",
"msg_type": "file",
"file": {
"media_id": "<media_id>"
}
}'Voice Messages
voice.media_idtype=voicebash
wecom-cli message aibot send --json '{
"chat_id": "<Current sessions[].chat_id>",
"msg_type": "voice",
"voice": {
"media_id": "<media_id>"
}
}'Video Messages
| Field | Required | Description |
|---|---|---|
| Yes | Obtained by uploading via the media upload interface with |
| No | Maximum length of 128 UTF-8 bytes; if omitted, the original file name used during upload is used |
| No | Maximum length of 512 UTF-8 bytes; if omitted, no description is displayed |
bash
wecom-cli message aibot send --json '{
"chat_id": "<Current sessions[].chat_id>",
"msg_type": "video",
"video": {
"media_id": "<media_id>",
"title": "Product Demo",
"description": "Core function demo of this week's version"
}
}'When the user does not provide a video title or description, directly omit the corresponding fields, do not pass empty strings, and do not ask about non-required fields.
Key Constraints
- Execute directly when the user clearly requests to send and the target and content are complete; do not repeatedly ask for confirmation. Only ask for missing items when the target, content or local file is missing.
- When sending multiple messages continuously, you do not need to re-call or
sessions listbefore eachwecom-cli identity whoami, but re-call to ensure the correctness ofsendwhen the context is compressed during continuous sending.chat_id - ,
chat_id, anduseridare internal call values, and it is forbidden to display them to users.media_id - The length limits for Markdown content, video title and description are calculated by UTF-8 bytes; do not silently truncate when exceeding the limit, ask the user to shorten or explicitly agree to split.
- After successful sending, only explain the target and message type, do not fabricate message IDs.
- Truthfully convey errors when the interface fails, do not bypass using curl / Python or other methods.
wecom-cli