# Template Messages
Dxplaination: Service Account subscription notification function opens grayscale test, template message ability can be used normally
Template messages are only used for Service Account to send important service notifications to users and can only be used in service scenarios that meet their requirements, such as credit card swipe notifications, successful product purchase notifications, etc.Marketing messages such as ads and all other messages that may cause harassment to the user are not supported.
With regard to the rules of use, please note:
- All Service Account can see the entry for requesting template message functionality in Features - > Add Feature Plugin, but only authenticated service numbers can request and obtain permission to use template messages;
- Apply for a suitable service category based on the industry to which you certified Service Account and the type of template message you need. Open service categories can view service categories ;
- Each Service Account can set up up to 5 categories, you can change the selected category 5 times a month, after changing or deleting the category, the template under the original category will be deleted;
- After setting the category, you can query and select existing templates in the public template library to call, and 25 templates can be used at the same time per account.
- The current daily limit for template messages per account is 100 thousand, with no special limits for individual templates.[Improved interface call frequency from default 10,000 / day to 100 thousand / day on 18 November 2014. See Developer Center after MP login.]When the number of fans of the account exceeds 10W / 100W / 1000W, the daily call limit of the template message will be increased accordingly, according to the number indicated in the Service Account MP background developer center page.
For the interface documentation, please note:
- When template message is called, it mainly needs template ID and the content of each parameter assignment in template.
- The argument content in the template must end with. "DATA" or it will be considered a reserved word;
- The template retains the symbol "."
# List of interfaces
Interface Name | English name | Request Path |
---|---|---|
Send template messages | sendTemplateMessage | /cgi-bin/message/template/send |
Get the template id | addTemplate | /cgi-bin/template/api_add_template |
Query intercepted template messages | queryBlockTmplMsg | /wxa/sec/queryblocktmplmsg |
Remove the template | deleteTemplate | /cgi-bin/template/del_private_template |
Get a list of selected templates | getAllTemplates | /cgi-bin/template/get_all_private_template |
Get Industry Information | getIndustry | /cgi-bin/template/get_industry |
Set your industry | setIndustry | /cgi-bin/template/api_set_industry |
# Event push
After the template message sending task is completed, the WeChat server sends a notification of success to the server configuration address filled in the developer center.
(1) When the delivery is successful, the XML pushed is as follows:
<xml>
<ToUserName><![CDATA[gh_7f083739789a]]></ToUserName>
<FromUserName><![CDATA[oia2TjuEGTNoeX76QEjQNrcURxG8]]></FromUserName>
<CreateTime>1395658920</CreateTime>
<MsgType><![CDATA[event]]></MsgType>
<Event><![CDATA[TEMPLATESENDJOBFINISH]]></Event>
<MsgID>200163836</MsgID>
<Status><![CDATA[success]]></Status>
</xml>
Parameter explaination
parameter | Introductions |
---|---|
ToUserName | Service Account WeChat |
FromUserName | The openid of the user receiving the template message |
CreateTime | Created time |
MsgType | The message type is an event |
Event | Event ends template message sending |
MsgID | Message id |
Status | Sending status is successful |
(2) When delivery fails due to user rejection (user settings refuse to receive Service Account messages), the push XML is as follows:
<xml>
<ToUserName><![CDATA[gh_7f083739789a]]></ToUserName>
<FromUserName><![CDATA[oia2TjuEGTNoeX76QEjQNrcURxG8]]></FromUserName>
<CreateTime>1395658984</CreateTime>
<MsgType><![CDATA[event]]></MsgType>
<Event><![CDATA[TEMPLATESENDJOBFINISH]]></Event>
<MsgID>200163840</MsgID>
<Status><![CDATA[failed:user block]]></Status>
</xml>
Parameter explaination
parameter | Introductions |
---|---|
ToUserName | Service Account WeChat |
FromUserName | The openid of the user receiving the template message |
CreateTime | Created time |
MsgType | The message type is an event |
Event | Event ends template message sending |
MsgID | Message id |
Status | The sending state is that the user refuses to receive |
(3) When delivery fails for other reasons, the XML pushed is as follows:
<xml>
<ToUserName><![CDATA[gh_7f083739789a]]></ToUserName>
<FromUserName><![CDATA[oia2TjuEGTNoeX76QEjQNrcURxG8]]></FromUserName>
<CreateTime>1395658984</CreateTime>
<MsgType><![CDATA[event]]></MsgType>
<Event><![CDATA[TEMPLATESENDJOBFINISH]]></Event>
<MsgID>200163840</MsgID>
<Status><![CDATA[failed: system failed]]></Status>
</xml>
Parameter explaination
parameter | Introductions |
---|---|
ToUserName | Service Account WeChat |
FromUserName | The openid of the user receiving the template message |
CreateTime | Created time |
MsgType | The message type is an event |
Event | Event ends template message sending |
MsgID | Message id |
Status | Sending status is Sending failed (non-user rejection) |