Skip to content

微信官方文档

客服消息流程:

公众号处于开发模式时
1.用户在公众号内发送消息-->微信服务器接收
2.微信服务器POST消息-->开者者填写的url
3.开发者在响应包中返回MsgType为transfer_customer_service的消息
4.微信服务器收到响应后会把当次发送的消息转发至客服系统

用例1 公众号转发用户的消息至客服消息

csharp
public override async Task<string> OnReceiveTextMessageEvent(TextMessage receiveMessage)
{
    string fromUserName = receiveMessage.FromUserName;
    string toUserName = receiveMessage.ToUserName;
 
    //转发用户消息到客服
    TransferCustomerServiceMessage msg = new TransferCustomerServiceMessage(fromUserName, toUserName);
    var options = WeChatOptions.FirstOrDefault(c => c.Id == toUserName);
    wechat.UseAppId(options.AppId);
    return await wechat.SendMessageAsync<TransferCustomerServiceMessage>(msg);
}