JeffreySu/WeiXinMPSDK · error · MessageHandlerException

微信企业号不支持 IResponseMessageTransfer_Customer_Service 响应类型

Error message

微信企业号不支持 IResponseMessageTransfer_Customer_Service 响应类型

What it means

The WeChat Work message handler does not support the Transfer_Customer_Service response type. NewResponseMessageTransfer_Customer_Service() throws MessageHandlerException because WeChat Work has no 'forward to customer service' passive reply; customer service works differently in Work.

Solutions

  1. Remove the transfer-to-customer-service reply in Work handlers and reply with a supported type (text/news) instead.
  2. Implement customer service via WeChat Work's own customer-service or app-chat APIs.
  3. Branch on platform so this factory method is only invoked from Senparc.Weixin.MP handlers.

Example fix

// before
var resp = requestMessageHandler.CreateResponseMessage<IResponseMessageTransfer_Customer_Service>();
// after
var resp = requestMessageHandler.CreateResponseMessage<IResponseMessageText>();
resp.Content = "客服将尽快与您联系";
Defensive patterns

Strategy: fallback

Validate before calling

if (handler is Senparc.Weixin.Work.MessageHandlers.WorkMessageHandler<>)
{
    // no customer-service transfer in Work — reply with supported type
    resp = handler.CreateResponseMessage<IResponseMessageText>();
}

Type guard

bool IsWorkHandler(MessageHandler<DefaultWorkMessageContext> h) => h is Senparc.Weixin.Work.MessageHandlers.WorkMessageHandler<DefaultWorkMessageContext>;

Try / catch

try
{
    resp = handler.CreateResponseMessage<IResponseMessageTransfer_Customer_Service>();
}
catch (MessageHandlerException)
{
    resp = handler.CreateResponseMessage<IResponseMessageText>();
}

Prevention

When it happens

Trigger: Calling NewResponseMessageTransfer_Customer_Service() on a WorkMessageHandler to hand a message off to customer service inside DefaultResponseMessage or an OnXxx handler.

Common situations: Porting Official Account customer-service-forwarding logic to WeChat Work; using shared handler code across MP and Work without platform checks.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


AI-assisted analysis of JeffreySu/WeiXinMPSDK@be573f6f94 (2026-09-12). Data as JSON: /api/errors/65ea978024fe8011. Report an issue: GitHub.

Appendix: source

Thrown at src/Senparc.Weixin.Work/Senparc.Weixin.Work/MessageHandlers/WorkMessageEntityEnlightener.cs:91

        public override IResponseMessageMusic NewResponseMessageMusic()
        {
            throw new MessageHandlerException("微信企业号不支持 IResponseMessageMusic 响应类型");
        }

        public override IResponseMessageNews NewResponseMessageNews()
        {
            return new ResponseMessageNews();
        }

        public override IResponseMessageText NewResponseMessageText()
        {
            return new ResponseMessageText();
        }

        public override IResponseMessageTransfer_Customer_Service NewResponseMessageTransfer_Customer_Service()
        {
            throw new MessageHandlerException("微信企业号不支持 IResponseMessageTransfer_Customer_Service 响应类型");
        }

        public override IResponseMessageVideo NewResponseMessageVideo()
        {
            return new ResponseMessageVideo();
        }

        public override IResponseMessageVoice NewResponseMessageVoice()
        {
            return new ResponseMessageVoice();
        }

        public override IRequestMessageMiniProgramPage NewRequestMessageMiniProgramPage()
        {
            throw new MessageHandlerException("微信企业号不支持 IRequestMessageMiniProgramPage 响应类型");
        }
    }
}

View on GitHub (pinned to be573f6f94)