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
Added on

NPX Install

npx skill4agent add wecomteam/wecom-cli wecomcli-lookup-contact

Tags

Translated version includes tags in frontmatter

SKILL.md Content (Chinese)

View Translation Comparison →

Address Book Member Query Skill

wecom-cli
is a command-line program provided by WeCom (WeChat Work). All operations are completed by executing the
wecom-cli
command.
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:
FieldTypeDescription
errcode
integerReturn code,
0
means success
errmsg
stringError message
userlist
arrayUser list
userlist[].userid
stringUnique user ID
userlist[].name
stringUser name
userlist[].alias
stringUser alias, may be empty

2. Search personnel by name/alias

After
get_userlist
returns the full list of members, filter and match the results locally:
  • Exact match: If
    name
    or
    alias
    is exactly the same as the keyword, use it directly
  • Fuzzy match: If
    name
    or
    alias
    contains the keyword, return all matching results
  • No results: Inform the user that no corresponding personnel is found
Search example:
User query: "Can you help me find who Zhang San is?"
  1. Call
    get_userlist
    to get the full list of members
  2. Filter members in
    userlist
    whose
    name
    or
    alias
    contains "张三"
  3. Return matching results

Notes

  • The members returned by
    get_userlist
    are 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
    userid
    ,
    name
    and
    alias
  • ⚠️ The interface will report an error when there are more than 10 people: If the number of members returned by
    userlist
    exceeds 10, it is regarded as an exception, and the processing should be stopped immediately and the user should be informed:
    The 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.
  • userid
    is the unique identifier of the user, which is used when the user ID needs to be passed to other interfaces
  • The
    alias
    field may be an empty string, so null value judgment is required during search
  • 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
  • If
    errcode
    is not
    0
    , it means the interface call failed, and the user needs to be informed of the error message (
    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
  1. Filter members whose
    alias
    is
    Sam
    or
    name
    contains
    Sam
    in the results
  2. If a unique match is found, display the result directly:
📇 Found member:
- Name: 张三
- Alias: Sam
- User ID: zhangsan
  1. 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
  1. Filter members whose
    name
    is "张三" and confirm the
    userid
  2. Pass the
    userid
    to the message sending interface

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
  1. Filter the matching results of "张三" and "李四" respectively
  2. Summarize and display together
Note: You only need to call
get_userlist
once, and filter the results multiple times locally to avoid repeated calls to the interface.

Quick Reference

Interface Description

InterfacePurposeInputReturn
get_userlist
Get all address book members within the visible rangeNoneUser list (userid, name, alias)

Local Filtering Strategy

ScenarioStrategy
Exact match (name or alias is completely consistent)Use directly, no user confirmation required
Fuzzy match (name or alias contains keywords), unique resultUse directly, display the result to the user
Fuzzy match, multiple resultsDisplay the candidate list, ask the user to choose
No matching resultInform the user that no corresponding personnel is found