wecom-aibot-python-sdk
企业微信智能机器人 Python SDK —— 基于 WebSocket 长连接通道,提供消息收发、流式回复、模板卡片、事件回调、文件下载解密等核心能力。
What it is and what it does
wecom-aibot-python-sdk is a Python client for WeChat Work's AI bot API, built on asyncio and WebSocket. It manages long-lived connections to WeChat Work's servers, automatically handles authentication, heartbeat, and reconnection with exponential backoff. The SDK parses incoming messages (text, image, voice, file, mixed) and events (enter chat, template card clicks, user feedback), then routes them to your async event handlers.
You use it to build chatbots and automation agents: listen for incoming messages, send streaming text replies with Markdown support, post template cards, update cards in-place, proactively push messages to users, and download encrypted files. All operations are async/await native, with built-in AES-256-CBC file decryption, pluggable logging, and a serial reply queue that ensures messages for the same request ID are sent in order.
Use it for:
- Build a WeChat Work chatbot that streams AI-generated responses with Markdown formatting.
- Send proactive notifications or alerts to users via template cards without waiting for an incoming message.
- Handle file uploads from users, decrypt them server-side, and process or store the contents.
- Respond to user interactions (button clicks on template cards) with follow-up messages or state updates.
- Implement a multi-turn conversation bot that tracks session state and sends welcome messages when users enter a chat.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
A Python SDK for WeChat Work (企业微信) AI bot that manages WebSocket connections, handles incoming messages and events, and sends replies including streaming text, template cards, and file downloads with AES decryption.
Yes. The SDK is actively maintained, has no known vulnerabilities, uses permissive MIT licensing, and offers low install friction. Install it if you need to build a WeChat Work bot in Python. The async-native design and built-in features (streaming, cards, file decryption, reconnection) make it the natural choice for this use case.
Install
wecom-aibot-python-sdk on PyPI
pip
pip install wecom-aibot-python-sdkuv
uv add wecom-aibot-python-sdkpoetry
poetry add wecom-aibot-python-sdkInstalling wecom-aibot-python-sdk
Before you install
Low friction install with a pure-Python wheel and five well-established async dependencies (websockets, aiohttp, pyee, cryptography, certifi). Actively maintained with recent commits and no known vulnerabilities.
License in practice
MIT license permits commercial and private use with minimal restrictions—suitable for most projects.
Quickstart
pip install wecom-aibot-python-sdk
from aibot import WSClient, WSClientOptions
ws_client = WSClient(WSClientOptions(
bot_id='your-bot-id',
secret='your-bot-secret'
))
@ws_client.on('message.text')
async def on_text(frame):
await ws_client.reply_stream(frame, 'stream-id', 'Hello!', True)
ws_client.run()
Requires Python >= 3.8 and a valid WeChat Work bot_id and secret from the enterprise WeChat admin console.
Verify before relying
- Whether the SDK handles reconnection and heartbeat automatically without user code intervention.
- Performance characteristics under high message volume or concurrent streams.
- Completeness of error handling and recovery for network failures beyond the documented exponential backoff.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.8) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 5 — websockets, aiohttp, pyee, cryptography, certifi |
| Maintenance | actively maintained — 144 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 159,024/month — #10,709 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: wecom_aibot_python_sdk-1.0.2-py3-none-any.whl
Keywords: wecom, wechat-work, aibot, websocket, sdk
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
wechatpyWeChat SDK providing Python bindings for…
permissive · top 15,000 on PyPI
pywxdumpExtracts WeChat account metadata, decrypts chat…
permissive · top 15,000 on PyPI
botframework-connectorEnables Python bots to send and receive…
permissive · top 5,000 on PyPI
line-bot-sdkSDK for building LINE bots that handles webhook…
permissive · top 5,000 on PyPI
pipecat-ai-whiskerWhisker is a real-time debugger for Pipecat…
permissive · top 15,000 on PyPI
dingtalk-streamPython SDK for building DingTalk chatbots and…
permissive · top 15,000 on PyPI
aiogramaiogram is an asynchronous Python framework for…
permissive · top 5,000 on PyPI
pyTelegramBotAPIA Python library that wraps the Telegram Bot…
copyleft · top 5,000 on PyPI
coinbase-advanced-pyOfficial Python SDK for the Coinbase Advanced…
permissive · top 15,000 on PyPI
plexwebsocketAsync library that connects to Plex media…
permissive · top 15,000 on PyPI