Implementing WeChat Subscription Messages After the 2021 Template Change
This guide explains the new WeChat service account subscription message workflow, covering terminology, user subscription steps via JSSDK, handling callback XML, and sending notifications through the official API, while also addressing common integration challenges.
Background
WeChat announced the "Service Account Template Message Capability Adjustment"; the original template message interface will be discontinued at 2021-04-30 24:00 , after which it cannot be used.
In short, the model follows mini‑programs: public accounts can no longer push template messages directly to subscribed users (e.g., a user who follows a bank's service account will not receive transaction alerts).
The author, whose industry heavily relies on template messages, shares the redesign and implementation of subscription notifications for reference.
Name Explanation
One‑time subscription : The user subscribes once and the service account can send a single corresponding subscription notification at any time.
Long‑term subscription : The user subscribes once and the service account can send multiple notifications over time; this mode is only available for public‑service domains such as government, healthcare, etc.
Service notification : WeChat enables a service notification feature by default, showing an orange notification in the user's chat list.
User Subscription Process
As shown, users can click buttons inserted in the public‑account article to subscribe to multiple notifications.
In an H5 page provided by developers, users can invoke the subscription button via JSSDK.
<code><wx-open-subscribe template="TenvU22BA1jCp4YHfYEpRuESXYReQyDuhs4vbdWA99I" id="subscribe-btn">
<template slot="style">
<style>
.subscribe-btn { color:#fff; background-color:#07c160; }
</style>
</template>
<template>
<button class="subscribe-btn">Class Notification</button>
</template>
</wx-open-subscribe>
<script>
var btn = document.getElementById('subscribe-btn');
btn.addEventListener('success', function(e) {
// Determine whether the user allowed or cancelled
// If no WeChat callback can be received, save the subscription status here
});
</script></code>Receiving WeChat Callback Subscription Event
When a user subscribes via article/H5, WeChat pushes the following XML to the developer's endpoint.
<code><xml>
<ToUserName>PublicAccountID</ToUserName>
<FromUserName>UserOpenID</FromUserName>
<CreateTime>Timestamp</CreateTime>
<MsgType><![CDATA[event]]></MsgType>
<Event><![CDATA[subscribe_msg_popup_event]]></Event>
<SubscribeMsgPopupEvent>
<List>
<TemplateId>TemplateID</TemplateId>
<SubscribeStatusString>UserAction (agree/cancel)</SubscribeStatusString>
<PopupScene>Scene (article/H5)</PopupScene>
</List>
</SubscribeMsgPopupEvent>
</xml></code>Store the information in a user‑subscription‑template relation table for later notification pushes.
Push Notification Process
Call the WeChat service to send a subscription notification.
<code>POST https://api.weixin.qq.com/cgi-bin/message/subscribe/bizsend?access_token=ACCESS_TOKEN</code>Request parameters:
<code>{
"touser": "RecipientOpenID (must have subscribed to the template)",
"template_id": "MessageTemplateID",
"page": "Link to open on click",
"data": {
"name1": { "value": "Sample" },
"time7": { "value": "2021-01-28 23:15:42" }
}
}</code>Problem Summary
Long‑term subscription application issues: currently only government/public sectors are supported; other industries must submit materials in advance to avoid service interruption when the template expires.
Framework adaptation issues: mainstream WeChat SDKs (WxJava, JFinal Weixin) do not yet implement the related events, requiring developers to handle callbacks manually.
Avoiding user cancellation: both "allow" and "cancel" actions from the JSSDK trigger callbacks; when cancelled, provide clear explanations and a fallback SMS notification strategy.
Java Architecture Diary
Committed to sharing original, high‑quality technical articles; no fluff or promotional content.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.