SKILL.md 1.3 KB


name: wechat-get-contact-list

description: 获取微信通讯录,按好友/群聊/公众号分类返回 wxid 列表。

wechat-get-contact-list

拉取完整通讯录,返回三类 wxid:好友、群聊、公众号。

触发场景

  • 用户问:"我有多少个好友?"
  • 用户问:"加了哪些群?"
  • 需要根据昵称找 wxid 时(先拿列表,再用 wechat-get-contact-detail 查昵称)

执行步骤

API_BASE=$(node -e "console.log(JSON.parse(require('fs').readFileSync(require('path').join(require('os').homedir(),'.openclaw','wechat-credentials.json'),'utf8')).wechatApiBase)")
curl -s --max-time 15 -X POST "$API_BASE/contacts/list" \
  -H "Content-Type: application/json" \
  -d '{}'

响应字段

{
  "ret": 200,
  "data": {
    "friends":   ["wxid_abc...", "wxid_def..."],
    "chatrooms": ["12345@chatroom", "67890@chatroom"],
    "ghs":       ["gh_xxx..."]
  }
}

后续动作

  • 只有 wxid,想看昵称 → wechat-get-contact-detail 传 wxids: [...]
  • 想看和某人的对话 → wechat-get-messages 传 wxid=...

重要提示

  • 列表可能比较大(几百到几千条),向用户汇报时只给数字和前若干条
  • 返回的只是 wxid 字符串,不含昵称;昵称需要 wechat-get-contact-detail 批量查