◐ Shell
clean mode source ↗

添加客服消息aimsgcontext字段支持 by Copilot · Pull Request #3795 · binarywang/WxJava

根据微信官方文档更新,小程序客服消息API新增了 aimsgcontext 字段用于AI消息上下文关联。

变更内容

  • WxMaKefuMessage: 新增 aimsgcontext 字段和 AiMsgContext 内部类(包含 msgid 字段)
  • BaseBuilder: 添加 aiMsgContextMsgId() 方法支持链式设置上下文消息ID
  • WxMaKefuMessageTest: 添加序列化测试验证JSON输出

使用示例

// 在回复中引用之前的消息ID作为上下文
WxMaKefuMessage message = WxMaKefuMessage.newTextBuilder()
  .toUser("OPENID")
  .content("根据您的问题...")
  .aiMsgContextMsgId("MSG_ID_123")
  .build();

生成JSON:

{
  "touser": "OPENID",
  "msgtype": "text",
  "text": {"content": "根据您的问题..."},
  "aimsgcontext": {"msgid": "MSG_ID_123"}
}

字段可选,向后兼容现有代码。

参考

https://developers.weixin.qq.com/doc/subscription/api/customer/message/api_sendcustommessage.html#Body-aimsgcontext-Object-Payload

Original prompt

This section details on the original issue you should resolve

<issue_title>客服消息参数增加了一些字段</issue_title>
<issue_description># 提问前,请确保阅读过项目首页说明以及wiki开发文档相关内容,完成内容后,请务必移除包括本句在内的无用内容,以免影响他人阅读,否则直接关闭,谢谢合作~

简要描述

一些参数字段可以加上

官方文档地址

请提供所需功能对应的微信官方文档地址以便进行确认。
https://developers.weixin.qq.com/doc/subscription/api/customer/message/api_sendcustommessage.html#Body-aimsgcontext-Object-Payload</issue_description>

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

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


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.