微信小程序客服默认后台只支持回复文字。
如果你想自动回复二维码图片,或者一个H5页面的连接怎么办。之前要用自己服务器写接口,现在有了云函数简单多了。
第一步,添加一个云函数msgPush
直接上代码
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61// 云函数入口文件 const cloud = require('wx-server-sdk') cloud.init() //<!--下载云存储图片--> let downLoad = async (event, context) => { const res = await cloud.downloadFile({ fileID: 'cloud://bvread-test-hvcev.6276-bvread-test-hvcev-1302378864/640.png', // 图片的File ID,提前通过云开发控制台上传的图片fileId }) const buffer = res.fileContent console.log(buffer) return buffer } //<!--把媒体文件上传到微信服务器--> let upload = async (Buffer) => { return await cloud.openapi.customerServiceMessage.uploadTempMedia({ type: 'image', media: { contentType: 'image/png', value: Buffer } }) } // 云函数入口函数 exports.main = async (event, context) => { const wxContext = cloud.getWXContext() if (event.MsgType == 'miniprogrampage') { await cloud.openapi.customerServiceMessage.send({ touser: wxContext.OPENID, msgtype: 'text', text: { content: '收到 MsgType=' + event.MsgType + ';content=' + event.Content, }, }) } else if (event.MsgType == 'image') { let Buffer = await downLoad() let meida = await upload(Buffer) await cloud.openapi.customerServiceMessage.send({ "touser": wxContext.OPENID, "msgtype": "image", "image": { "media_id": meida.mediaId } }) } else { await cloud.openapi.customerServiceMessage.send({ 'touser': wxContext.OPENID, 'msgtype': 'link', 'link':{ 'title': '标题1', 'url': 'https://www.baidu.com', 'description': '描述', 'thumb_url': 'url' } }) } return 'success' }
第二步,打开云开发,添加云函数消息推送
记得添加EVENT事件
最后
以上就是务实蓝天最近收集整理的关于微信小程序客服自动回复二维码或者H5图文连接第一步,添加一个云函数msgPush第二步,打开云开发,添加云函数消息推送的全部内容,更多相关微信小程序客服自动回复二维码或者H5图文连接第一步内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复