GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — 添加企微智能机器人消息接收和主动发送功能 by Copilot · Pull Request #3815 · binarywang/WxJava

Conversation

Copilot AI commented Dec 19, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

问题

API 模式创建的智能机器人回调消息无法被 WxCpXmlMessage 正确解析,缺少主动发送消息的 API。

变更

消息接收支持

  • 在 WxCpXmlMessage 添加 robotId 和 sessionId 字段及 XStream 注解
// 现在可以正确解析智能机器人回调消息
WxCpXmlMessage message = WxCpXmlMessage.fromEncryptedXml(...);
String robotId = message.getRobotId();
String sessionId = message.getSessionId();

主动发送消息 API

  • 新增 WxCpIntelligentRobotSendMessageRequest/Response 类
  • 在 WxCpIntelligentRobotService 添加 sendMessage() 方法
  • 添加 SEND_MESSAGE API 路径常量
WxCpIntelligentRobotSendMessageRequest request = new WxCpIntelligentRobotSendMessageRequest();
request.setRobotId("robot_id");
request.setUserid("user123");
request.setMessage("消息内容");

WxCpIntelligentRobotSendMessageResponse response = robotService.sendMessage(request);

文档和测试

  • 更新 INTELLIGENT_ROBOT.md 添加使用示例
  • 添加消息解析和发送的单元测试

参考文档: https://developer.work.weixin.qq.com/document/path/100719

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • developer.work.weixin.qq.com
    • Triggering command: /usr/bin/curl curl -s REDACTED (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

  • Configure Actions setup steps to set up my environment, which run before the firewall is enabled
  • Add the appropriate URLs or hosts to the custom allowlist in this repository's Copilot coding agent settings (admins only)
Original prompt

This section details on the original issue you should resolve

<issue_title>企微智能机器人接收消息和主动发消息</issue_title>
<issue_description># 提问前,请确保阅读过项目首页说明以及wiki开发文档相关内容,完成内容后,请务必移除包括本句在内的无用内容,以免影响他人阅读,否则直接关闭,谢谢合作~

简要描述

用”API模式创建“智能机器人后
将自己的智能体接入到智能机器人,接收并回复消息
目前4.7.9.B用WxCpXmlMessage接收消息无法解析

官方文档地址

https://developer.work.weixin.qq.com/document/path/100719
#3684</issue_description>

Comments on the Issue (you are @copilot in this section)

Custom agent used: 全部用中文
需要用中文,包括PR标题和分析总结过程

  • Fixes 企微智能机器人接收消息和主动发消息 #3805

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Copilot AI self-assigned this Dec 19, 2025
Initial plan
9d8d557
Copilot AI assigned binarywang Dec 19, 2025
Copilot started work on behalf of binarywang December 19, 2025 17:25
View session
@binarywang
添加企微智能机器人消息接收和主动发送功能
7b4b281
Co-authored-by: binarywang <[email protected]>
Copilot AI changed the title [WIP] Fix message parsing issue in intelligent robot 添加企微智能机器人消息接收和主动发送功能 Dec 19, 2025
Copilot AI requested a review from binarywang December 19, 2025 17:36
Copilot finished work on behalf of binarywang December 19, 2025 17:36
@binarywang
binarywang marked this pull request as ready for review December 20, 2025 04:06
Copilot AI review requested due to automatic review settings December 20, 2025 04:06
Copilot started reviewing on behalf of binarywang December 20, 2025 04:07
View session
Copilot AI reviewed Dec 20, 2025
View reviewed changes

Copilot AI left a comment

Copy link
Copy Markdown

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

本 PR 为企业微信智能机器人模块添加了消息接收解析和主动发送消息的功能支持,解决了 API 模式创建的智能机器人回调消息无法被正确解析的问题。

主要变更包括:

  • 在 WxCpXmlMessage 中添加 robotId 和 sessionId 字段支持智能机器人消息解析
  • 新增主动发送消息的请求/响应类和服务方法
  • 完善相关测试用例和文档说明

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/message/WxCpXmlMessage.java 添加 robotId 和 sessionId 字段及 XStream 注解,支持智能机器人消息解析
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/intelligentrobot/WxCpIntelligentRobotSendMessageRequest.java 新增主动发送消息请求类,包含 robotId、userid、message、sessionId、msgId 字段
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/intelligentrobot/WxCpIntelligentRobotSendMessageResponse.java 新增主动发送消息响应类,包含 msgId 和 sessionId 字段
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpIntelligentRobotService.java 在服务接口中添加 sendMessage 方法定义
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpIntelligentRobotServiceImpl.java 实现 sendMessage 方法,调用微信 API 发送消息
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/constant/WxCpApiPathConsts.java 添加 SEND_MESSAGE API 路径常量
weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/message/WxCpXmlMessageTest.java 添加智能机器人消息解析测试用例
weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpIntelligentRobotServiceImplTest.java 添加主动发送消息请求/响应的序列化和反序列化测试用例
weixin-java-cp/INTELLIGENT_ROBOT.md 更新文档,添加主动发送消息和接收消息的使用说明和示例代码

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/message/WxCpXmlMessageTest.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread ...java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpIntelligentRobotServiceImplTest.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread ...java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpIntelligentRobotServiceImplTest.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread ...java/me/chanjar/weixin/cp/bean/intelligentrobot/WxCpIntelligentRobotSendMessageResponse.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

@binarywang
Update weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/intelli…
38f2624
…gentrobot/WxCpIntelligentRobotSendMessageResponse.java

Co-authored-by: Copilot <[email protected]>
@binarywang
binarywang merged commit 8181645 into develop Dec 20, 2025
1 check was pending

Uh oh!

There was an error while loading. Please reload this page.

@binarywang
binarywang deleted the copilot/fix-message-parsing-issue branch December 20, 2025 09:18
@binarywang binarywang added this to the 4.8.0 milestone Dec 20, 2025
Copilot AI added a commit that referenced this pull request Dec 21, 2025
🆕 #3815 【企业微信】增加智能机器人消息接收和主动发送功能
0e6e55a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

Copilot code review Copilot
Copilot review effort
Applies to this pull request for everyone.Learn more about Copilot code review.
Copilot left review comments
@binarywang binarywang Awaiting requested review from binarywang

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@binarywang binarywang

Copilot code review Copilot

Labels

None yet

Projects

None yet

Milestone

4.8.0

Development

Successfully merging this pull request may close these issues.

企微智能机器人接收消息和主动发消息

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@binarywang
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.