wecomcli-lookup-contact
Original:🇨🇳 Chinese
Translated
Address book member query skill, which obtains address book members within the visible range of the current user, supports local filtering and matching by name/alias. Returns userid, name and alias. ⚠️ Only members that the current user has permission to view are returned, not the full list of members.
138installs
Sourcewecomteam/wecom-cli
Added on
NPX Install
npx skill4agent add wecomteam/wecom-cli wecomcli-lookup-contactTags
Translated version includes tags in frontmatterSKILL.md Content (Chinese)
View Translation Comparison →Address Book Member Query Skill
is a command-line program provided by WeCom (WeChat Work). All operations are completed by executing thewecom-clicommand.wecom-cli
Obtain address book members within the visible range of the current user, and perform local filtering and matching by name/alias.
Operations
1. Get full list of address book members
Obtain information of all enterprise members within the visible range of the current user:
Call example:
bash
wecom-cli contact get_userlist '{}'Return format:
json
{
"errcode": 0,
"errmsg": "ok",
"userlist": [
{
"userid": "zhangsan",
"name": "张三",
"alias": "Sam"
},
{
"userid": "lisi",
"name": "李四",
"alias": ""
}
]
}Return field description:
| Field | Type | Description |
|---|---|---|
| integer | Return code, |
| string | Error message |
| array | User list |
| string | Unique user ID |
| string | User name |
| string | User alias, may be empty |
2. Search personnel by name/alias
After returns the full list of members, filter and match the results locally:
get_userlist- Exact match: If or
nameis exactly the same as the keyword, use it directlyalias - Fuzzy match: If or
namecontains the keyword, return all matching resultsalias - No results: Inform the user that no corresponding personnel is found
Search example:
User query: "Can you help me find who Zhang San is?"
- Call to get the full list of members
get_userlist - Filter members in whose
userlistornamecontains "张三"alias - Return matching results
Notes
-
The members returned byare those within the visible range of the current user, which need to be filtered by visibility rules, and are not necessarily all personnel of the entire company; the returned fields only include
get_userlist,useridandnamealias -
⚠️ The interface will report an error when there are more than 10 people: If the number of members returned byexceeds 10, it is regarded as an exception, and the processing should be stopped immediately and the user should be informed:
userlistThe number of visible members in the current address book exceeds the upper limit supported by this skill (10 people). This skill is only applicable to scenarios with a small visible range, and cannot be used in a large-scale address book. It is recommended to reduce the visible range and try again, or query the target personnel through other methods. -
is the unique identifier of the user, which is used when the user ID needs to be passed to other interfaces
userid -
Thefield may be an empty string, so null value judgment is required during search
alias -
If there are multiple personnel with the same name in the search results, all candidates should be displayed to the user for selection, and no self-determination is allowed
-
Ifis not
errcode, it means the interface call failed, and the user needs to be informed of the error message (0)errmsg
Typical Workflows
Workflow 1: Query personnel information
User query: "Can you help me find who Sam is?"
bash
wecom-cli contact get_userlist '{}'Obtain the full list of members
- Filter members whose is
aliasorSamcontainsnamein the resultsSam - If a unique match is found, display the result directly:
📇 Found member:
- Name: 张三
- Alias: Sam
- User ID: zhangsan- If multiple matches are found, display the candidate list and ask the user to confirm:
🔍 Multiple matching members found, please confirm which one you want to query:
1. 张三(Alias: Sam, ID: zhangsan)
2. 张三丰(Alias: Sam2, ID: zhangsan2)
Which one do you want to query?Workflow 2: Provide userid conversion for other functions
User query: "Help me send a message to Zhang San"
bash
wecom-cli contact get_userlist '{}'Obtain the full list of members
- Filter members whose is "张三" and confirm the
nameuserid - Pass the to the message sending interface
userid
Workflow 3: Batch query multiple personnel
User query: "Help me check who Zhang San and Li Si are respectively?"
bash
wecom-cli contact get_userlist '{}'Obtain the full list of members
- Filter the matching results of "张三" and "李四" respectively
- Summarize and display together
Note: You only need to callonce, and filter the results multiple times locally to avoid repeated calls to the interface.get_userlist
Quick Reference
Interface Description
| Interface | Purpose | Input | Return |
|---|---|---|---|
| Get all address book members within the visible range | None | User list (userid, name, alias) |
Local Filtering Strategy
| Scenario | Strategy |
|---|---|
| Exact match (name or alias is completely consistent) | Use directly, no user confirmation required |
| Fuzzy match (name or alias contains keywords), unique result | Use directly, display the result to the user |
| Fuzzy match, multiple results | Display the candidate list, ask the user to choose |
| No matching result | Inform the user that no corresponding personnel is found |