Skip to content

Fix wecomcs open_kfid msgid - #2449

Open
DeepCodeYang wants to merge 2 commits into
langbot-app:masterfrom
DeepCodeYang:fix-wecomcs-open_kfid
Open

Fix wecomcs open_kfid msgid#2449
DeepCodeYang wants to merge 2 commits into
langbot-app:masterfrom
DeepCodeYang:fix-wecomcs-open_kfid

Conversation

@DeepCodeYang

@DeepCodeYang DeepCodeYang commented Aug 18, 2026

Copy link
Copy Markdown

概述 / Overview

/src/langbot/pkg/platform/sources/wecomcs.py
针对企业微信客服人工接管主动发送消息报错,修复了两处内容:

  1. send_message 调用时无法获取open_kid,在 wecomcs.py 中找到 WecomEventConverter 类的 target2yiri 方法,将处理 text
    和 image 事件时的 friend处代码,将id补充前缀 event.receiver_id (即 open_kfid)。

  2. msgid 长度超限:企业微信客服 API 官方文档明确规定,主动发送消息时的 msgid(消息 ID)最大长度不能超过 32 字节,由于uuid.uuid4().hex 本身已经是 32 个字符,于是把langbot_前缀去掉。
    【补充企业微信官方文档地址:】https://developer.work.weixin.qq.com/document/path/94700
    并且在文字text类型下方增加了对图片类型image的支持。

更改前后对比截图 / Screenshots

请在此部分粘贴更改前后对比截图(可以是界面截图、控制台输出、对话截图等):
Please paste the screenshots of changes before and after here (can be interface screenshots, console output, conversation screenshots, etc.):

修改前 / Before:
请求信息:
{page_id: "console", endpoint: "/reply", method: "POST", body: {session_key: "person_uwmJ2Y5ZgAAfaenjtZtOgT2KO14nyuTvg", text: "你好", image_base64: "", file_base64: "", file_name: ""}}
响应/报错信息:
{code: -1, msg: "ActionCallError: Exception: Failed t
o send message"}
修改后 / After:

img_v3_0214h_03cf4e01-89b8-4bfd-b48a-8fada317cf3g

检查清单 / Checklist

PR 作者完成 / For PR author

请在方括号间写x以打勾 / Please tick the box with x

  • 阅读仓库贡献指引了吗? / Have you read the contribution guide?
  • 我已签署或将在机器人提示后签署 CLA。 / I have signed, or will sign when prompted by the bot, the CLA.
  • 与项目所有者沟通过了吗? / Have you communicated with the project maintainer?
  • 我确定已自行测试所作的更改,确保功能符合预期。 / I have tested the changes and ensured they work as expected.

项目维护者完成 / For project maintainer

  • 相关 issues 链接了吗? / Have you linked the related issues?
  • [Bug]: 提供一个企业微信适配器的bug(已处理分享出来)(企业微信客服) #2421
  • 配置项写好了吗?迁移写好了吗?生效了吗? / Have you written the configuration items? Have you written the migration? Has it taken effect?
  • 依赖加到 pyproject.toml 和 core/bootutils/deps.py 了吗 / Have you added the dependencies to pyproject.toml and core/bootutils/deps.py?
  • 文档编写了吗? / Have you written the documentation?

fix bug wecomcs send_message open_kfid
event.receiver_id  is open_kfid
fix bug msgid exceeds the 32-byte limit
@dosubot dosubot Bot added size:S This PR changes 10-29 lines, ignoring generated files. bug? Bug或Bug修复相关 / maybe a bug IM: wecom 企业微信 适配器相关 / WeCom and WeComCS adapter related m: Platform 机器人管理相关 / Bots management labels Aug 18, 2026
@github-actions

github-actions Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

All contributors have signed the CLA. ✅ 所有贡献者均已签署 CLA。
Posted by the CLA Assistant Lite bot.

@DeepCodeYang DeepCodeYang changed the title Fix wecomcs open kfid Fix wecomcs open_kfid msgid Aug 18, 2026
@DeepCodeYang

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

dadachann added a commit to langbot-app/cla that referenced this pull request Aug 18, 2026
@RockChinQ

Copy link
Copy Markdown
Member

Hi @DeepCodeYang , please fix the unit test issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug? Bug或Bug修复相关 / maybe a bug IM: wecom 企业微信 适配器相关 / WeCom and WeComCS adapter related m: Platform 机器人管理相关 / Bots management size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants