If an Official Account is under the development mode, when a Weixin user sends messages to the Official Account, the Weixin server will first POST the messages to the URL configured by the developer. If the messages are intended to be forwarded to the Customer Service system, the developer must return the messages with MsgType as transfer_customer_service in the response package. After receiving the response, the Weixin server forwards the messages sent in that chat session to the Customer Service system. You can also add TransInfo in XML when returning the messages with MsgType as transfer_customer_service to designate a Customer Service account to receive these messages.

When the user is connected to the Customer Service, before the Customer Service closes the chat session, messages sent by the user in the chat session are directly forwarded to the Customer Service system. When the chat session is not closed by the Customer Service after 30 minutes, the Weixin server will automatically stop forwarding messages to the Customer Service, and the messages will be sent to the URL configured by the developer.

When the user is waiting in queue, the messages sent by the user will still be pushed to the URL configured by the developer.

Note that, only messages sent by Weixin users will be forwarded, any other events (such as a menu is tapped, or a geographic location is reported) should not be forwarded; otherwise, the Customer Service will see meaningless messages on the customer service system.

Forward messages to Customer Service

If an Official Account is under the development mode, when a Weixin user sends messages to the Official Account, the Weixin server will first POST the messages to the URL configured by the developer. If the messages is intended to be forwarded to the Customer Service system, the developer must return the messages with MsgType as transfer_customer_service in the response package. After receiving the response, the Weixin server forwards the messages sent in that chat session to the Customer Service system.

 <xml> 
  <ToUserName><![CDATA[touser]]></ToUserName>  
  <FromUserName><![CDATA[fromuser]]></FromUserName>  
  <CreateTime>1399197672</CreateTime>  
  <MsgType><![CDATA[transfer_customer_service]]></MsgType> 
</xml>

Parameters

Parameter Required Description
ToUserName Yes Recipent's ID (OpenID received)
FromUserName Yes Developer's Weixin ID
CreateTime Yes Creation time of the message (integral)
MsgType Yes transfer_customer_service

Forwarding messages to specified Customer Service

If there are multiple Customer Service personnel logging in to the Customer Service system at the same time and "auto connection" is enabled to receive users' messages, each user's messages that are forwarded to the Customer Service system will be assigned to one of the Customer Service personnel. If you want to forward a user's messages to a designated Customer Service personnel, add TransInfo when returning transfer_customer_service messages. Note that if the designated Customer Service personnel is not available (being offline, auto connection is disabled, or the number of users connected automatically has reached the limit), the user will be directly connected to the designated Customer Service personnel, and other Customer Service personnel will not receive any notification or connect to the user. It is recommended to first check the availability of the Customer Service via the Get Online Customer Service Connection Info API when designating the Customer Service, and ensure the available Customer Service personnel can be designated to provide timely service for users.

Sample code

 <xml> 
  <ToUserName><![CDATA[touser]]></ToUserName>  
  <FromUserName><![CDATA[fromuser]]></FromUserName>  
  <CreateTime>1399197672</CreateTime>  
  <MsgType><![CDATA[transfer_customer_service]]></MsgType>  
  <TransInfo> 
    <KfAccount><![CDATA[test1@test]]></KfAccount> 
  </TransInfo> 
</xml>

Parameters

Parameter Required Description
ToUserName Yes Recipent's ID (OpenID received)
FromUserName Yes Developer's Weixin ID
CreateTime Yes Creation time of the message (integral)
MsgType Yes transfer_customer_service
KfAccount Yes Specifies the Customer Service account to receive the chat