微信小程序-客服消息

1.在页面上使用客服消息
	
	必须属性:
		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=bar

						thumb_media_id - 小程序消息卡片封面,image 类型的 media_id
			 */

	参考文档:
		https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/customer-message/customer-message.html
		https://developers.weixin.qq.com/miniprogram/dev/component/button.html
		https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/customer-message/customerServiceMessage.send.html

2.服务端接收的消息类型:
	text - 文本消息
		Content -  文本内容

	image - 图片消息
		PicUrl - 
		MediaId - 图片消息媒体ID
			可以调用接口 'getTempMedia - 获取临时素材' 拉取数据

	miniprogrampage - 小程序卡片消息
		Title - 标题
		AppId - 小程序 appid
		PagePath - 小程序页面路径
		ThumbUrl - 小程序封面图的临时 cdn 链接
		ThumbMediaId - 小程序封面图的临时素材id

	event - 事件消息
		user_enter_tempsession - 进行会话事件
			sessionForm - '客服会话按钮' 上设置的 'session-from - 会员来源',有助于我们分析不同场景

	参考文档:
		https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/customer-message/receive.html

3.服务端发送的消息类型:
	text - 文本消息

	image - 图片消息

	link - 图文消息(easywechat 使用的还是 news)

	miniprogrampage - 小程序卡片消息	

	参考文档:
		https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/customer-message/customerServiceMessage.send.html

4.转发客服消息:
	可以将用户的消息,转发到网页版的客服工具,接入多客服系统

	返回的消息类型为:
		transfer_customer_service
	
	参考文档:
		https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/customer-message/trans.html

5.关于消息中,涉及到的媒体文件问题:
	MediaId 以及 ThumbMediaId,有 2 个接口:
		1>uploadTempMedia - 上传临时素材
			参数:
				acccess_token
				type - 文件类型(目前只有:image)
				media - form-data 中媒体文件标识,有filename、filelength、content-type等信息(FormData 表单数据)

		2>getTempMedia - 下载临时素材
			参数:
				acccess_token
				media_id - 媒体文件ID

	参考文档:
		https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/customer-message/customerServiceMessage.uploadTempMedia.html
		https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/customer-message/customerServiceMessage.getTempMedia.html

6.下发客服状态:
	这个没测试

	参考文档:
		https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/customer-message/typing.html
		https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/customer-message/customerServiceMessage.setTyping.html

7.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



 

你可能感兴趣的:(微信小程序)