wecomcli-msg

Original🇨🇳 Chinese
Translated

WeCom message skill. It provides capabilities including session list query, message record pulling (supports text/image/file/voice/video), multimedia file acquisition and text message sending. It is triggered when users need to "view messages", "check chat records", "send a message to someone", "what are the recent messages", "send a message to the group", "see what pictures/files have been sent".

22installs
Added on

NPX Install

npx skill4agent add wecomteam/wecom-cli wecomcli-msg

Tags

Translated version includes tags in frontmatter

SKILL.md Content (Chinese)

View Translation Comparison →

WeCom Message Skill

wecom-cli
is a command line program provided by WeCom, all operations are completed by executing
wecom-cli
commands.
Interact with WeCom message system through
wecom-cli msg <interface name> '<json input parameters>'
.

Interface List

get_msg_chat_list — Get session 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"}'
Query the list of sessions with messages by time range, pagination is supported. See API Details.

get_message — Pull session messages

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"}'
Pull message records within the specified time range according to session type and ID, pagination is supported. Supports text/image/file/voice/video message types, only supports messages within 7 days. See API Details.

get_msg_media — Get message file content

bash
wecom-cli msg get_msg_media '{"media_id": "MEDIAID_xxxxxx"}'
Automatically download the file to local according to the file ID, return the local path (
local_path
), name, type, size and MIME type of the file. It is used to obtain the actual content of non-text messages such as pictures, files, voice, videos, etc. See API Details.

send_message — Send text message

bash
wecom-cli msg send_message '{"chat_type": 1, "chatid": "zhangsan", "msgtype": "text", "text": {"content": "hello world"}}'
Send text messages to private chats or group chats. See API Details.

Core Rules

Time Range Rules

  • Format: All time parameters use
    YYYY-MM-DD HH:mm:ss
    format
  • Default range: When not specified by the user, the default is the last 7 days (counting back 7 days from the current time)
  • Limit: The start time cannot be earlier than 7 days before the current time, and cannot be later than the current time
  • Relative time support: Supports automatic calculation for "yesterday", "last three days", etc.

chatid Search Rules

  • When the user provides a person name or group name instead of ID:
    1. Call
      get_msg_chat_list
      to get the session list (the time range is consistent with the target query)
    2. Match by
      chat_name
      in
      chats
    3. Matching strategy:
      • Exact match with unique result: use directly
      • Fuzzy match with multiple results: display candidate list for user to choose
      • No matching result: inform the user that no match is found
  • chat_type judgment: The return of
    get_msg_chat_list
    does not contain the session type field, which needs to be inferred from context: use
    chat_type=2
    when the user explicitly mentions "group", otherwise default to
    chat_type=1
    (private chat)

userid to name Conversion

Process:
  1. Call
    get_userlist
    of
    wecomcli-contact
    skill to get user list
  2. Establish mapping relationship from userid to name
  3. Display strategy:
    • Exact match: display name
    • No match: keep displaying userid

Mandatory Interaction Steps (Cannot be skipped)

The following steps must be executed one by one when non-text message download is involved, and shall not be merged, omitted or skipped, even if the user does not actively ask:
  1. Must actively inform the file location: After the download is completed, you must immediately show the user the full path and storage directory of all files
  2. Must ask whether to delete: After informing the location, you must immediately ask the user whether to clean up the temporary files

Typical Workflows

View Session List

User query examples:
  • "See what chats I have had in the last week"
  • "Who sent me messages these days"
Execution process:
  1. Determine the time range (specified by the user or default to the last 7 days)
  2. Call
    get_msg_chat_list
    to get the session list
  3. Display session name, last message time, and number of messages
  4. If
    has_more
    is
    true
    , inform the user that there are more sessions available for further viewing

View Chat Records

User query examples:
  • "Help me check the recent chat records with Zhang San"
  • "Check the recent messages in the project group"
Execution process:
  1. Determine the time range (specified by the user or default to the last 7 days)
  2. Determine the
    chatid
    and
    chat_type
    of the target session according to chatid search rules
  3. Call
    get_message
    to pull the message list
  4. Call
    get_userlist
    of
    wecomcli-contact
    skill to get the address book, and establish userid→name mapping
  5. Count non-text messages: Traverse the message list, count the number and type of messages with
    msgtype
    not
    text
    (image/file/voice/video)
  6. Replace
    userid
    with readable name when displaying messages, format:
    • Text message:
      Name [Time]: Content
    • Image message:
      Name [Time]:[Image]
    • File message:
      Name [Time]:[File] File name
    • Voice message:
      Name [Time]:[Voice] Voice content
    • Video message:
      Name [Time]:[Video]
  7. Non-text message processing: After displaying the messages, if there are non-text messages:
    • Actively ask whether to download: Inform the user of the number and type of non-text messages (e.g.: "The above chat contains 2 pictures and 1 file, do you need to download them to local?")
    • After user confirmation, call
      get_msg_media
      interface one by one, the interface will automatically download the file and return
      local_path
    • Check file suffix: After each file is downloaded, check whether the file corresponding to
      local_path
      has the correct suffix:
      • Judge according to
        content_type
        (MIME type) and
        name
        field returned by
        get_msg_media
        :
        • If the file name lacks a suffix (e.g.
          screenshot
          instead of
          screenshot.png
          ), automatically add the correct suffix according to
          content_type
          (e.g.
          image/png
          .png
          ,
          application/pdf
          .pdf
          ,
          audio/amr
          .amr
          ,
          video/mp4
          .mp4
          )
        • If the file name suffix is inconsistent with
          content_type
          , correct it based on
          content_type
      • After completing or correcting the suffix, rename the file to the correct file name
      • Confirm that the file can be read normally (file size > 0), if the file is empty or damaged, inform the user that the file download is abnormal
    • ⚠️ Do not use
      MEDIA:
      command for downloaded files
      : These files are historical attachments downloaded from chat records, you only need to inform the user of the local storage path, it is strictly forbidden to resend them to the user through
      MEDIA:
      command
  8. ⚠️ Must actively inform the file location (this step cannot be skipped): After all files are downloaded and checked, you must immediately and actively display the file storage directory and the full path of each file to the user in a summary form, do not wait for the user to ask. Example:
    📁 Files have been downloaded to the following locations:
    • Image:
      xxx/yyy.png
    • File:
      xxx/yyy.pdf
    You can find all downloaded files in the
    xxx/yyy/
    directory.
  9. ⚠️ Must ask whether to delete (this step cannot be skipped): After informing the file location, you must immediately and actively ask the user whether to delete the downloaded temporary files (e.g.: "If you no longer need these files, do you want me to clean them up for you?")
    • After the user confirms deletion, delete the file corresponding to
      local_path
    • Keep the file if the user does not need to delete it
  10. If
    next_cursor
    is not empty, inform the user that there are more messages available for further viewing

Send Message

User query examples:
  • "Help me send a message to Zhang San: Tomorrow's meeting is rescheduled to 3 PM"
  • "Send a message in the project group: There is a meeting at 3 PM today"
Execution process:
  1. Determine the
    chatid
    and
    chat_type
    of the target session according to chatid search rules
  2. Confirmation before sending: Confirm the sending object and content with the user (e.g.: "About to send to Zhang San: 'Tomorrow's meeting is rescheduled to 3 PM', confirm to send?"), execute after user confirmation
  3. Call
    send_message
    to send (
    msgtype
    is fixed as
    text
    )
  4. Display the sending result

View Messages and Reply

User query example:
  • "See what Zhang San sent me, then help me reply received"
Execution process:
  1. First execute the "View chat records" process (reuse the obtained
    chatid
    and
    chat_type
    )
  2. After displaying the messages, execute the "Send message" process (need to confirm before sending)

Error Handling

  • Time range exceeded: Inform the user of the 7-day limit and adjust to the valid range
  • Session not found: Clearly inform the user that the corresponding session is not found
  • API error: Display specific error information, retry if necessary
  • Network problem: Actively retry up to 3 times when HTTP error occurs