模板消息相关
模板消息相关官方文档
模板消息相关服务封装于 OfficialTemplateMessageService
类中,可通过如下方式引入:
import { OfficialTemplateMessageService } from '@iot9x.com/nestjs-official'
发送模板消息
/**
* 发送模板消息
* @param appid 公众号appID
* @param openId 接收人openid
* @param templateId 模板消息ID
* @param data 消息内容
* @param options 附加参数
* @returns 模板消息发送结果
*/
async sendTemplateMessage(appid: string, openId: string, templateId: string, data: Record<string, any>, options?: SendTemplateMessageOptions): Promise<SendTemplateMessageResponse> {}
其中, SendTemplateMessageOptions
类型如下所示:
/**
* 发送公众号模板消息附加参数
* @see https://developers.weixin.qq.com/doc/offiaccount/Message_Management/Template_Message_Interface.html#5
*/
export interface SendTemplateMessageOptions {
/** 跳转URL */
url?: string;
/** 跳转小程序信息 */
miniprogram?: {
/** 小程序appid */
appid: string;
/** 小程序页面路径,可加参数 */
pagepath: string;
};
}