Loading…

Send subscription message

# Step 1: Get template ID Manually configure and obtain the template ID on the WeChat public platform: Log in to [https://mp.weixin.qq.com](https://mp.weixin.qq.com/) to obtain the template. If there is no suitable template, you can apply to add a new template, which can be used after passing the review. ![](https://dcdn.it120.cc/yuque/0/2019/jpeg/572726/1575727618913-56fbca86-7f23-4790-97e5-1d28342c71a4.jpeg) # Step 2: Background configuration template message ![](https://dcdn.it120.cc/yuque/0/2019/png/572726/1575815541455-c5a4b468-e625-416d-8759-6169c8a77319.png) ## Template data ```json { "thing1": { "value": "Apply to become a distributor", "color": "#173177" }, "phrase2": { "value": "Failed to pass review", "color": "#FF0000" }, "thing4": { "value": "${saleDistributionApply.remark}", "color": "#173177" } } ``` 1. Please modify thing1, phrase2, and thing4 in the above template data according to the specific keywords of the template you choose. 2. The color variable is only valid for service account template messages; the mini program subscription message is invalid and does not need to be set; ## Variables supported in template data ### Order Same as ["**Detailed Description of Cloud Printer Template Variables**"](https://www.yuque.com/apifm/doc/wtviya) ### Product Management ${goods.XXX} + name product name + subName subtitle + tags product tags, multiple tags separated by commas in English + originalPrice original price + minPrice current price + stores current inventory + shopId The store ID of the store to which this product belongs + limitation Is the purchase limit enabled for this product? + miaosha true means flash sale product; false means not flash sale product + seckillBuyNumber seckill buy limit for each user + minScore How many points do you need to pay? + numberSells sales quantity + numberOrders number of orders + purchaseNotes Purchase Notes + characteristic features, selling points + vetStatus 0 Pending review 1 Review passed 2 Review failed + deliveryType delivery type: 0 not set 1 express only 2 self-pickup only 3 express + self-pickup + curUserHasFaved Whether the currently logged in user has favorited this product ${user.XXX} + id user number + avatarUrl avatar + nick nickname + mobile mobile phone number + gender 0 unknown 1 male 2 female + isSeller whether it is a distributor + referrer inviter + isIdcardCheck Whether real-name authentication has been carried out + birthday birthday + levelId User membership level ID ${userCash.XXX} + balance available balance + freeze freeze amount + fxCommisionPaying Pending Distribution Commission + growth growth value + score available points + scoreLastRound The remaining number of points in the previous round, used to clear the points logic regularly + totalPayAmount cumulative payment amount + totalPayNumber The cumulative number of payments + totalScore the cumulative number of points earned + totalWithdraw cumulative withdrawal amount + totleConsumed The accumulated consumption amount [will be calculated after the order is confirmed and received] + totalRechargeAmount cumulative recharge amount + totalRefundAmount cumulative refund amount [the amount refunded to the balance, the amount returned by the original route is not counted] ### Distributor application ${saleDistributionApply.XXX} ```json mobile: mobile phone number name: name status: 0 under review 1 failed 2 passed remark: remark dateAdd: application time ``` ### Leave a comment ${comment.XXX} For specific fields, you can view the background comment message return data structure fields. ```plain ${extJson.XXXXXX} ``` Extended attributes of messages/comments ### CMS Articles ${cmsnews.XXX} For specific fields, you can view the background cms article management list and return data structure fields. ### Queue number calling ${queuingUpType.XXX} ```plain name queue name descript queue description numberGet The total number of people who have taken numbers numberTotle The maximum number of numbers that can be taken How many minutes is expected for each minitus number to be in service? curNumber: Which number is currently being served? ``` ${queuingUpLog.XXX} ```plain number number mobile The mobile phone number filled in when picking up a number serviceWindow service window name ``` ###Self-built live broadcast room ```javascript ${liveRoom.XXXX} ``` ```plain id room ID uid anchor user number name room name ``` ### Latest announcement reminder ```javascript ${notice.XXXX} ``` ```plain id announcement id type announcement type title title redirectUrl The jump address of the announcement descript announcement summary introduction content announcement content dateAdd announcement release time (must be formatted, see below for details) ``` ### Group success/failure reminder Variables are the same as the order module ### Apply for invoicing ```javascript ${invoice.XXXX} ``` + id apply for ID + orderId order ID + orderNumber order number + comName company name + tfn tax number + tel contact number + address address + account bank account + amount invoice amount + consumption invoicing content + status status: 0 pending 1 failed 2 invoicing 3 invoicing completed + statusStr status description + remark note + file invoice download address + mobile mobile phone number to receive invoices + email email address to receive invoices + dateAdd application invoice time + dateUpdate last operation time ```plain ${extJson.XXXXXX} ``` Extended attributes when applying for invoicing ### CP activities ```javascript ${cpactivityJoin.xxx} ``` + id registration record ID + uid registration user ID + cpactivityId activity ID + dateAdd registration time + status registration status 0 matching 1 matching failed 2 matching successful + amount registration fee paid + cpuid matching peer user number ```javascript ${cpactivityInfo.xxxxx} ``` + title activity title + dateStart start time + dateDeadline deadline + dateMatch announces result time + numberJoin number of applicants + numberMen Number of boys + numberWomen Number of girls + amountBoy boy registration fee + amountGirl girl registration fee ### Points changes ```javascript ${scoreLog.xxx} ``` + behavior 0 income 1 expense + behaviorStr Chinese description + type 0 Register 1 Invite friends 2 Daily check-in 3 Redeem coupons 4 Administrator adjustments 5 Recharge for free 6 Spending rebates 7 Points for good reviews 11 Purchase goods 12 Point coupons 13 Distribution rebates 14 Mini program forwarding to WeChat group + typeStr Chinese description + score number of transaction points + scoreLeft remaining available points + dateAdd transaction time + remark note ### User Assets ```javascript ${userCash.xxx} ``` + balance available balance + freeze freeze amount + fxCommisionPaying Pending Distribution Commission + growth growth value + score available points + scoreLastRound The remaining number of points in the previous round, used to clear the points logic regularly + totalPayAmount cumulative payment amount + totalPayNumber The cumulative number of payments + totalScore the cumulative number of points earned + totalWithdraw cumulative withdrawal amount + totleConsumed The accumulated consumption amount [will be calculated after the order is confirmed and received] + totalRechargeAmount cumulative recharge amount + totalRefundAmount cumulative refund amount [the amount refunded to the balance, the amount returned by the original route is not counted] ## Trigger status ### Order -1 Closed order 0 Pending payment 1 Paid and awaiting shipment 2 Shipped and awaiting confirmation 3 Confirmed receipt and awaiting evaluation 4 Evaluated ### Distributor application 1 Fail 2 Pass # Step 3: Obtain distribution permissions For details, see the mini program message subscription interface [wx.requestSubscribeMessage](https://developers.weixin.qq.com/miniprogram/dev/api/open-api/subscribe-message/wx.requestSubscribeMessage.html) The bindTab event of the button is required to obtain authorization. The authorization window cannot pop up in other ways. # One-time subscription and long-term subscription [https://tech.qq.com/a/20191015/009298.htm](https://tech.qq.com/a/20191015/009298.htm) `One-time subscription messages can meet the needs of most service scenarios of mini programs, but there are scenarios in the offline public service field that one-time subscriptions cannot meet. For example, if a flight is delayed, message reminders need to be sent multiple times based on real-time flight dynamics. To facilitate service, the platform provides long-term subscription messages. After a user subscribes once, developers can send multiple messages over a long period of time. Currently, long-term subscription messages are open to offline public services such as government affairs, medical care, transportation, finance, and education. In the future, industry needs will be comprehensively evaluated and user experience will be continuously improved. ` #Why didn't I receive the push message? ## Mini program detection Check whether the following authorization information has popped up on the mini program, and whether the user has clicked "Allow": ![](https://dcdn.it120.cc/yuque/0/2020/png/572726/1585719158506-c648066b-657a-4286-a9f1-7181a8750e62.png) ## Determine whether it is "subscription message" or "template message" Make sure you are adding a subscription message template, do not mistakenly use it as a template message template ## Write the variables first to eliminate sending exceptions caused by variable errors. When configuring the subscription message in the "apifm", do not use variables for the time being. Use the official WeChat example for testing the variables. If the hard-coded variables can be received, then the problem is caused by the variables. We will proceed to the next step of troubleshooting. If the variable is hard-coded and still cannot be received, it means there is a problem with the json data you configured. Please check carefully.Example:![](https://dcdn.it120.cc/yuque/0/2020/png/572726/1585720223025-322bcede-a309-4be3-b503-408c4df4264c.png) This template has three variables. When testing, write down these three variables using the example content on the left to see if you can receive the message, such as: ```json { "character_string1": { "value": "2019103115382541014" }, "character_string5": { "value": "YT2018315450862" }, "time9": { "value": "2019-11-05 11:11:11" }, } ``` Confirm the content of the variable and use the official example directly, so that you can definitely receive the message, and then troubleshoot the problem caused by the variable in the next step. ## Improper use of variables ### Variable restrictions WeChat variables cannot use any characters. For details, please check the official instructions: [https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/subscribe-message/subscribeMessage.send.html](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/subscribe-message/subscribeMessage.send.html) ### The time and date must specify the format All date class variables must specify the date display format, such as the current time: ```javascript ${.now?string('yyyy-MM-dd HH:mm:ss')} ``` ** here ?string('yyyy-MM-dd HH:mm:ss') ** cannot be omitted