企业🤖AI Agent构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
## 开发者模式消息及事件格式 ### 接入和结束会话事件 1、接入会话事件:system\_notify\_in\_receive ~~~ { "App_Type": "yunh5", "ChannelId": "15033", "ChannelName": "xy007", "Content": "", "CreateTime": 1697444398, "FromUserName": 799533513, "MsgId": "652cf22e7a3ca", "Event": "system_notify_in_receive", "StaffId": null, "StaffName": "\\\\u5728\\\\u7ebf\\\\u5ba2\\\\u670d", "ToBusiness": true, "ToUserName": "lkkk1", "ChatSessionId": "20211", "wechatapp\_id": "211079" } ~~~ 2、结束会话事件:system\_notify\_out\_receive ~~~ { "App_Type": "yunh5", "ChannelId": "15033", "ChannelName": "xy007", "Content": "", "CreateTime": 1697444398, "FromUserName": 799533513, "MsgId": "652cf22e7a3ca", "Event": "system_notify_out_receive", "StaffId": null, "StaffName": "在线客服", "ToBusiness": true, "ToUserName": "lkkk1", "ChatSessionId": "20211", "wechatapp_id": "211079" } ~~~ ### 小程序C端消息和事件 1.C端文本 ``` json { "ToUserName": "toUser", "FromUserName": "fromUser", "CreateTime": 1482048670, "MsgType": "text", "Content": "this is a test", "MsgId": 1234567890123456 } ``` 2.C端图片 ``` json { "ToUserName": "toUser", "FromUserName": "fromUser", "CreateTime": 1482048670, "MsgType": "image", "PicUrl": "this is a url", "MediaId": "media_id", "MsgId": 1234567890123456 } ``` 3.C端小程序卡片 ``` json { "ToUserName": "toUser", "FromUserName": "fromUser", "CreateTime": 1482048670, "MsgType": "miniprogrampage", "MsgId": 1234567890123456, "Title":"title", "AppId":"appid", "PagePath":"path", "ThumbUrl":"", "ThumbMediaId":"" } ``` 4. C端进入会话事件 ``` json { "ToUserName": "toUser", "FromUserName": "fromUser", "CreateTime": 1482048670, "MsgType": "event", "Event": "user_enter_tempsession", "SessionFrom": "sessionFrom" } ``` 5、其他C端事件可参考微信开发者文档 ### 公众号C端消息和事件 1、文本消息 ``` json { "Content": "哈哈哈", "CreateTime": "1688444107", "FromUserName": "oRjZX59v2IYoARjcVUA3OgB_5QsQ", "MsgId": "24172710472080493", "MsgType": "text", "ToBusiness": false, "ToUserName": "gh_bba8f05106a1" } ``` 2、图片消息 ``` json { "ToUserName": "toUser", "FromUserName": "fromUser", "CreateTime": "1348831860", "MsgType": "image", "PicUrl": "this is a url", "MediaId": "media_id", "MsgId": "1234567890123456", "ToBusiness": false // 标记是否为客服发送消息 } ``` 3、语音消息 ``` json { "ToUserName": "toUser", "FromUserName": "fromUser", "CreateTime": "1357290913", "MsgType": "voice", "MediaId": "media_id", "Format": "Format", "MsgId": "1234567890123456", "ToBusiness": false // 标记是否为客服发送消息 } ``` 4、视频消息 ``` json { "ToUserName": "toUser", "FromUserName": "fromUser", "CreateTime": "1357290913", "MsgType": "video", "MediaId": "media_id", "ThumbMediaId": "thumb_media_id", "MsgId": "1234567890123456", "ToBusiness": false // 标记是否为客服发送消息 } ``` 5、关注、取关事件 ``` json { "ToUserName": "toUser", "FromUserName": "FromUser", "CreateTime": "123456789", "MsgType": "event", "Event": "subscribe", // subscribe:关注,unsubscribe:取关 "ToBusiness": false // 标记是否为客服发送消息 } ``` 6、扫描渠道二维码关注 ``` json { "ToUserName": "toUser", "FromUserName": "FromUser", "CreateTime": "123456789", "MsgType": "event", "Event": "subscribe", "EventKey": "qrscene_123123", // 渠道二维码的key,用于判断是来自哪个渠道二维码 "Ticket": "TICKET", "ToBusiness": false // 标记是否为客服发送消息 } ``` 7、扫描渠道二维码事件(已关注粉丝扫码) ``` json { "ToUserName": "toUser", "FromUserName": "FromUser", "CreateTime": "123456789", "MsgType": "event", "Event": "SCAN", "EventKey": "SCENE_VALUE", // 渠道二维码的key,用于判断是来自哪个渠道二维码 "Ticket": "TICKET", "ToBusiness": false // 标记是否为客服发送消息 } ``` 8、点菜单事件(click) ``` json { "ToUserName": "toUser", "FromUserName": "FromUser", "CreateTime": "123456789", "MsgType": "event", "Event": "CLICK", // click一般用于点菜单后回复消息 "EventKey": "EVENTKEY" } ``` 9、点菜单跳转链接(跳转网址或者跳转小程序) ``` json { "ToUserName": "toUser", "FromUserName": "FromUser", "CreateTime": "123456789", "MsgType": "event", "Event": "VIEW", "EventKey": "www.qq.com", //跳转网址则为网址,跳转小程序则为小程序的pagepath "MenuId": "MENUID", //菜单ID,点击的是个性化菜单时,可以通过这个字段,知道是哪个规则的菜单被点击了 "ToBusiness": false // 标记是否为客服发送消息 } ``` 10、其他消息和时间类型可以参考官方文档 ### B端客服回复消息 1、文本消息 ~~~ {    "App_Type": "wechat_kefu",    "ChannelId": "14777",    "ChannelName": "咸鱼测试1",    "MsgType": "text",    "Content": "啦啦啦",    "CreateTime": 1688441501,    "FromUserName": "799533439",     // 客服的uid    "StaffId": "18186158229",    // 客服登录账号    "StaffName": "管理员",       // 客服昵称    "MsgId": "64a3929d8e4df",    "ToBusiness": false,    "ToUserName": "h51a51-1688026512803-37275.0.14777" } ~~~ 2、图片/视频/语音/文件消息 ~~~ {    "App_Type": "wechat_kefu",    "ChannelId": "14777",    "ChannelName": "咸鱼测试1",    "Content": "[这里是图片/视频/语音/文件消息的url链接]",    "CreateTime": 1688442150,    "FromUserName": "799533439",    "MsgId": "oyeVrJ83bSzVxFMdkktuQVkUXDrhYgko",    "MsgType": "image",    "StaffId": "18186158229",    "StaffName": "管理员",    "ToBusiness": true,    "ToUserName": "h51a51-1688026512803-37275.0.14777" } ~~~ 3、图文消息 ~~~ { "App_Type": "yunh5", "ChannelId": "14777", "ChannelName": "咸鱼测试1", "Content": "[这里是图片的url链接]", "CreateTime": 1688443210, "Description": "这里是图文的描述", "FromUserName": "799533439", "MsgId": "64a39949423e9", "MsgType": "multiple", "StaffId": "18186158229", "StaffName": "管理员", "Title": "这里是图文的标题", "ToBusiness": true, "ToUserName": "h51a51-1688026512803-37275.0.14777", "Url": "[这里是跳转的url链接]" } ~~~ 4、小程序卡片 ~~~ { "AppId": "wxf57cf2affa38e55d", "App_Type": "official_account", "Content": "[这里是图片的url链接]", "CreateTime": 1688444505, "FromUserName": "799533439", "MsgId": "64a39e5784983", "MsgType": "miniprogrampage", "PagePath": "pages/index/index", "StaffId": "18186158229", "StaffName": "管理员", "Title": "[卡片标题]", "ToBusiness": true, "ToUserName": "oRjZX59v2IYoARjcVUA3OgB_5QsQ" } ~~~