1.在页面上使用客服消息button open-type="contact" bindcontact="handleContact"/button必须属性:open-type="contact"非必须属性:session-from - 会话来源(不同按钮,可以设置不同值,表示不同的会话场景)send-message-title - 会话内消息卡片标题(默认:当前标题)send-message-path - 会话内消息卡片点击跳转小程序路径(默认:当前分享路径)send-message-img - 会话内消息卡片图片(默认:截图)show-message-card - 是否显示会话内消息卡片(默认:false)设置为 true,用户进行客服会话会在右下角显示 '可能要发送的小程序' 提示,用户点击后可以快速发送小程序消息bindcontact - 客服消息回调如果用户在会话中,点击了由 '服务端' 发送的小程序消息,则会返回到小程序,我们可以通过 bindcontact 事件回调,来获取用户所点消息的页面路径 path 和 参数 query// 回调事件handleContact (e) {console.log(e.path)console.log(e.query)}/*注意:'服务端' 返回的小程序消息,只能是本小程序,但可以指定不同的页面及参数miniprogrampage - 小程序消息结构title - 消息标题pagepath - 小程序页面路径,支持参数,例如:pages/index/index?foo=barthumb_media_id - 小程序消息卡片封面,image 类型的 media_id */参考文档:https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/customer-message/customer-message.htmlhttps://developers.weixin.qq.com/miniprogram/dev/component/button.htmlhttps://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/customer-message/customerServiceMessage.send.html2.服务端接收的消息类型:text - 文本消息Content - 文本内容image - 图片消息PicUrl - MediaId - 图片消息媒体ID可以调用接口 'getTempMedia - 获取临时素材' 拉取数据miniprogrampage - 小程序卡片消息Title - 标题AppId - 小程序 appidPagePath - 小程序页面路径ThumbUrl - 小程序封面图的临时 cdn 链接ThumbMediaId - 小程序封面图的临时素材idevent - 事件消息user_enter_tempsession - 进行会话事件sessionForm - '客服会话按钮' 上设置的 'session-from - 会员来源',有助于我们分析不同场景参考文档:https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/customer-message/receive.html3.服务端发送的消息类型:text - 文本消息image - 图片消息link - 图文消息(easywechat 使用的还是 news)miniprogrampage - 小程序卡片消息参考文档:https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/customer-message/customerServiceMessage.send.html4.转发客服消息:可以将用户的消息,转发到网页版的客服工具,接入多客服系统返回的消息类型为:transfer_customer_service参考文档:https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/customer-message/trans.html5.关于消息中,涉及到的媒体文件问题:MediaId 以及 ThumbMediaId,有 2 个接口:1uploadTempMedia - 上传临时素材参数:acccess_tokentype - 文件类型(目前只有:image)media - form-data 中媒体文件标识,有filename、filelength、content-type等信息(FormData 表单数据)2getTempMedia - 下载临时素材参数:acccess_tokenmedia_id - 媒体文件ID参考文档:https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/customer-message/customerServiceMessage.uploadTempMedia.htmlhttps://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/customer-message/customerServiceMessage.getTempMedia.html6.下发客服状态:这个没测试参考文档:https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/customer-message/typing.htmlhttps://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/customer-message/customerServiceMessage.setTyping.html7.EasyWeChat 开发小程序的客服消息:$app-customer_service。同公众号的客服消息应该是一致的。同时,进入消息、接收消息、发送消息的用法,都是参照公众号文档。客服消息,跟发送普通消息的区别是(以 text 消息为例):// 普通消息return new Text('你好!');// 客服消息$message = new Text('你好!');$app-customer_service-message($message)-to($open_id)-send();参考文档:服务端https://www.easywechat.com/docs/4.1/official-account/server消息https://www.easywechat.com/docs/4.1/official-account/messages多客服消息转发(跟上面的第 4 点一样,转发给客服系统)https://www.easywechat.com/docs/4.1/official-account/message-transfer













