Everything about WeChat Subscription Message

So Far…

David Yu
Shanghai Coders
3 min readMay 3, 2021

--

Photo by Jon Tyson on Unsplash

In the past, I wrote about template messages for WeChat Mini-Program.

In this article, I will attempt to cover broader spectrum of WeChat on this “new” subscription message. It’s new until they decide to change again.

Current Rule

One-time subscription message is the official translation for WeChat’s subscription message service.

However, the name is a bit misleading. It can seem like the user only have to subscribe once then the developer can send them an endless number of messages.

A one-time subscription message means one permission acquired from the user is only good for one message.

After you send the message, you will need to acquire the user’s permission again.

The following special business categories are an exception:

Governmental, Medical, Transportation, Finance, Education

Where to get Permission?

For Mini-Program:

User interaction is required to trigger the permission prompt.

Notes:

For WeChat Official Account:

A user tap on a special link in a WeChat Official Account article.

Steps:

  1. Add subscribe message as a plugin in the official account dashboard
  2. Create template
  3. Add a link to the article when writing an article in the official account

Doc: https://developers.weixin.qq.com/doc/offiaccount/Subscription_Messages/intro.html

For Website opened within WeChat:

Through WeChat JSSDK, a permission prompt is triggered when the user tap on something on a website.

Steps:

  1. Setup WeChat JSSDK
  2. Use special weixin tag, example below
<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">
一次性模版消息订阅
</button>
</template>
</wx-open-subscribe>
<script>
var btn = document.getElementById('subscribe-btn');
btn.addEventListener('success', function (e) {
console.log('success', e.detail);
});
btn.addEventListener('error',function (e) {
console.log('fail', e.detail);
});
</script>

Doc: https://developers.weixin.qq.com/doc/offiaccount/OA_Web_Apps/Wechat_Open_Tag.html#23

For Native App:

Through WeChat iOS or Android SDK, user jumps to WeChat to give permission.

Steps:

  1. Setup WeChat SDK with your iOS or Android app
  2. Trigger permission request on app

Doc: https://developers.weixin.qq.com/doc/oplatform/Mobile_App/One-time_subscription_info.html

How to send a message?

Here’s the part that is a bit troublesome. Depending on where you got the permission from, the API endpoint call to send the message is different.

Mini-Program

POST https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token=ACCESS_TOKEN

Doc: https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/subscribe-message/subscribeMessage.send.html

Official Account/Website

POST https://api.weixin.qq.com/cgi-bin/message/subscribe/bizsend?access_token=ACCESS_TOKEN

Doc: https://developers.weixin.qq.com/doc/offiaccount/Subscription_Messages/api.html#send%E5%8F%91%E9%80%81%E8%AE%A2%E9%98%85%E9%80%9A%E7%9F%A5

Native App

POST https://api.weixin.qq.com/cgi-bin/message/template/subscribe?access_token=ACCESS_TOKEN

Doc: https://developers.weixin.qq.com/doc/oplatform/Mobile_App/One-time_subscription_info.html

Where do users get messages?

For Mini-Program and Native App, the message will appear in “Service Message”.

For WeChat Official Account or Website with JSSDK, it will appear in the Official Account’s conversation box if the user has already subscribed to the Official Account. Otherwise, it will fall into “Service Message” as well.

Conclusion

If you want to learn more about WeChat-related development, click here.

--

--

David Yu
Shanghai Coders

Full-stack developer based in Shanghai. I help people turning their ideas into reality.