WeChat Mini Program Customer Service

Let AI reply to customer service messages in WeChat Mini Programs, and take over in the dashboard after handoff to a human agent.

When a customer taps the "Contact Support" button in your mini program, they enter a WeChat customer service session, and their messages are answered by AI. After handing over to a human agent, you serve them in "Conversations" in the dashboard, and your replies are sent back to the customer's WeChat.

Step 1: Connect on the "Channels" page in the dashboard. Enter your mini program's AppID and AppSecret (WeChat Official Accounts Platform → Development → Development Management → Development Settings). Before saving, we actually exchange for an access_token with WeChat, so if something's wrong you'll see the reason right away. We use the stable_token API to get the token, so the token your own server is already using won't be invalidated.

Step 2: Configure Message Push. On the WeChat Official Accounts Platform → Development → Development Management → Development Settings → Message Push, enable it and fill in the values shown on the "Channels" page:

ItemWhat to enter
URL{API}/channels/wechat/{渠道 ID} — you can copy it from the Channels page
Token / EncodingAESKeyGenerated on the Channels page; you can copy them
Message encryption methodSafe Mode
Data formatJSON

When you submit, WeChat will verify the URL; once that succeeds, the channel status becomes "Running". If your mini program has an IP allowlist enabled, add the server IP shown on the Channels page.

Step 3: Add the button to your mini program.

<button open-type="contact" session-from="{{userToken}}">联系客服</button>

Put the user_token issued by your server into session-from (format: see Identify signed-in customers), and the AI will know which member the customer is and can look up their orders. If you leave it out, the customer is treated as anonymous. The token is only verified once, when the customer enters the session, so we recommend an exp of at least 1 hour.

Notes:

  • After a customer sends a message, you can reply within 48 hours (a WeChat rule); after that, you have to wait for the customer to send another message. Replies that can't be delivered are marked in red in "Conversations" along with the reason.
  • We currently handle text messages and mini program cards; images and voice messages are recorded in the conversation for agents to see, and while the AI is handling the chat it asks the customer to describe things in text instead.
  • If you fill in a "Product page path" in the channel (e.g. pages/goods/detail?id={id}), products the AI recommends are also sent as mini program cards, with {id} replaced by the product's external_id. A product needs a JPG or PNG image to be sent as a card.
  • A welcome message is sent once when the same customer enters a support session for the first time within 24 hours; you can turn this off in the channel. The content comes from the welcome message in "Bot Settings".
  • Markdown isn't supported in WeChat customer service messages, so the AI answers in plain text.

Was this page helpful?

Last updated: