skillfed

wecom-aibot-python-sdk

企业微信智能机器人 Python SDK —— 基于 WebSocket 长连接通道,提供消息收发、流式回复、模板卡片、事件回调、文件下载解密等核心能力。

wecom-aibot-python-sdk v1.0.2 159.0K downloads/30d#10,709 on PyPI40
Permissive license MIT Active released

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-sdk

uv

uv add wecom-aibot-python-sdk

poetry

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

Development Status :: 4 - BetaIntended Audience :: DevelopersProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Topic :: Communications :: ChatTopic :: Software Development :: Libraries :: Python Modules

Tags

wecom enterprise wechat bot sdkwebsocket long connection messagingstreaming ai bot repliestemplate card messagesfile download decryption aes
wecom-wechat-workwebsocket-asyncai-bot-sdk

More Python Modules packages

Further reading