MCPInstall

wecom-automation

企业微信个人账号直连自动化。基于 Wechaty 框架实现企业微信消息接收、自动同意好友、知识库问答、人工介入提醒。适用于企业微信个人机器人和自动化助手场景。

Installs
445
Last 24h
—
Trending rank
—
Security
Not audited

Install

Works with every agent the skills CLI supports.

npx skills add https://github.com/aaaaqwq/agi-super-team --skill wecom-automation
  1. 01

    Install

    Run the command in your project. The CLI asks which agents to install for.

  2. 02

    Describe the task

    Ask your agent for something this skill covers. It loads wecom-automation automatically when relevant.

  3. 03

    Review the result

    The agent follows the SKILL.md steps, scripts and references bundled with the skill.

SKILL.md

The instructions your agent reads when the skill is triggered.

企业微信个人账号直连自动化

基于 Wechaty 框架连接企业微信个人账号,实现完整的 AI 助手功能。适用于企业微信机器人、自动化客服、个人助手等场景。

核心功能

1. 自动同意好友添加

  • 监听好友请求事件
  • 自动通过好友验证
  • 发送个性化欢迎消息
  • 标注用户信息和来源

2. 智能问答(基于知识库)

  • 向量知识库存储企业知识
  • 语义搜索匹配问题
  • LLM 生成专业回复
  • 支持多轮对话上下文

3. 人工介入提醒

  • 置信度阈值自动判断
  • 通过 Telegram/飞书通知人工
  • 记录未解决问题用于优化
  • 平滑转接到人工客服

4. 消息类型支持

  • 文本消息(问答、对话)
  • 图片消息(OCR、识别)
  • 文件消息(DOCX、PDF 等)
  • 语音消息(转文字、语音交互)
  • 链接消息(预览、摘要)
  • 名片消息(保存、处理)

技术架构

┌──────────────┐
│  企业微信     │
│  个人账号     │
└──────┬───────┘
       │
       ▼
┌──────────────────┐
│   Wechaty        │
│   (PadLocal)     │
└──────┬───────────┘
       │
       ▼
┌────────────────────┐
│  OpenClaw Gateway  │
│  (消息分发、处理)   │
└──────┬─────────────┘
       │
       ├──────────────┬──────────────┐
       │              │              │
       ▼              ▼              ▼
┌──────────┐   ┌──────────┐   ┌──────────┐
│ 向量知识库 │   │  LLM API  │   │ 通知服务  │
│(PG+pgvec)│   │ (Kimi/GPT)│   │(Telegram)│
└──────────┘   └──────────┘   └──────────┘

快速开始

方案选择

企业微信个人账号直连有两种方案:

方案 A:Wechaty + PadLocal(推荐,适合个人)

优点:

  • 配置简单,快速上手
  • 稳定性高,官方维护
  • 支持所有消息类型
  • 适合个人使用

缺点:

  • PadLocal 需要付费(约 50 元/月)
  • 单账号限制

适用场景:个人助手、小规模客服

方案 B:企业微信内部应用 API(适合企业)

优点:

  • 官方 API,免费使用
  • 稳定性最高
  • 支持大规模部署

缺点:

  • 需要企业认证
  • 配置相对复杂
  • 功能受限于 API

适用场景:企业客服、大规模应用

本技能使用方案 A(Wechaty + PadLocal)

第一步:申请 PadLocal Token

  1. 访问 https://github.com/wechaty/wechaty
  2. 选择 "PadLocal" 协议
  3. 注册账号并获取 Token
  4. 保存 Token 到 pass:
pass insert api/wechaty-padlocal

第二步:安装依赖

# 1. 安装 Node.js 依赖
cd ~/clawd/skills/wecom-automation
npm install

# 2. 安装 Python 依赖
pip3 install -r requirements.txt

# 3. 配置环境变量
cp .env.example .env

第三步:配置环境变量

编辑 ~/clawd/skills/wecom-automation/.env:

# Wechaty 配置
WECHATY_PUPPET=padlocal
WECHATY_TOKEN=$(pass show api/wechaty-padlocal)
WECHATY_LOG_LEVEL=info

# 企业微信账号配置
WECOM_NAME="企业微信机器人"
WECOM_QR_CODE_PATH=/tmp/wecom_qrcode.png

# 知识库配置
KB_DB_URL=postgresql://postgres@localhost/wecom_kb
KB_SIMILARITY_THRESHOLD=0.7
KB_TOP_K=3

# LLM 配置
LLM_PROVIDER=kimi
LLM_API_KEY=$(pass show api/kimi)
LLM_API_BASE=https://api.moonshot.cn/v1
LLM_MODEL=moonshot-v1-8k

# 人工介入通知
NOTIFICATION_CHANNEL=telegram:8518085684
NOTIFICATION_ENABLED=true

# OpenClaw Gateway 配置
GATEWAY_URL=http://localhost:8080
GATEWAY_TOKEN=$(pass show api/openclaw-gateway)

第四步:初始化数据库

# 创建数据库
sudo -u postgres createdb wecom_kb

# 初始化表结构
psql wecom_kb < ~/clawd/skills/wecom-automation/schema.sql

# 导入示例知识库
python3 ~/clawd/skills/wecom-automation/scripts/import_kb.py \
  --input ~/clawd/skills/wecom-automation/knowledge/sample.md \
  --category "常见问题" \
  --key "$(pass show api/kimi)"

第五步:启动机器人

# 方式 1:直接运行
cd ~/clawd/skills/wecom-automation
npm start

# 方式 2:通过 PM2(推荐)
pm2 start ~/clawd/skills/wecom-automation/ecosystem.config.js

# 查看日志
pm2 logs wecom-bot

第六步:扫码登录

启动机器人后会显示二维码:

██████████████████████████████████
██                              ██
██  1. 打开企业微信 → 扫一扫    ██
██  2. 扫描下方二维码登录      ██
██                              ██
██████████████████████████████████

[二维码图片]

使用企业微信扫码登录后,机器人即可正常工作。

使用方法

场景 1:新好友自动欢迎

// workflows/on_friend_add.js
const { Contact } = require('wechaty')

bot.on('friendship', async friendship => {
  if (friendship.type() === Friendship.Type.Receive) {
    const contact = friendship.contact()

    // 自动通过好友请求
    await friendship.accept()

    // 发送欢迎消息
    await contact.say(`👋 欢迎来到${contact.name()}!

我是智能助手小a,可以帮您:
• 解答常见问题
• 处理售后请求
• 查询订单状态

如有复杂问题,我会转接人工客服为您服务。`)

    // 添加到数据库
    await saveUser(contact)
  }
})

场景 2:知识库问答

// workflows/answer_question.js
const { Message } = require('wechaty')

bot.on('message', async msg => {
  if (msg.type() === Message.Type.Text) {
    const text = msg.text()
    const from = msg.from()

    // 搜索知识库
    const results = await searchKnowledge(text)

    // 生成答案
    const answer = await generateAnswer(text, results)

    // 判断是否需要人工介入
    if (answer.confidence < 0.7) {
      await escalateToHuman(from, text, answer)
    } else {
      await msg.say(answer.text)
    }
  }
})

场景 3:文件处理(DOCX/PDF)

// workflows/handle_file.js
const { Message } = require('wechaty')

bot.on('message', async msg => {
  if (msg.type() === Message.Type.Attachment) {
    const file = await msg.toFileBox()

    // 下载文件
    const filePath = `/tmp/${file.name}`
    await file.toFile(filePath)

    // 处理文件(提取内容、分析等)
    const content = await extractFileContent(filePath)

    // 发送回复
    await msg.say(`✅ 已收到文件:${file.name}\n\n正在处理...`)

    // 处理后回复
    await processAndReply(msg, content)
  }
})

场景 4:人工介入提醒

// workflows/escalate.js
async function escalateToHuman(contact, question, answer) {
  // 1. 发送用户消息
  await contact.say('⏳ 已为您转接人工客服,请稍候...')

  // 2. 通过 Telegram 通知人工客服
  const notification = `🚨 需要人工介入

用户:${contact.name()}
问题:${question}
时间:${new Date().toLocaleString()}

请及时处理。`

  await sendTelegramNotification(notification)

  // 3. 记录未解决问题
  await saveUnknownQuestion(contact, question)
}

目录结构

~/clawd/skills/wecom-automation/
├── SKILL.md                    # 本文件
├── package.json                # Node.js 依赖
├── requirements.txt            # Python 依赖
├── ecosystem.config.js         # PM2 配置
├── .env.example                # 环境变量模板
├── schema.sql                  # 数据库表结构
├── bot.js                      # Wechaty 机器人主文件
├── config/
│   ├── knowledge.js            # 知识库配置
│   └── escalation.js           # 人工介入规则
├── workflows/
│   ├── on_friend_add.js        # 好友添加处理
│   ├── answer_question.js      # 问答处理
│   ├── handle_file.js          # 文件处理
│   └── escalate.js             # 人工介入
├── lib/
│   ├── knowledge.js            # 知识库操作
│   ├── llm.js                  # LLM 调用
│   ├── notification.js         # 通知服务
│   └── database.js             # 数据库操作
└── knowledge/
    └── sample.md               # 示例知识文档

API 参考文档

企业微信 API 文档

Wechaty 文档

Kimi API 文档

高级功能

1. 多轮对话记忆

// 使用 Redis 存储会话上下文
const redis = require('redis')
const client = redis.createClient()

async function getConversationHistory(userId) {
  const history = await client.get(`conv:${userId}`)
  return history ? JSON.parse(history) : []
}

async function appendMessage(userId, role, content) {
  const history = await getConversationHistory(userId)
  history.push({ role, content, timestamp: Date.now() })
  await client.set(`conv:${userId}`, JSON.stringify(history))
}

2. 文件处理

// 提取 DOCX 内容
const docx = require('docx')

async function extractDocx(filePath) {
  const doc = await docx.Document.read(filePath)
  const text = doc.paragraphs.map(p => p.text).join('\n')
  return text
}

// 提取 PDF 内容
const pdf = require('pdf-parse')

async function extractPdf(filePath) {
  const data = await fs.readFile(filePath)
  const result = await pdf(data)
  return result.text
}

3. 语音转文字

# 使用 Whisper API
import openai

def transcribe_audio(audio_path):
    with open(audio_path, "rb") as audio:
        transcript = openai.Audio.transcribe(
            model="whisper-1",
            file=audio
        )
    return transcript["text"]

4. 图片 OCR

# 使用 Kimi Vision
import openai

def ocr_image(image_path):
    with open(image_path, "rb") as image:
        result = openai.chat.completions.create(
            model="gemini-2.5-pro",
            messages=[{
                "role": "user",
                "content": "识别图片中的文字"
            }],
            image=image
        )
    return result.choices[0].message.content

监控与维护

日志查看

# PM2 日志
pm2 logs wecom-bot

# 错误日志
pm2 logs wecom-bot --err

# 实时日志
pm2 logs wecom-bot --lines 100

性能监控

// 添加自定义指标
const prometheus = require('prom-client')

const messageCounter = new prometheus.Counter({
  name: 'wecom_messages_total',
  help: 'Total messages received',
  labelNames: ['type']
})

const answerLatency = new prometheus.Histogram({
  name: 'wecom_answer_latency_seconds',
  help: 'Answer generation latency',
  buckets: [0.1, 0.5, 1, 2, 5, 10]
})

人工介入统计

-- 查看未解决问题分布
SELECT
    COUNT(*) as count,
    SUBSTRING(question, 1, 30) as question_preview
FROM unknown_questions
GROUP BY question_preview
ORDER BY count DESC
LIMIT 10;

-- 查看每日介入次数
SELECT
    DATE(created_at) as date,
    COUNT(*) as escalations
FROM escalation_log
GROUP BY DATE(created_at)
ORDER BY date DESC
LIMIT 7;

故障排查

问题 1:无法扫码登录

# 检查 Wechaty 日志
pm2 logs wecom-bot --lines 50

# 重启机器人
pm2 restart wecom-bot

# 清理缓存
rm -rf /tmp/wechaty*
pm2 restart wecom-bot

问题 2:消息不回复

# 检查知识库连接
psql wecom_kb -c "SELECT COUNT(*) FROM knowledge_chunks;"

# 测试 LLM API
curl -X POST https://api.moonshot.cn/v1/chat/completions \
  -H "Authorization: Bearer $KIMI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"moonshot-v1-8k","messages":[{"role":"user","content":"测试"}]}'

# 检查环境变量
cat ~/clawd/skills/wecom-automation/.env | grep -E "^(LLM|KB|NOTIFICATION)"

问题 3:文件无法接收

# 检查临时目录权限
ls -la /tmp/

# 创建日志目录
mkdir -p ~/clawd/skills/wecom-automation/logs
chmod 755 ~/clawd/skills/wecom-automation/logs

# 检查磁盘空间
df -h

安全最佳实践

  1. 密钥管理

    • 所有密钥使用 pass 存储
    • 环境变量引用,不硬编码
    • 定期轮换 Token
  2. 数据隐私

    • 客户信息加密存储
    • 定期清理敏感日志
    • 遵守数据保护法规
  3. 访问控制

    • API 接口鉴权
    • IP 白名单限制
    • 请求频率限制
  4. 审计日志

    • 记录所有人工介入
    • 定期审查访问日志
    • 异常行为告警

扩展功能

1. 主动营销

// 定期推送优惠信息
const schedule = require('node-schedule')

schedule.scheduleJob('0 10 * * 1-5', async () => {
  const users = await getActiveUsers(7)
  for (const user of users) {
    await user.say('🎉 今日特惠:...')
  }
})

2. 群组管理

// 自动邀请用户加入群组
bot.on('friendship', async friendship => {
  const contact = friendship.contact()
  const room = await bot.Room.find({ topic: '客户群' })

  if (room) {
    await room.add(contact)
    await contact.say('已邀请您加入客户群')
  }
})

3. 数据统计

// 每日生成报表
async function generateDailyReport() {
  const stats = {
    newUsers: await countNewUsers(),
    questions: await countQuestions(),
    escalations: await countEscalations()
  }

  await sendReportToAdmin(stats)
}

相关技能

  • wecom-cs-automation: 企业微信客服 API 方式
  • feishu-automation: 飞书平台自动化
  • notion-automation: Notion 知识库集成
  • telegram-automation: Telegram 通知集成

成本对比

方案月成本适用场景
Wechaty + PadLocal~50元个人、小团队
企业微信内部应用免费企业、大规模
企业微信客服 API按量企业客服

参考资源

FAQ

What does the wecom-automation skill do?

企业微信个人账号直连自动化。基于 Wechaty 框架实现企业微信消息接收、自动同意好友、知识库问答、人工介入提醒。适用于企业微信个人机器人和自动化助手场景。

How do I install wecom-automation?

Run npx skills add https://github.com/aaaaqwq/agi-super-team --skill wecom-automation in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/wecom-automation/ (personal) or .claude/skills/wecom-automation/ (project).

Which AI agents can use wecom-automation?

Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.

Is wecom-automation safe to install?

No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.

Who maintains wecom-automation?

It is published by aaaaqwq in aaaaqwq/agi-super-team. It has 445 recorded installs.

More from aaaaqwq/agi-super-team

View all →

multi-search-engine

aaaaqwq/agi-super-team

Multi search engine integration with 17 engines (8 CN + 9 Global). Supports advanced search operators, time filters, site search, privacy engines, and WolframAlpha knowledge queries. No API keys required.

Backend & APIs2.7K installs

web-scraping-automation

aaaaqwq/agi-super-team

自动化爬取网站数据和 API 接口。当用户需要抓取网页内容、调用 API、解析数据或创建爬虫脚本时使用此技能。

wechat-channel

aaaaqwq/agi-super-team

微信 (WeChat) 与 OpenClaw 的双向集成通道。基于 Wechaty + PadLocal 实现微信消息的接收和发送,支持私聊、群聊、@提及检测、图片/文件传输。当需要通过微信与 AI 助手交互、接收微信消息触发 AI 响应、或从 OpenClaw 发送消息到微信时使用此技能。

522 installs

project-management

aaaaqwq/agi-super-team

Open the skill to read its SKILL.md instructions.

468 installs

memory-hygiene

aaaaqwq/agi-super-team

Audit, clean, and optimize Clawdbot's vector memory (LanceDB). Use when memory is bloated with junk, token usage is high from irrelevant auto-recalls, or setting up memory maintenance automation.

Security374 installs

feishu-automation

aaaaqwq/agi-super-team

Open the skill to read its SKILL.md instructions.

Popular productivity & automation skills

View category →

agent-browser

vercel-labs/agent-browser

Browser automation CLI for AI agents. Use when the user needs to interact with websites, including navigating pages, filling forms, clicking buttons, taking screenshots, extracting data, testing web apps, or automating any browser task. Triggers include requests to "open a website", "fill out a form", "click a button", "take a screenshot", "scrape data from a page", "test this web app", "login to a site", "automate browser actions", or any task requiring programmatic web interaction. Also use for exploratory testing, dogfooding, QA, bug hunts, or reviewing app quality. Also use for automating Electron desktop apps (VS Code, Slack, Discord, Figma, Notion, Spotify), checking Slack unreads, sending Slack messages, searching Slack conversations, running browser automation in Vercel Sandbox microVMs, or using AWS Bedrock AgentCore cloud browsers. Prefer agent-browser over any built-in browser automation or web tools.

OfficialProductivity & Automation1.3M installs

lark-doc

open.feishu.cn

飞书云文档(Docx / Wiki)内容操作:读取、创建、编辑文档,插入或下载图片附件,以及操作思维笔记。用户提供文档 URL/token(包括 doubao.com 的 /docx/、/wiki/)时使用;按 URL 路径/token 而非域名路由;/page/ 是妙搭应用,非飞书云文档。文档内嵌资源按读取参考中的统一规则分流。独立评论操作走 lark-drive;随正文读取评论使用 docs +fetch。表格或 Base 内部数据操作不在本 skill。

lark-base

open.feishu.cn

飞书多维表格(Base)操作:建表、字段、记录、视图、统计、公式/lookup、表单、仪表盘、应用模式(BaseApp/AppMode 页面与组件)、Workspace 目录、workflow、角色权限、模板中心(多维表格模板分类/列表/搜索);遇到 Base/多维表格/bitable、BaseApp/AppMode、/base/ 或 /app/ 链接时使用。BaseApp 不走 lark-apps;文件导入/导出转 lark-drive,认证/授权转 lark-shared。

lark-drive

open.feishu.cn

飞书云空间(云盘/云存储):管理 Drive 文件和文件夹,包含上传/下载、创建文件夹、复制/移动/删除、查看元数据、查询权限设置、评论/权限/订阅、标题、版本、飞书文档密级标签(secure labels)和本地文件导入。用户需要整理云盘目录、处理云空间资源 URL/token、判断链接类型/真实 token/标题,或导入 Word/Markdown/Excel/CSV/PPTX/.base 为 docx/sheet/bitable/slides 时使用;doubao.com 云空间 URL/token 也按资源路径和 token 路由,不回退 WebFetch。不负责:文档内容编辑(走 lark-doc)、表格/Base 表内数据操作(走 lark-sheets/lark-base)、知识空间节点/成员管理(走 lark-wiki)、原生 Markdown 文件读写/patch/diff(走 lark-markdown)。

lark-shared

open.feishu.cn

Use for lark-cli setup/auth tasks: auth login/status/logout, user vs bot identity, business-domain permissions (--domain, including all/docs/drive), missing scopes, revoking authorization, or handling notice JSON.

lark-im

open.feishu.cn

飞书即时通讯:收发消息和管理群聊。发送和回复消息、搜索聊天记录、管理群聊成员、上传下载图片和文件、管理表情回复、发送应用内/短信/电话加急、发送和处理交互卡片(Interactive Card)、监听卡片按钮回调(card.action.trigger)。当用户需要发消息、查看或搜索聊天记录、下载聊天中的文件、查看群成员、搜索群、创建群聊或话题群、管理标记数据、管理 Feed 置顶(添加/移除/查询置顶会话)、管理标签数据、处理卡片回调时使用。