Skip to content

feat(gateway): add WeChat QR setup flow - #4175

Closed
latentharbor wants to merge 3 commits into
NousResearch:mainfrom
latentharbor:feat/wechat-setup-flow
Closed

feat(gateway): add WeChat QR setup flow#4175
latentharbor wants to merge 3 commits into
NousResearch:mainfrom
latentharbor:feat/wechat-setup-flow

Conversation

@latentharbor

Copy link
Copy Markdown

What does this PR do?

Adds first-class WeChat support to the Hermes gateway using the official WeChat AI bot login/API flow, with QR pairing integrated
directly into Hermes setup.

This revives the earlier WeChat adapter direction, but updates it for the current gateway/CLI architecture and removes the manual
standalone login step. Instead of requiring users to run a separate scripts/weixin_login.py flow first, WeChat can now be configured
through hermes setup, hermes gateway setup, or hermes wechat, with QR pairing rendered directly in the terminal.

The implementation also wires WeChat through the full Hermes messaging surface: gateway config/env loading, adapter creation, allowlist
auth, toolset selection, send_message, cron delivery, channel discovery, and status/setup UX.

Related Issue

Fixes #2422

Supersedes the earlier WeChat adapter attempts in #2425 and #2502.

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 🔒 Security fix
  • 📝 Documentation update
  • ✅ Tests (adding or improving test coverage)
  • ♻️ Refactor (no behavior change)
  • 🎯 New skill (bundled or hub)

Changes Made

  • Added official WeChat adapter in gateway/platforms/weixin.py
  • Added WeChat platform/config wiring in gateway/config.py, gateway/run.py, gateway/channel_directory.py, toolsets.py, cron/ scheduler.py, and tools/send_message_tool.py
  • Added WeChat prompt/toolset/status/setup integration in agent/prompt_builder.py, hermes_cli/gateway.py, hermes_cli/setup.py,
    hermes_cli/status.py, hermes_cli/tools_config.py, and hermes_cli/main.py
  • Added reusable QR login flow in hermes_cli/wechat_login.py
  • Kept scripts/weixin_login.py as a thin compatibility wrapper around the shared login module
  • Fixed terminal QR rendering so the login flow shows a scannable QR directly in the terminal instead of only printing a link
  • Added regression tests in tests/gateway/test_weixin.py and tests/hermes_cli/test_wechat_login.py

How to Test

  1. Run UV_CACHE_DIR=/tmp/uv-cache uv run python -m hermes_cli.main setup
  2. Choose WeChat (Weixin) from the messaging setup flow and complete QR pairing in the terminal
  3. Confirm WEIXIN_TOKEN and WEIXIN_ACCOUNT_ID are written to the active Hermes env file, then run uv run python -m hermes_cli.main gateway
  4. Send a WeChat message to the bot and confirm Hermes replies without KeyError('weixin')
  5. Optional: run UV_CACHE_DIR=/tmp/uv-cache uv run --with pytest --with pytest-xdist python -m pytest tests/hermes_cli/ test_wechat_login.py tests/gateway/test_weixin.py tests/gateway/test_config.py tests/gateway/test_status.py tests/gateway/ test_channel_directory.py tests/hermes_cli/test_gateway.py tests/tools/test_send_message_tool.py tests/tools/ test_send_message_missing_platforms.py tests/gateway/test_allowlist_startup_check.py tests/gateway/test_unauthorized_dm_behavior.py -q

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits (fix(scope):, feat(scope):, etc.)
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix/feature (no unrelated commits)
  • I've run pytest tests/ -q and all tests pass
  • I've added tests for my changes (required for bug fixes, strongly encouraged for features)
  • I've tested on my platform: macOS

Documentation & Housekeeping

  • I've updated relevant documentation (README, docs/, docstrings) — or N/A
  • I've updated cli-config.yaml.example if I added/changed config keys — or N/A
  • I've updated CONTRIBUTING.md or AGENTS.md if I changed architecture or workflows — or N/A
  • I've considered cross-platform impact (Windows, macOS) per the [compatibility guide](https://github.com/NousResearch/hermes-agent/
    blob/main/CONTRIBUTING.md#cross-platform-compatibility) — or N/A
  • I've updated tool descriptions/schemas if I changed tool behavior — or N/A

Screenshots / Logs

  • hermes setup now shows WeChat (Weixin) in the messaging platform flow
  • The QR pairing flow now renders a terminal QR directly during hermes setup / hermes gateway setup / hermes wechat
  • Manual verification completed on macOS against the official WeChat login flow

@latentharbor

Copy link
Copy Markdown
Author

I double-checked the implementation before opening this PR: the WeChat integration here does not depend on weixinclawbot, api.weixinclawbot.com, or any OpenClaw-specific WeChat backend surface.

The adapter/login flow is wired directly against the official iLink endpoints exposed through ilinkai.weixin.qq.com.

@latentharbor
latentharbor force-pushed the feat/wechat-setup-flow branch from 28918f7 to d39e779 Compare April 1, 2026 01:41
@aneryu

aneryu commented Apr 1, 2026

Copy link
Copy Markdown

This is great—I tested it locally and can control it via WeChat now.

@saonian

saonian commented Apr 8, 2026

Copy link
Copy Markdown

For most Chinese users, WeChat is the primary messaging platform in daily life. Enterprise WeChat/WeCom is useful, but it serves a different scenario and cannot replace regular WeChat for general personal use.

That means regular WeChat support is not just a “nice to have” variant of Enterprise WeChat support. It is the main path if Hermes wants meaningful adoption among Chinese-speaking users.

@teknium1

Copy link
Copy Markdown
Contributor

Merged via PR #8665 which synthesizes the best fixes from ~25 community PRs into a single consolidated change. Your contribution (WeChat QR setup flow) was reviewed and informed the final implementation. Thank you @latentharbor for your work on this!

@teknium1 teknium1 closed this Apr 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: WeChat messaging platform support

4 participants