# Forward customer service message
If the Mini Program has set up a message push, when ordinary WeChat users send messages to the Mini Program customer service, the WeChat server will first send the message. POST Completed by the developer. URL If you want to forward the message to the web customer service tool, you need the developer to return in the response package MsgType for transfer_customer_service After receiving the response, the WeChat server will forward the sent message to the customer service system.
After the user is connected by the customer service, before the customer service closes the session and during the session, the messages sent by the user will be forwarded directly to the customer service system. When the session exceeds 30 When the customer service is not closed, the WeChat server will automatically stop forwarding to the customer service and resume sending the message to the developer's URL Go.
While the user is in the waiting queue, the messages sent by the user will still be pushed to the developer filled out the URL Go.
Here, it is especially important to note that only messages sent by WeChat users should be forwarded, and other events (such as users calling a customer service session from a Mini Program) should not be forwarded; otherwise, the customer service will see some meaningless messages on the customer service system.
# Message forwarding to the web version of the customer service tool
The developer simply returns in the response package MsgType for transfer_customer_service After receiving the response, the WeChat server will forward the sent message to the customer service system.
If you are using a push message received by your own server, return the following format XML Data:
<xml>
<ToUser ><![CDATA[cough]]></ToUser >
<FromUserName><![CDATA[fromuser]]></FromUserName>
<CreateTime>1399197672</CreateTime>
<MsgType ><![CDATA[transfer_customer_service]]></MsgType >
</xml>
Dxplaination of parameters
parameter | Is it necessary | describe |
---|---|---|
ToUser | yes | Recipient account number (OpenID received) |
FromUserName | yes | Mini Program original id |
CreateTime | yes | Message Creation Time (Integer) |
MsgType | yes | transfer_customer_service |
If it is usedPush messages received by cloud functions, the cloud function needs to return the same format after being triggered by the customer service message JSON
Data:
// ...
exports.main = async (event, context) => {
// Judgment processing customer service message ...
// Finally return JSON
return {
MsgType: 'transfer_customer_service',
ToUserName: 'cough',
FromUserName: 'fromuser',
CreateTime: parseInt (+new Date / 1000),
}
}