--- id: wecom-aibot-python-sdk version: "1.0.2" license: MIT license_treatment: permissive maintenance: active --- # wecom-aibot-python-sdk — 企业微信智能机器人 Python SDK —— 基于 WebSocket 长连接通道,提供消息收发、流式回复、模板卡片、事件回调、文件下载解密等核心能力。 License: permissive · Maintenance: active · Downloads: 159.0K/mo ## 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 above — 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 pip install wecom-aibot-python-sdk uv add wecom-aibot-python-sdk poetry add wecom-aibot-python-sdk ## Installing 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_current - Install friction: low - Maintenance: active - Downloads: 159.0K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags wecom enterprise wechat bot sdk, websocket long connection messaging, streaming ai bot replies, template card messages, file download decryption aes, wecom-wechat-work, websocket-async, ai-bot-sdk [View on SkillFed](https://skillfed.io/packages/wecom-aibot-python-sdk) · [View on PyPI](https://pypi.org/project/wecom-aibot-python-sdk/)