🎨 #3795 【小程序】客服消息API新增了 aimsgcontext 字段,用于AI消息上下文关联
This commit is contained in:
@@ -40,6 +40,9 @@ public class WxMaKefuMessage implements Serializable {
|
||||
@SerializedName("miniprogrampage")
|
||||
private KfMaPage maPage;
|
||||
|
||||
@SerializedName("aimsgcontext")
|
||||
private AiMsgContext aiMsgContext;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@@ -90,6 +93,16 @@ public class WxMaKefuMessage implements Serializable {
|
||||
private String thumbMediaId;
|
||||
}
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public static class AiMsgContext implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@SerializedName("msgid")
|
||||
private String msgId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得文本消息builder.
|
||||
*/
|
||||
|
||||
@@ -8,6 +8,7 @@ import cn.binarywang.wx.miniapp.bean.WxMaKefuMessage;
|
||||
public class BaseBuilder<T> {
|
||||
protected String msgType;
|
||||
protected String toUser;
|
||||
protected String aiMsgContextMsgId;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public T toUser(String toUser) {
|
||||
@@ -15,6 +16,12 @@ public class BaseBuilder<T> {
|
||||
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();
|
||||
m.setMsgType(this.msgType);
|
||||
m.setToUser(this.toUser);
|
||||
if (this.aiMsgContextMsgId != null) {
|
||||
m.setAiMsgContext(new WxMaKefuMessage.AiMsgContext(this.aiMsgContextMsgId));
|
||||
}
|
||||
return m;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,4 +66,14 @@ public class WxMaKefuMessageTest {
|
||||
"\"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\"}}");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user