
wecomcli-contact
PopularContact 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. 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-cliis a command-line tool provided by WeCom. All operations are performed by executingwecom-clicommands.
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:
nameoraliasexactly matches the keyword, use directly - Fuzzy match:
nameoraliascontains the keyword, return all matches - No results: Inform the user that no matching person was found
Search example:
User asks: "Find who 张三 is?"
- Call
get_userlistto get all members - Filter
userlistfor members whosenameoraliascontains "张三" - Return matching results
Notes
-
get_userlistreturns members visible to the current user, filtered by visibility rules, not necessarily all company personnel; returned fields only includeuserid,name, andalias -
⚠️ Error if more than 10 members: If
userlistreturns 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. -
useridis the unique user identifier; use this field when passing user IDs to other interfaces -
aliasmay 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
errcodeis not0, 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
- Filter members whose
aliasisSamornamecontainsSam - If a unique match is found, display the result:
📇 Found member:
- Name: 张三
- Alias: Sam
- UserID: zhangsan
- 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
- Filter members with
name"张三", confirmuserid - Pass
useridto the message sending interface
Workflow 3: Batch Query Multiple People
User asks: "Check who 张三 and 李四 are?"
wecom-cli contact get_userlist '{}'
Get all members
- Filter results for "张三" and "李四" separately
- Summarize and display together
Note: Only call
get_userlistonce, 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 |





