

通过微信公众号向关注用户发送消息。
node.js
1、在微信公众号后台的 开发 > 基本配置 获取appid和appsecret
2、关注用户在此公众号的openid
1、创建云函数,填写配置参数,并设置输入参数接收openid
2、编写API,调用发送客服消息接口:weixinApi.sendText
async function run($input, $output, $modules = modules) {
const weixinApi = $modules.weixinApi;
let result = await weixinApi.sendText(
$input.openid,//传入的openid
'<a href="https://www.baidu.com">点此进入系统~</a>'//文本消息内容
);
$output.result = result;//输出结果
}
注:发送文本消息支持<a>标签。
在API下方调试,输入openid,返回”errmsg”:”OK”说明发送成功
微信公众号更多API可参考扩展库:https://github.com/node-webot/co-wechat-api
也可参考官方开发文档:
https://developers.weixin.qq.com/doc/offiaccount/Message_Management/Service_Center_messages.html