1
0
mirror of synced 2025-12-16 20:28:11 +08:00

🎨 #3795 【小程序】客服消息API新增了 aimsgcontext 字段,用于AI消息上下文关联

This commit is contained in:
Copilot
2025-12-05 16:20:18 +08:00
committed by GitHub
parent ddcdf658cf
commit 85bd27424d
3 changed files with 33 additions and 0 deletions

View File

@@ -40,6 +40,9 @@ public class WxMaKefuMessage implements Serializable {
@SerializedName("miniprogrampage") @SerializedName("miniprogrampage")
private KfMaPage maPage; private KfMaPage maPage;
@SerializedName("aimsgcontext")
private AiMsgContext aiMsgContext;
@Data @Data
@AllArgsConstructor @AllArgsConstructor
@NoArgsConstructor @NoArgsConstructor
@@ -90,6 +93,16 @@ public class WxMaKefuMessage implements Serializable {
private String thumbMediaId; private String thumbMediaId;
} }
@Data
@AllArgsConstructor
@NoArgsConstructor
public static class AiMsgContext implements Serializable {
private static final long serialVersionUID = 1L;
@SerializedName("msgid")
private String msgId;
}
/** /**
* 获得文本消息builder. * 获得文本消息builder.
*/ */

View File

@@ -8,6 +8,7 @@ import cn.binarywang.wx.miniapp.bean.WxMaKefuMessage;
public class BaseBuilder<T> { public class BaseBuilder<T> {
protected String msgType; protected String msgType;
protected String toUser; protected String toUser;
protected String aiMsgContextMsgId;
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public T toUser(String toUser) { public T toUser(String toUser) {
@@ -15,6 +16,12 @@ public class BaseBuilder<T> {
return (T) this; return (T) this;
} }
@SuppressWarnings("unchecked")
public T aiMsgContextMsgId(String msgId) {
this.aiMsgContextMsgId = msgId;
return (T) this;
}
/** /**
* 构造器方法. * 构造器方法.
*/ */
@@ -22,6 +29,9 @@ public class BaseBuilder<T> {
WxMaKefuMessage m = new WxMaKefuMessage(); WxMaKefuMessage m = new WxMaKefuMessage();
m.setMsgType(this.msgType); m.setMsgType(this.msgType);
m.setToUser(this.toUser); m.setToUser(this.toUser);
if (this.aiMsgContextMsgId != null) {
m.setAiMsgContext(new WxMaKefuMessage.AiMsgContext(this.aiMsgContextMsgId));
}
return m; return m;
} }
} }

View File

@@ -66,4 +66,14 @@ public class WxMaKefuMessageTest {
"\"link\":{\"title\":\"title\",\"description\":\"description\",\"url\":\"https://mp.weixin.qq.com/s?__biz=MzI0MDA2OTY5NQ==\",\"thumb_url\":\"thumbUrl\"}}"); "\"link\":{\"title\":\"title\",\"description\":\"description\",\"url\":\"https://mp.weixin.qq.com/s?__biz=MzI0MDA2OTY5NQ==\",\"thumb_url\":\"thumbUrl\"}}");
} }
public void testTextBuilderWithAiMsgContext() {
WxMaKefuMessage reply = WxMaKefuMessage.newTextBuilder()
.toUser("OPENID")
.content("回复内容")
.aiMsgContextMsgId("MSG_ID_123")
.build();
assertThat(reply.toJson())
.isEqualTo("{\"touser\":\"OPENID\",\"msgtype\":\"text\",\"text\":{\"content\":\"回复内容\"},\"aimsgcontext\":{\"msgid\":\"MSG_ID_123\"}}");
}
} }