#Adjust
WeChat Mini Program has disabled the template message function and uses subscription messages instead, so bosses please move on:
[**"Send Subscription Message"**](https://www.yuque.com/apifm/doc/sw1dg9)
# Preface
This tutorial is based on the "apifm-wxapi" module and teaches you how to quickly implement small program development, so you may need to understand the following knowledge points first:
["Creating HelloWorld Project"](https://www.yuque.com/apifm/doc/hezlrm)
["Use "apifm-wxapi" to quickly develop small programs"](https://www.yuque.com/apifm/doc/mdldsd)
["Register for free to open the backend and obtain an exclusive domain name"](https://www.yuque.com/apifm/doc/qr6l4m)
In this case, some functions require the user to log in before they can be operated, which means token authorization is required. Please understand first:
["WeChat Mini Program login to obtain openid and third-party tokens"](https://www.yuque.com/apifm/doc/kaygbw)
# Function introduction
Send template messages to users, so you must first set up your mini program appid and secret in the background
["Appid and secret of background configuration applet"](https://www.yuque.com/apifm/doc/ngdgyi)
# Select the appropriate template message template
Log in to your mini program backend [https://mp.weixin.qq.com/](https://mp.weixin.qq.com/). In the template message on the left menu, you can choose to select a template from the existing template library / set the template message yourself and submit it for review to enable your template message template.
After enabling the template, you will be able to obtain the template message ID and message variables
# apifm-wxapi method
### Save formid/prepaymentId
```javascript
WXAPI.addTempleMsgFormid(token, type, formId)
```
> type: form/pay, representing payment or form submission respectively.
>
> formId: In the form submission scenario, it is the formId carried by the submit event; in the payment scenario, it is the prepay_id of the payment
>
Mini programs have special regulations for sending template messages to users:
[https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/template-message.html](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/template-message.html)
1. When a user completes a payment in the mini program, developers are allowed to push a limited number of template messages to the user within 7 days (3 messages can be sent for one payment, and the number of messages for multiple payments is independent and does not affect each other)
2. When a user submits a form in a mini program and the form is declared to send template messages, and the developer needs to provide services to the user, the developer can be allowed to push a limited number of template messages to the user within 7 days (one message can be sent once a form is submitted, and the number of messages sent after multiple submissions is independent and does not affect each other)
_So in order to break through this quantity limit, we collect a lot of formid/prepaid IDs in advance, so that we can send template messages to users without restrictions_
**Please use your mobile phone to debug mini program template messages. The formid obtained by the development tool is a mock (simulated) and cannot be used to actually send template messages**
### Send template message to user
```javascript
WXAPI.sendTempleMsg(Object object)
```
> For detailed parameter description, please refer to the interface document.
>
> Can send messages immediately; send messages triggered by conditions
>
This method can specify a formid/prepayment Id, or you can not pass this parameter, then the system will automatically obtain a formid/prepayment Id stored in the above method to send template messages.
**For more detailed parameter usage and more advanced advanced usage methods, please refer to the API interface documentation: **
["api interface document"](#)
_More usage methods about apifm-wxapi: _
["apifm-wxapi Instructions for Use"](https://github.com/gooking/apifm-wxapi/blob/master/instructions.md)
_Download the Demo code of this case: _
["apifm-wxapi using Demo program"](https://github.com/gooking/apifm-wxapi-demo)
Looking forward to your progress!
grateful!