wecomcli-contact

wecomcli-contact

Popular

Contact member query skill. Retrieves the address book members visible to the current user, supports local filtering by name/alias. Returns userid, name, and alias. ⚠️ Only returns members the current user has permission to see, not the full list.

2.4Kstars
166forks
Updated 7/2/2026
SKILL.md
readonlyread-only
name
wecomcli-contact
description

Contact member query skill. Retrieves the address book members visible to the current user, supports local filtering by name/alias. Returns userid, name, and alias. ⚠️ Only returns members the current user has permission to see, not the full list.

Contact Member Query Skill

wecom-cli is a command-line tool provided by WeCom. All operations are performed by executing wecom-cli commands.

Retrieves the address book members visible to the current user and filters locally by name/alias.

Operations

1. Get All Visible Members

Get all enterprise member information visible to the current user:

Example call:

wecom-cli contact get_userlist '{}'

Return format:

{
    "errcode": 0,
    "errmsg": "ok",
    "userlist": [
        {
            "userid": "zhangsan",
            "name": "张三",
            "alias": "Sam"
        },
        {
            "userid": "lisi",
            "name": "李四",
            "alias": ""
        }
    ]
}

Field descriptions:

Field Type Description
errcode integer Return code, 0 means success
errmsg string Error message
userlist array User list
userlist[].userid string Unique user ID
userlist[].name string User name
userlist[].alias string User alias, may be empty

2. Search by Name/Alias

After get_userlist returns all members, filter locally:

  • Exact match: name or alias exactly matches the keyword, use directly
  • Fuzzy match: name or alias contains the keyword, return all matches
  • No results: Inform the user that no matching person was found

Search example:

User asks: "Find who 张三 is?"

  1. Call get_userlist to get all members
  2. Filter userlist for members whose name or alias contains "张三"
  3. Return matching results

Notes

  • get_userlist returns members visible to the current user, filtered by visibility rules, not necessarily all company personnel; returned fields only include userid, name, and alias

  • ⚠️ Error if more than 10 members: If userlist returns more than 10 members, treat as an error and immediately stop processing, informing the user:

    The number of visible members exceeds the limit of this skill (10).
    This skill is only suitable for small visibility scopes and cannot be used with large address books.
    Please reduce the visibility scope and retry, or query the target person through other means.

  • userid is the unique user identifier; use this field when passing user IDs to other interfaces

  • alias may be an empty string; check for empty values when searching

  • If multiple members have the same name, present all candidates for the user to choose; do not decide on your own

  • If errcode is not 0, the API call failed; inform the user of the error message (errmsg)


Typical Workflows

Workflow 1: Query Person Information

User asks: "Check who Sam is?"

wecom-cli contact get_userlist '{}'

Get all members

  1. Filter members whose alias is Sam or name contains Sam
  2. If a unique match is found, display the result:
📇 Found member:
- Name: 张三
- Alias: Sam
- UserID: zhangsan
  1. If multiple matches are found, show a candidate list for user confirmation:
🔍 Found multiple matching members, please confirm which one you want:

1. 张三 (Alias: Sam, ID: zhangsan)
2. 张三丰 (Alias: Sam2, ID: zhangsan2)

Which one would you like to query?

Workflow 2: Provide userid for Other Functions

User asks: "Send a message to 张三"

wecom-cli contact get_userlist '{}'

Get all members

  1. Filter members with name "张三", confirm userid
  2. Pass userid to the message sending interface

Workflow 3: Batch Query Multiple People

User asks: "Check who 张三 and 李四 are?"

wecom-cli contact get_userlist '{}'

Get all members

  1. Filter results for "张三" and "李四" separately
  2. Summarize and display together

Note: Only call get_userlist once, then filter locally multiple times to avoid repeated API calls.


Quick Reference

API Description

API Purpose Input Return
get_userlist Get all visible members None User list (userid, name, alias)

Local Filtering Strategy

Scenario Strategy
Exact match (name or alias exactly matches) Use directly, no user confirmation needed
Fuzzy match (name or alias contains keyword), unique result Use directly, show result to user
Fuzzy match, multiple results Show candidate list, ask user to choose
No match Inform user that no matching person was found