WeChat Onboarding: Official Account to Template Send
This guide walks you from an empty WeChat channel to a working, production-ready setup. It complements the WeChat channel page, which covers every field, error code, and rate limit in reference form — this guide is the ordered path you follow the first time, and re-run whenever you connect, rotate, or retire an Official Account.WeChat is a beta channel. The send and receive paths run end to end, but onboarding is bring-your-own-credential: nothing sends until you provision a WeChat Official Account, get at least one template approved, and connect the account’s access token to Orbit.
1. Prerequisites: Official Account and access token
WeChat Official Account messaging is template-only and follower-only. Two upstream prerequisites exist before Orbit can send anything:- Register a WeChat Official Account in your organization. Any account type (service or subscription) can send template messages if it is verified by WeChat — unverified accounts cannot select template message functions.
- Generate an access token through the WeChat token grant. The token is short-lived (about two hours); WeChat returns
errcode 40001the moment it expires. Because the token rotates this quickly, plan for a central refresh — see Credential rotation below.
- In the Orbit dashboard, open Settings → Channels → WeChat and paste the access token. Orbit stores it encrypted at rest and masks it after submit; it never appears in an API response.
503 CHANNEL_NOT_CONFIGURED. That connection step is the only Orbit-side gate — there is no review cycle on the Orbit side, only WeChat’s own account verification and template approval.
2. Pick and approve a template
WeChat Official Account messaging carries no free-form text: every send is a pre-approved template message selected bytemplate_name, with template_params filling the template’s placeholders.
- In the WeChat Official Account admin console, choose a template from the library (or submit your own) and wait for WeChat’s approval. Each approved template gets a template id — that id is what you pass as
template_name. - Each template declares named placeholders in the
{{key.DATA}}shape:{{order_id.DATA}},{{carrier.DATA}}. Yourtemplate_paramsobject is a flat string-to-string map keyed by those placeholder names, without the{{...}}plumbing —{ "order_id": "A1024", "carrier": "SF Express" }.
template_name is rejected with 422 VALIDATION_ERROR, and an id the account has not been approved for comes back from WeChat as errcode 40037 (502 MESSAGE_SEND_FAILED with the errcode in the error message). Pick the template upstream first; the API cannot substitute one.
3. Send your first template message
Send withPOST /api/v1/messages/wechat:
- curl
- Node.js
- Python
202 Accepted means persisted and queued; the terminal delivered / failed state arrives later on the delivery-status webhook. To defer the send, pass scheduled_at as an RFC 3339 timestamp; the message sits as scheduled and stays editable or cancellable until dispatch (the pattern lives in Message scheduling).
For a bulk broadcast, do not loop the single-send endpoint — submit a campaign with channel: "wechat"; the campaign carries the same template_name / template_params payload and skips recipients without a connected openid.
4. OpenID targeting and metadata.url deep links
Two WeChat-specific addressing details:
tois the follower’s openid. The openid is scoped to your Official Account — it is not the user’s WeChat id, and it is not portable to another OA. Followers hand it to you when they contact you: every inbound reply carries the sender’s openid on themessage.receivedwebhook (event.data.from), so store it on the contact record and reuse it for outbound targeting. A send to a string that is not a follower of your OA comes back from WeChat aserrcode 40003— do not retry those; the recipient is not addressable.metadata.urldeep-links the message. Set it to an H5 page and the follower taps the rendered template message straight into it — order details, a booking page, a claim form.metadatais echoed back on the delivery and inbound webhooks, so you can reconcile your own identifiers end to end.
5. Inbound: replies and signature verification (optional)
There is no WeChat webhook for you to register — the Orbit messaging gateway normalizes inbound replies and eachTEMPLATESENDJOBFINISH delivery callback, then forwards them to you on the standard Orbit webhook surface. Subscribe under Settings → Webhooks:
message.receivedwithchannel: "wechat"— a follower reply. The sender’s openid sits underevent.data.from.message.statuswithchannel: "wechat"— the delivery callback advancing your outbound message to its terminaldelivered/failedstate.
6. Credential rotation and errors you will actually see
The access-token lifecycle is the one operational burden the beta channel leaves to you. The OA access token is a bearer credential — anyone holding it can send as your Official Account — so:- Rotate centrally and before expiry. Refresh the token through the WeChat grant, then paste the new value under Settings → Channels → WeChat. While an expired token sits connected, sends fail with
errcode 40001until the fresh one lands. - Never commit a token to git, and scope each environment to its own Official Account so a leaked dev token cannot reach customer traffic.
Branch on the errcode rather than retrying blindly: 40001 and 40037 are recoverable, 40003 is not — the recipient cannot be reached.
Compliance notes
Consent and opt-out remain tenant-owned controls. A follower reply of “unsubscribe” (or your locale-equivalent) arrives as a normalmessage.received inbound event — fold it into your suppression list just as you would for SMS, using the patterns in Opt-out lists and the Public consent form guide for capture. WeChat’s own template-approval process is upstream and is separate from Orbit’s consent enforcement.
Where to go next
- WeChat channel page — full field reference, scheduling semantics, campaign broadcasting, and the pricing note.
- APAC channels onboarding — the same playbook for LINE, KakaoTalk, and Zalo, with a channel-picker per region.
- Fallback chains — position WeChat as a last-hop fallback to SMS or vice versa.
- Inbox setup — route inbound WeChat replies to your team.